magento / magento/magento-coding-standard
Do not recommend using static:: for private constants
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 375
- Forks
- 165
- PR merge metrics
- No merged PRs in 30d
Description
### 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No implementation files or tests are named. Start by reviewing the repository's existing coding-standard rules for how private constants and static calls are detected, then trace their related tests. Done means the standard warns when static:: accesses a private constant or calls a private static method, with coverage for both cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100