I’ve been trying to find if there is a CakePHP naming convention for private and protected class members.
This isn’t part of the official coding style as it likely doesn’t really affect the end-user. However, since we are trying to following CakePHP conventions to keep issues minimal, I was curious if there was an internal/informal standard for this.
I seen in some cases that an _ is used for both protected fields/variables and methods. However, this isn’t consistent. I see a mix of _ and regular names in classes. Is there a standard that new code follows even if some old code is mixed?
In a nutshell, CakePHP uses PSR-2 with a few additions/changes. One of the legacy issues of this, is that many protected/private members use a underscore prefix, but newer code does not (Since it would not be good for BC to remove the existing ones). Using underscores is still PSR-2 compliant since PSR-2 only recommends not using them.