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

underscore difference between CakePHP Coding Standards and PRS-2 #9940

Closed
littleylv opened this Issue Dec 30, 2016 · 5 comments

Comments

Projects
None yet
4 participants
@littleylv
Contributor

littleylv commented Dec 30, 2016

In Coding Standards you say:

Additionally, non-public method or variable names start with a single underscore (_).

In PSR-2: Coding Style Guide and PSR-2: Coding Style Guide:

Property names SHOULD NOT be prefixed with a single underscore to indicate protected or private visibility.

Method names SHOULD NOT be prefixed with a single underscore to indicate protected or private visibility.

Also, some other composer vendors like symfony and zendframework haven't use a single underscore too:
grep 'protected function _' vendor/symfony/* vendor/zendframework/* -rl
grep 'protected function _' vendor/cakephp/* -rl

Are there any reasons CakePHP starts with a single underscore? :)

@antograssiot

This comment has been minimized.

Member

antograssiot commented Dec 30, 2016

SHOULD NOT is distinct from MUST NOT so it is not really a conflict.
You can read one of the original issue if you're interested here

@littleylv littleylv changed the title from CakePHP Coding Standards conflicts with PRS-2 to underscore difference between CakePHP Coding Standards and PRS-2 Dec 30, 2016

@littleylv

This comment has been minimized.

Contributor

littleylv commented Dec 30, 2016

@antograssiot Thanks for that. I'll read it.

@littleylv littleylv closed this Dec 30, 2016

@markstory

This comment has been minimized.

Member

markstory commented Dec 30, 2016

We should probably stop recommending the underscore prefixes. In some of the newer parts of the framework we've stopped using _ prefixes.

@markstory markstory reopened this Dec 30, 2016

@antograssiot

This comment has been minimized.

Member

antograssiot commented Dec 30, 2016

That's why I didn't close the issue in the first place. I too think that this note should be removed.

@ADmad

This comment has been minimized.

Member

ADmad commented Jan 1, 2017

Our phpcs ruleset no longer dictates use of underscore prefix. I have opened a PR to update the docs.

@ADmad ADmad closed this Jan 1, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment