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
- Branch
- langconstparen
- Lint
Lint Passed - Unit
Tests Passed - Build Status
Buildable 2025 Build 2026: [Placeholder Plan] Wait for 30 Seconds
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