Skip to content

Latest commit

 

History

History
25 lines (18 loc) · 1.87 KB

code-standard-sniffers.md

File metadata and controls

25 lines (18 loc) · 1.87 KB
group subgroup title landing-page menu_title menu_order functional_areas
coding-standards
01_Coding standards
Code sniffers
Coding standards
PHP code sniffers
3
Standards

PHP code sniffers

We recommend the consistent use of a code sniffer to enhance the readability of your code and help ensure that it meets Magento code standards. A code sniffer is a tool that automates the process of identifying code irregularities. Although a sniffer will identify many more inconsistencies and errors than a manual edit, we recommend that you evaluate and make any fixes that your sniffer program identifies.

Magento recommends the use of PHP_CodeSniffer{:target="_blank"}, the most popular code sniffer in use throughout the {% glossarytooltip bf703ab1-ca4b-48f9-b2b7-16a81fd46e02 %}PHP{% endglossarytooltip %} development community. PHP_CodeSniffer 1.4.0+ includes PSR-1{:target="_blank"} and PSR-2{:target="_blank"} standards, which are followed by Magento 2. You can configure PHP_CodeSniffer to use your own rules, too. The Magento Extension Quality Program Coding Standard{:target="_blank"} provides specifications that you can use to configure your code sniffer of choice to bring your PHP coding style closer to Magento PHP standards.

Code standards

Magento supports the PSR-1{:target="_blank"} and PSR-2{:target="_blank"} standards.

The [Coding standards overview]({{ site.baseurl }}/guides/v2.0/coding-standards/bk-coding-standards.html){:target="_blank"} introduces Magento-specific practices for PHP, JavaScript, and {% glossarytooltip 5bfa8a8e-6f3e-4fed-a43e-62339916f02e %}JQuery{% endglossarytooltip %}.