Skip to content

Commit

Permalink
Merge pull request #2820 from 10up/fix/issue-2807
Browse files Browse the repository at this point in the history
WP-CLI index timers: Cast values to float
  • Loading branch information
felipeelia authored Jun 7, 2022
2 parents c0aa3e7 + 46419c5 commit 94f8cfe
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions includes/classes/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -1530,7 +1530,7 @@ protected function timer_start() {
*/
protected function timer_stop( $precision = 3 ) {
$diff = microtime( true ) - $this->time_start;
return number_format( $diff, $precision );
return (float) number_format( (float) $diff, $precision );
}

/**
Expand All @@ -1542,7 +1542,7 @@ protected function timer_stop( $precision = 3 ) {
* @return string
*/
protected function timer_format( $microtime, $format = 'H:i:s.u' ) {
$microtime_date = \DateTime::createFromFormat( 'U.u', number_format( $microtime, 3, '.', '' ) );
$microtime_date = \DateTime::createFromFormat( 'U.u', number_format( (float) $microtime, 3, '.', '' ) );
return $microtime_date->format( $format );
}

Expand Down

0 comments on commit 94f8cfe

Please sign in to comment.