Skip to content

Commit

Permalink
Fix float to int conversion error (#188)
Browse files Browse the repository at this point in the history
* Fix float to int conversion error

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

* Fix init var type to resolve implicit type conversion

Class variable was initialized as int, but then used in float arithmetic. Init type changed from int to float.

* Update `getRuntime` return value

* getQueryRuntime now always returns as `float`

---------

Co-authored-by: sebastian_kraetzig <sebastian.kraetzig@4g-server.eu>
Co-authored-by: Tim Turner <tturner@ronin-design.com>
  • Loading branch information
3 people authored Mar 9, 2023
1 parent 6d73234 commit 3d06c49
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/Adapter/ServerQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,11 @@ public function getQueryCount(): int
}

/**
* Returns the total runtime of all queries.
* Returns the total runtime in microseconds of all queries.
*
* @return mixed
* @return float
*/
public function getQueryRuntime(): mixed
public function getQueryRuntime(): float
{
return $this->getProfiler()->getRuntime();
}
Expand Down
12 changes: 6 additions & 6 deletions src/Helper/Profiler/Timer.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ class Timer
protected bool $running = false;

/**
* Stores the timestamp when the timer was last started.
* Stores the timestamp in microseconds when the timer was last started.
*
* @var integer
* @var float
*/
protected int $started = 0;
protected float $started = 0;

/**
* Stores the timer name.
Expand Down Expand Up @@ -114,11 +114,11 @@ public function stop(): void
}

/**
* Return the timer runtime.
* Return the timer runtime in microseconds.
*
* @return mixed
* @return float
*/
public function getRuntime(): mixed
public function getRuntime(): float
{
if ($this->isRunning()) {
$this->stop();
Expand Down

0 comments on commit 3d06c49

Please sign in to comment.