magento-coding-standard icon indicating copy to clipboard operation
magento-coding-standard copied to clipboard

Do not recommend using static:: for private constants

Open ihor-sviziev opened this issue 4 years ago • 1 comments

Rule

Using static:: for private constants and methods discouraged.

Reason

In case if someone will extend the class OR create plugin for it - he will get the Undefined class constant error. In past we had few issues related to this - https://github.com/magento/magento2/pull/28797 https://github.com/magento/magento2/pull/29925.

We had it only with constants, but potentially the same issue could appear with static method calls.

Implementation

Detect all private constants in the class and all static:: calls to them and add warning if such case detected.

ihor-sviziev avatar Oct 10 '20 18:10 ihor-sviziev

Hi @ihor-sviziev. Thank you for your report. To help us process this issue please make sure that you provided sufficient information.

Please, add a comment to assign the issue: @magento I am working on this


m2-assistant[bot] avatar Oct 10 '20 18:10 m2-assistant[bot]