$a = & $a or $a &= $a list() will no longer assign variables in reverse order Otherwise, search for reference assignation to an array. Just like the previous, spot PHP Notice: Undefined index: in the logs, since this report that a variable is created without value, especially with &=. Spot all array elements that are created with references (both &= and = &). One solution is to rely on PHP error log : crank it up to strict standards and search for ‘Strict Standards:’.Īlternatively, search for parenthesis in arguments calls and check if they are useless : Īrray elements or object properties that are automatically created by reference That won’t be the case in PHP 7, and it is wrong in PHP 5 anyway. Parenthesis may be used to hide some errors, just like the operator. Targeting $$ and $, $$p, $$q, $$o->b Parentheses around variables or function calls But mixed syntax and variable parts, such as variable variable or variable properties are in need for some curly braces. Multiple dimensions arrays are OK, so is properties/methods chaining. Some complex variables access have a new interpretation. Note : I won’t detail what is changed but focus on what can be done to pinpoint interesting issues in the code and actually find them. This is not trivial to check with a text search. For example, foreach() has different changes depending on by-value and by-reference type, and impact within the loop block or right after it. On the other hand, there is also room for a lot of false positives. For example, usort() has a new sorting behavior for equals values, so targeting usort() and uksort() is a good idea. The list is not long, and a quick text search will lead us to many places in the code. After having checked that the old PHP 5.x is lintable with PHP 7, the next challenge is to read the ‘ backward incompatible changes‘ and see if it applies to the legacy code. PHP 7 is probably the ‘ the easiest upgrade yet‘.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |