Fixes T5648.
Details
Details
- Reviewers
epriestley - Group Reviewers
Blessed Reviewers - Maniphest Tasks
- T5648: Add a linter rule for parentheses being used with PHP language constructs
- Commits
- rARCf6e26a71335e: Add a linter rule for parentheses being used with PHP language constructs
Added some test cases.
Diff Detail
Diff Detail
- Repository
- rARC Arcanist
- Lint
Lint Skipped - Unit
Tests Skipped
Event Timeline
Comment Actions
My original intention was that the replacement could be set to $child->getChildren(), but it seems that the replacement has to be a string.
Comment Actions
My original intention was that the replacement could be set to $child->getChildren(), but it seems that the replacement has to be a string.
You should be able to $child->getConcreteString() and then trim the parens off.
Comment Actions
...and, because of how the tree works, it's actually more correct to do that. If you just turned getChildren() into a string, you would discard comments like these:
require_once ( /* quack */ 'some_path.php' /* woof */ );
As the tree only contains semantic nodes, it looks like this:
require_once ( /* quack */ 'some_path.php' /* woof */ ); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^
So getChildren() does not include /* quack */ or /* woof */.
Comment Actions
- Provide replacement text
- Strict equality
- Slightly better lint message
There is an ugly hack here that I will fix soon