Page MenuHomePhabricator

Add a linter rule for parentheses being used with PHP language constructs
ClosedPublic

Authored by joshuaspence on Aug 2 2014, 9:54 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Nov 24, 1:01 PM
Unknown Object (File)
Thu, Nov 7, 11:37 PM
Unknown Object (File)
Oct 24 2024, 10:54 AM
Unknown Object (File)
Oct 18 2024, 10:44 AM
Unknown Object (File)
Oct 18 2024, 1:25 AM
Unknown Object (File)
Oct 11 2024, 10:37 PM
Unknown Object (File)
Oct 8 2024, 6:08 PM
Unknown Object (File)
Oct 1 2024, 10:16 AM
Subscribers

Diff Detail

Repository
rARC Arcanist
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

joshuaspence retitled this revision from to Add a linter rule for parentheses being used with PHP language constructs.
joshuaspence updated this object.
joshuaspence edited the test plan for this revision. (Show Details)
joshuaspence added a reviewer: epriestley.
joshuaspence edited edge metadata.
  • Minor string change
  • Fix failing unit test

My original intention was that the replacement could be set to $child->getChildren(), but it seems that the replacement has to be a string.

Oh, and this doesn't work with print.

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.

...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 */.

joshuaspence edited edge metadata.
  • Provide replacement text
  • Strict equality
  • Slightly better lint message

There is an ugly hack here that I will fix soon

epriestley edited edge metadata.
This revision is now accepted and ready to land.Aug 5 2014, 12:42 AM