yiisoft / yii2-debug

Debug Extension for Yii 2
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
201 stars 149 forks source link

php 8.1 multiple Implicit conversion from float 152815.288066864 to int loses precision #470

Closed 515orestis closed 2 years ago

515orestis commented 2 years ago

What steps will reproduce the problem?

if you bypass https://github.com/yiisoft/yii2-debug/issues/465 by removing the implementation in opis SerializableClosure.php you get multiple Implicit conversions from float yii2-debug/src/views/default/panels/db/detail.php line 53 -54 ` $millisecondsDiff = (int)(($timeInSeconds - (int)$timeInSeconds) * 1000);

            return date('H:i:s.',(int) $timeInSeconds) . sprintf('%03d', $millisecondsDiff);`

you need cast int

yii2-debug/src/models/search/Base.php line 33-38 ` if (isset($value)&&mb_strpos($value, '>') !== false) { $value = (int)str_replace('>', '', $value); $filter->addMatcher($attribute, new matchers\GreaterThan(['value' => $value]));

    } elseif (isset($value)&&mb_strpos($value, '<') !== false) {
        $value = (int)str_replace('<', '', $value);`

cast int and add isset

yii2-debug/src/views/default/panels/profile/detail.php line 48 -50

$timeInSeconds = (int)$data['timestamp'] / 1000;

            return date('H:i:s.',(int) $timeInSeconds) . sprintf('%03d', $millisecondsDiff);`

cast int

/yii2-debug/src/views/default/view.php line 68, 113 . ', ' . date('Y-m-d h:i:s a',(int) $meta['time']) echo ' at ' . date('Y-m-d h:i:s a', (int)$summary['time']) . ' by ' . $summary['ip']; cast need

yii2-debug/src/views/default/panels/config/summary.php line 6 , 8 <span class="yii-debug-toolbar__label"><?= $panel->data['application']['yii'] ?? '' ?></span>

<span class="yii-debug-toolbar__label"><?= $panel->data['php']['version'] ?? '' ?></span>

add default value (because is possible to have undefined key)

What's expected?

What do you get instead?

Additional info

Q A
Yii version latest
PHP version 8.1
Operating system
bizley commented 2 years ago

Could you address those issues with separate PRs if possible?