planetteamspeak / ts3phpframework

Modern use-at-will framework that provides individual components to manage TeamSpeak 3 Server instances
https://www.planetteamspeak.com
GNU General Public License v3.0
209 stars 59 forks source link

Fix float to int conversion error #188

Closed Sebbo94BY closed 1 year ago

Sebbo94BY commented 1 year ago

Fixes the following error: Implicit conversion from float to int loses precision

Exception:

   Whoops\Exception\ErrorException 

  Implicit conversion from float 1678058856.0934 to int loses precision

  at vendor/planetteamspeak/ts3-php-framework/src/Helper/Profiler/Timer.php:93
     89▕
     90▕         $this->data["realmem_start"] = memory_get_usage(true);
     91▕         $this->data["emalloc_start"] = memory_get_usage();
     92▕
  ➜  93▕         $this->started = microtime(true);
     94▕         $this->running = true;
     95▕     }
     96▕
     97▕     /**

      +3 vendor frames 
  4   [internal]:0
      PlanetTeamSpeak\TeamSpeak3Framework\Adapter\ServerQuery::__destruct()
ronindesign commented 1 year ago

There's no point in using microtime(true) if we don't want float, i.e. microseconds, since intval() will just truncate of the microseconds information and result in just "seconds".

Since microtime(true) is set explicitly and I believe intentionally, the fix should be to change the initial types from int to float so there's no type conversion.

Sebbo94BY commented 1 year ago

Ok, probably the better solution. 😅

Thanks for updating and merging it!