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)
Thu, Dec 26, 6:20 AM
Unknown Object (File)
Thu, Dec 19, 8:56 AM
Unknown Object (File)
Tue, Dec 17, 9:22 AM
Unknown Object (File)
Tue, Dec 17, 2:25 AM
Unknown Object (File)
Thu, Dec 12, 12:08 PM
Unknown Object (File)
Fri, Dec 6, 6:52 PM
Unknown Object (File)
Thu, Dec 5, 10:45 AM
Unknown Object (File)
Sun, Dec 1, 4:39 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