-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PSR-2 Compliant Sniffer #111
Conversation
$phpcsFile->addError($error, $stackPtr, 'PrivateNoUnderscore', $data); | ||
return; | ||
} | ||
if ($private === true) { | ||
$filename = $phpcsFile->getFilename(); | ||
if (strpos($filename, '/lib/Cake/') !== false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is for cake3, this will never be true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. 🙏
The latest Remaining errors outside of what
Outside of a missing Would be nice to get this merged before worrying about a multi-line fixer for core, so that we can tag |
@bcrowe It would be nice if you could also make required changes for the 2.0 branch to update the squizlabs/php_codesniffer dependency to 2.0. |
The |
@ADmad The sniffer is now working with the phpcs 2.0 branch. Random Good News: I've completely removed the I've also completely removed the Edit: nose goes |
So does PSR2 rulesset include sniffs which covers those sniffs removed or were new sniffs included to our set from Squiz or PEAR standarsds? If am I am pretty sure there is a net loss. |
Earlier today, I took the Squiz and PEAR |
Just because PSR2 does not have rules for docblocks doesn't mean we can't have extra terseness to ensure proper doc blocks which are the basis of having proper API docs generated. Any user who doesn't like these extra checks can just PSR2 ruleset instead of CakPHP's.
I did. I copied the sniff from squizlabs and then modification / deletions were done because we didn't need some of the checks like ensuring the tag were descriptions aligned etc. |
Absolutely! I just didn't see any API doc generation losses at first glance. Let me look again, unless you've seen some losses already?
So this looks okay? |
Currently all docblocks are already good so how would you :) Removing the
Not for me until alternative for the removed comment sniff is added :) |
Latest output: https://gist.github.com/bcrowe/03d25d5f0d8db4ddac92
|
That is looking like a manageable list. We clearly won't be done for the first RC, but by the second we stand a chance. |
I think we can just nuke the Edit: Ya, this wasn't sniffed for nor enforced in 2.x regardless our our CS example... heh. |
Latest output: https://gist.github.com/bcrowe/0731b74f02763ab9f812 I've removed all the "description/comment" requirements from This brings us to a small amount of work to update some missing It'll be best to start furnishing the By the way, PSR-2 doesn't have docblock rules. So, this brings us to a PSR-2/CakePHP compliant sniffer, outside of the for-mentioned exlcusions for underscores and camel casing. |
Allow or ensure? The sniffer should throw a warning if
I wish we could keep this but it would be a lot of work to update the docblocks 😄
I would keep them. They are a bit painful only when throws statement is of type Also all docblock related sniffs should throw warnings, not errors (I made that change to exiting FunctionCommmentSniff). That way users can easily ignore them in their app using |
@bcrowe All said it's ok if we can't get all docblock related sniffs to our liking at the get go. They can be added incrementally. Please just create issues for ones you remove/skip so that they are not forgotten. |
It now ensures. (cd1fbd7)
All of the nice-to-have and future incremental fixes have been reinstated and dropped down to warnings. PHPCS Output (src/ and tests/):
I believe this brings us to PSR-2 compliance, outside of "should..." suggestions, and some eventual/future/nice-to-have home-brewed docblock rules. |
👏 The list of error with warnings suppressed seems quite manageable. |
@markstory Looks like it's been 29 days since beta3, want to me to squeeze in the applicable "with warnings suppressed" changes on core before our RC1? Will obviously only take a few minutes or so tomorrow. Looks like all outstanding PRs to 3.0 are by people capable of rebasing. |
@bcrowe Sounds good to me. I don't know if we'll do the RC1 right on schedule as the RulesChecker and Form work is not complete yet. |
Anything else that needs to be taken care of before we can tag current master 1.0 and merge this? |
Nope. I can take care of the tagging. |
Great (and interesting) job 👍 |
I've created a 1.x branch and a 1.0.0 tag for the existing codesniffer rules. The new PSR2 compliant sniffer (2.x) will now be on master. |
@bcrowe Great job 👏 |
This PR aims to implement PSR-2 in its entirety, as well as preserving existing CakePHP rules that do not conflict with PSR-2.
After running
php-cs-fixer
on core, and then runningphpcs
with this updated sniffer -- it's largely docblock indentation fails... which PHP-CS-Fixer doesn't seem to fix. 😢To Do's:
I'm opening this as a "WIP" in case I've overlooked/removed any CakePHP rules, as well for looking for any docblock indentation insight anyone may have.
This PR's eventual merge will be released as
2.0
so that continuous integration between Cake 2 and 3 can live side by side.