Plugin-php: [PSR-12] Method visibility

Created on 17 Sep 2019  Â·  6Comments  Â·  Source: prettier/plugin-php

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

  1. Visibility MUST be declared on all methods.
    – Section 4.4

    Solving this reliably would need an --engine flag if we attempt to support PHP 4 (and, therefore, the var keyword).

Playground Link (contains all listed violations)

discussion psr compat

Most helpful comment

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.

All 6 comments

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?

Same comments as here and here (seems out of scope).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Epskampie picture Epskampie  Â·  4Comments

czosel picture czosel  Â·  5Comments

czosel picture czosel  Â·  4Comments

czosel picture czosel  Â·  5Comments

Selion05 picture Selion05  Â·  4Comments