1.2.1640. func_get_arg() Modified¶
func_get_arg() and func_get_args() used to report the calling value of the argument until PHP 7.
Since PHP 7, it is reporting the value of the argument at calling time, which may have been modified by a previous instruction.
This code will display 1 in PHP 7, and 0 in PHP 5.
<?php
function x($a) {
print func_get_arg(0); // 0
$a++;
print func_get_arg(0); // 1
}
x(0);
?>
1.2.1640.1. Connex PHP features¶
1.2.1640.1.1. Suggestions¶
Use func_get_arg() early in the function.
Avoir mixing func_get_args() and direct access to the parameters.
Avoir using func_get_args() and specifying parameters.
Avoir modifying parameters.
1.2.1640.1.2. Specs¶
Short name |
Functions/funcGetArgModified |
Rulesets |
|
Exakat since |
0.8.4 |
PHP Version |
All |
Severity |
Major |
Time To Fix |
Quick (30 mins) |
Changed Behavior |
PHP 7.0 |
Precision |
High |
Available in |