vanilla-php / benchmark-php

:rocket: A benchmark script for PHP and MySQL (Archived)
MIT License
192 stars 90 forks source link

bindec give ( ! ) Deprecated: Invalid characters passed for attempted conversion, these have been ignored in php 7.4.x #15

Closed simongcc closed 3 years ago

simongcc commented 3 years ago

Hi! It seems that php 7.4.x is more strict in checking arguments and function bindec expects 0 and 1 only string so it give the warning.

( ! ) Deprecated: Invalid characters passed for attempted conversion, these have been ignored in benchmark.php on line 183

odan commented 3 years ago

Would you like to create a PR to fix it?

Kristian-Tan commented 3 years ago

This isn't fixed yet? I propose to either remove the bindec function altogether from benchmark OR add an if statement like this:

alternative 1: remove the bindec function altogether

- 183: $mathFunctions = array("abs", "acos", "asin", "atan", "bindec", "floor", "exp", "sin", "tan", "is_finite", "is_nan", "sqrt");
+ 183: $mathFunctions = array("abs", "acos", "asin", "atan", "floor", "exp", "sin", "tan", "is_finite", "is_nan", "sqrt");

alternative 2: add an if statement, if $function is "bindec" then call_user_func_array($function, array(decbin($i))); else call_user_func_array($function, array($i));

- 186: call_user_func_array($function, array($i));
+ 186: if($function == "bindec") call_user_func_array($function, array(decbin($i)));
+ 187: else call_user_func_array($function, array($i));

If you approve any of the 2 above, I'll make a PR

odan commented 3 years ago

This bug has been fixed. Please try it again.