1.2.1456. Wrong Type For Native PHP Function¶
This rule reports calls to a PHP native function with values of the wrong type. With modern PHP versions and strict_typing, it generates a Fatal error.
<?php
// valid calls
echo exp(1);
echo exp(2.5);
// invalid calls
echo exp("1"); // OK without strict types
echo exp(array(2.5)); // always a fatal error
// valid call, but invalid math
// -1 is not a valid value for log(), but -1 is a valid type (int) : it is not reported by this analysis.
echo log(-1);
?>