Skip to content

Add description why php functions marked as discouraged and give alternatives #102

Open
@ihor-sviziev

Description

@ihor-sviziev

Preconditions

N/A

Steps to reproduce

  1. 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

  1. You should get understandable message what's wrong with your code, message The use of function pathinfo() is discouraged isn't clean enough
  2. For case when some function marked as discouraged - there should be some information that shows reason of it, what is best practice
  3. That's actually relevant for all rules

Good example: https://github.com/extdn/extdn-phpcs/blob/master/Extdn/Sniffs/Classes/StrictTypesSniff.md

Actual result

  1. 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions