Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PEAR/FunctionDeclaration: prevent fixer conflict for unfinished closu…
…res/live coding The `PEAR.Functions.FunctionDeclaration` sniff contained code to protect against a fixer conflict for unfinished closures, however, this code did not work correctly as an unfinished closure will generally also not have a function body, which "undoes" the protection via the scope opener check. In other words, the fixer conflict still existed and would result in one part of the sniff trying to _add_ a space between the `function` keyword and the open parenthesis, while another part of the sniff would be removing that space again. ``` => Fixing file: 1/1 violations remaining PEAR.Functions.FunctionDeclaration:124 replaced token 11 (T_WHITESPACE on line 7) " (" => "(" => Fixing file: 1/1 violations remaining [made 1 pass]... * fixed 1 violations, starting loop 2 * PEAR.Functions.FunctionDeclaration:94 replaced token 10 (T_FUNCTION on line 7) "function" => "function " => Fixing file: 1/1 violations remaining [made 2 passes]... * fixed 1 violations, starting loop 3 * PEAR.Functions.FunctionDeclaration:124 replaced token 11 (T_WHITESPACE on line 7) " (" => "(" => Fixing file: 1/1 violations remaining [made 3 passes]... * fixed 1 violations, starting loop 4 * PEAR.Functions.FunctionDeclaration:94 replaced token 10 (T_FUNCTION on line 7) "function" => "function " => Fixing file: 1/1 violations remaining [made 4 passes]... * fixed 1 violations, starting loop 5 * ``` Fixed now by verifying if the function is named instead. That way we can be sure it's not a closure. Includes test. Builds on the previously pulled fix from PR 816. Related to #152
- Loading branch information