I am testing my extension code against the PSR2 and Zend standards. However, the two standards conflict. I found a problem which I fixed for Zend, which then showed as an error in PSR2. If I fix it for PSR2 it will show as error for Zend. Which is the preferred standard for Magento 2?

Zend Error:: Opening brace should be on a new line

PSR2 Error:: Whitespace found at end of line

The same goes for _:

PSR2 ::Property name "$_productLoader" should not be prefixed with an underscore to indicate visibility

Zend ::underscore to indicate visibility Protected member variable "productLoader" must contain a leading underscore

1 Answer 1


Magento 2 follows PSR2 (Source), I found some pieces in the core code are still breaking the rules set by PSR2 but I suppose that's mostly older legacy code which has not been refactored yet. Custom code written today, however, should always be written following the PSR1 and PSR2 guidelines.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.