joomla / coding-standards

Joomla Coding Standards Definition
https://developer.joomla.org/coding-standards/basic-guidelines.html
GNU General Public License v2.0
128 stars 129 forks source link

Add test case for issue found in the CMS with closures #250

Closed wilsonge closed 5 years ago

wilsonge commented 5 years ago

Case https://github.com/joomla/coding-standards/pull/242 missed a case - where we have a closure combined with a chained function call. This is the unit test to reproduce. Unfortunately currently struggling for the fix - hence the open PR

As always tagging @photodude just in case he has any great ideas :D

photodude commented 5 years ago

@wilsonge I would suggest looking at what gsherwood said in my PR for moving this sniff to the Core.

"There is no need for an indent property in this sniff if you are just trying to align the opening brace under the IF statement. PHPCS provides 'column' indexes in the tokens array so you know where to align things."

So maybe partially rewriting the sniff to use the column index and not the indent property would help in resolving the issue. (or maybe not)

wilsonge commented 5 years ago

Removing that makes sense. Merging this now as we've migrated the CMS onto codesniffer and this doesn't cause any issues there. I'll try and work on removing all the space checking from this sniff however too.