magento / magento/magento-coding-standard

PHPStorm unable to run phpcs inspection

Open
#390 12 comments 2 reactions 2 assignees Claimed by @fredden View on GitHub
bug Progress: PR created
Dominant language
PHP
Stars
375
Forks
165
PR merge metrics
No merged PRs in 30d

Description

### Preconditions
1. Tested on Magento Open Source 2.4.4 and Adobe Commerce 2.4.4
2. PHP 8.1 (I haven't tried 7.4)
3. PHPStorm version is 2021.2.4

### Steps to reproduce
1. Configure PHP interpreter in PHPStorm
2. Configure phpcs in PHPStorm to use the Magento coding standard
3. Enable the phpcs inspections

### Expected result
1. PHPStorm displays phpcs rule violations according to the configuration

### Actual result
In the PHStorm event log the message is shown
```
ERROR: Referenced sniff "PHPCompatibility.FunctionUse.RemovedFunctions" does not exist
```

### Additional Information

Running phpcs on the command line works
```
vendor/bin/phpcs --standard=vendor/magento/magento-coding-standard/Magento2 path/to/check
```

---

The same PHPStorm configuration works on Magento 2.4.3 with PHP 7.4.

---

If I remove the reference to that sniff from the `Magento2/ruleset.xml`, phpcs fails with a stacktrace where any other Magento2 rule extending from a `PHPCompatibility` rule class can't find the parent class.
Maybe this points to an autoload error?
However, I quick test by adding `"PHPCompatibility\\:": "vendor/phpcompatibility/php-compatibility/PHPCompatibility/"` to the root composer.json and dumping the composer autoloader did not change anything.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.