Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sniff::get_function_call_parameters(): correctly handle closures when…
… passed as param Closures can be declared within function calls when the function expects a call-back. This situation was only partially handled within the `Sniff::get_function_call_parameters()` method. Most of the time when a comma is encountered within a closure, it will be at a different nesting level than the original function call/array, which meant it would be disregarded and the method would return the correct results. However, there are some, albeit rare, situations in which the comma would be at the target nesting level, causing the method to split the closure into two or more "parameters". As far as I know, this bug has not caused any issues for any of the WPCS sniffs so far, but the situation should be handled correctly even so. I came across this while working on 1371, the PR for which will contain a unit test covering this fix. Additionally, the same fix has been pulled to the PHPCompatibility standard with dedicated unit tests. See: PHPCompatibility/682 Related to 764
- Loading branch information