plugin-php
plugin-php copied to clipboard
[PSR-12] Method visibility
Disclaimer: I am aware that it's not make-or-break for Prettier to adhere to PSR-12.
However, now that it is officially accepted as a standard, we should discuss (and, if necessary, reject) each current violation of PSR-12 — if only to have point to refer to in future discussions or issues.
PSR-12 Violations
-
Visibility MUST be declared on all methods. – Section 4.4
Solving this reliably would need an
--engineflag if we attempt to support PHP 4 (and, therefore, thevarkeyword).
That said, I'm not sure whether auto-adding visibility keywords is in scope for a formatter at all, so feel free to close this without further discussion.
Hm, without visibility it is always public?
/cc @czosel what do you think, with --engine option it is safe.
Anyway i aware that, for many it can be very annoying.
Hmm, I'm a bit torn about this one (and probably some other aspects of PSR-12 as well). On the one hand one can apply the same reasoning than for PSR-2, on the other hand this seems a bit verbose. I think it would be very helpful to get a sense of where the PHP community stands on these points. Are the popular projects advocating for PSR-12, or even implementing it already? Are there projects which deliberately decided against implementing PSR-12 or some parts of it?