Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WP-CLI index timers: Cast values to float #2820

Merged
merged 1 commit into from
Jun 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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