Skip to content

Commit

Permalink
WP-CLI index timers: Cast values to float
Browse files Browse the repository at this point in the history
felipeelia committed Jun 2, 2022
1 parent c0aa3e7 commit 46419c5
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
@@ -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 );
}

/**
@@ -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 );
}

0 comments on commit 46419c5

Please sign in to comment.