magento / magento/magento-coding-standard
Magento2\Sniffs\Legacy\RestrictedCodeSniff doesn't catch namespaced classes
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 375
- Forks
- 165
- PR merge metrics
- No merged PRs in 30d
Description
Preconditions
- Magento 2.4.5-p1
- Magento Coding Standard v29
Steps to reproduce
- Create a php file, where you include any namespaced class from restricted_classes.php for example \Magento\Framework\Serialize\Serializer\Serialize in the constructor or any other place
- Run code sniffer on that file.
Expected result
- Sniffer caught the class
Actual result
- Sniffer didn't catch the class
Notes
Registered tokens contain only partial values for classes, they transmit parts of this class in turn, Magento, then Framework, then Serialize, and so on, but the whole class is not transmitted. Therefore, the sniffer only works for classes that consist of a single word or are combined with an underscore _.
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
Start with Magento2/Sniffs/Legacy/RestrictedCodeSniff.php and inspect the registered tokens referenced in the issue, then compare them with the fully qualified names in Magento2/Sniffs/Legacy/_files/restricted_classes.php. Run CodeSniffer against a PHP file using a namespaced restricted class such as Magento\Framework\Serialize\Serializer\Serialize; done means the sniffer reports that class.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100