magento / magento/magento-coding-standard
Add description why php functions marked as discouraged and give alternatives
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 375
- Forks
- 165
- PR merge metrics
- No merged PRs in 30d
Description
Preconditions
N/A
Steps to reproduce
- Make PR to Magento with changed file, that don't have like about ignoring discouraged pathinfo function or run magneto coding standard against some file.
Expected result
- You should get understandable message what's wrong with your code, message
The use of function pathinfo() is discouragedisn't clean enough - For case when some function marked as discouraged - there should be some information that shows reason of it, what is best practice
- That's actually relevant for all rules
Good example: https://github.com/extdn/extdn-phpcs/blob/master/Extdn/Sniffs/Classes/StrictTypesSniff.md
Actual result
- I'm getting result like this:
Errors is quite clear, but not warnings
PHP Code Sniffer detected 2 violation(s):
FILE: /var/www/html/app/code/Magento/Deploy/Service/DeployPackage.php
----------------------------------------------------------------------
FOUND 2 ERRORS AND 2 WARNINGS AFFECTING 4 LINES
----------------------------------------------------------------------
109 | ERROR | [x] Missing short description
110 | ERROR | [x] There must be exactly one blank line before tags
224 | WARNING | [ ] The use of function pathinfo() is discouraged
225 | WARNING | [ ] The use of function pathinfo() is discouraged
----------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
Failed asserting that 2 matches expected 0.
Related question on stack overflow, answer not seems to me correct.
https://magento.stackexchange.com/questions/192978/the-use-of-function-pathinfo-is-discouraged-magento-2
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 by inspecting the PHP CodeSniffer rules that emit discouraged-function warnings, including the pathinfo() message, and compare their guidance with the linked Extdn StrictTypesSniff documentation. Done means affected warnings explain why the function or rule is discouraged and identify a preferred alternative, with the approach applied consistently where feasible.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- tooling
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100