Skip to content
Dava Gordon edited this page Feb 4, 2020 · 4 revisions

Terminology

PHP CodeSniffer is a static code analysis tool to detect violations of a defined Coding Standard.

A Coding Standard in PHP CodeSniffer - a collection of sniff files combined in the ruleset.xml file.

Each sniff can have its own severity (priority) and type (error or warning).

Consolidation

There are few Magento related Coding Standards:

Each of these Coding Standards contain a lot of sniffs in common. However, there are also some differences in the code checking approach. For example:

  • The MEQP coding standard uses a severity approach (from 10 to 1). The test fails only in the case of a severity 10 finding (error). Issues with severity from 1 to 9 marked as a warning and do not cause test failure.
  • In the Magento Core checking strategy, all findings lead to test failure. Note: By default, PHP CodeSniffer assigns a severity of 5 to all errors and warnings.
  • MEQP Coding Standard contains some false-positive sniffs, for which the aim is just to warn developers and draw their attention to the particular code piece.

As a result it leads to inconsistency and code duplication. Extension developers are confused about what code standard to use in their extension development and Magento related projects contribution.

Goals

  1. Make it easier to run static checks for extensions developers.
  2. Store all related to Magento sniffs in one place.
  3. Make static check consistent.
  4. Make rules compatible with IDE.

Join #coding-standard channel for more details.