You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In PHP there are a number of functions which can set variables in the current scope. Sometimes by reference to a passed parameter (first examples), sometimes just plainly in the current scope (second examples).
While the first set of examples is handled correctly by the sniff, the second set of examples is not.
Now, I'm not saying it will be easy to handle this or that I have a ready-made solution for this, but I figured opening an issue as a reminder to have a look at this at some point would be a good idea nevertheless.
I totally agree with number 2, and I'm not sure how to solve it easily. As for number 1, I'm not totally convinced it's incorrect. We have code in place already to detect pass-by-reference functions, so this code would pass:
$output = [];
parse_str($str, $output);
Without that first line, we're relying on PHP's "helpful" shortcut to use and define a variable at the same time. This ties in to the discussion here.
Sorry for the confusion. This issue is about the second part. AFAIC (based on a simple test run), the examples from the first part are handled correctly already (which was already noted in the original issue description).
I only added the code for the first example because the functions involved overlap.
In PHP there are a number of functions which can set variables in the current scope. Sometimes by reference to a passed parameter (first examples), sometimes just plainly in the current scope (second examples).
While the first set of examples is handled correctly by the sniff, the second set of examples is not.
Now, I'm not saying it will be easy to handle this or that I have a ready-made solution for this, but I figured opening an issue as a reminder to have a look at this at some point would be a good idea nevertheless.
1. Functions setting a variable by reference.
The sniff correctly doesn't throw an error for
$matches
or$output
being used.2. Functions setting variables in the current scope.
The sniff as-is will throw errors for use of "undefined"
$first
,$second
,$arr
,$a
,$b
variables, while these are in actual fact all defined.The text was updated successfully, but these errors were encountered: