magento-coding-standard
magento-coding-standard copied to clipboard
Magento Coding Standard
### Rule All new PHP files MUST have strict type mode enabled by starting with `declare(strict_types=1)`;. All updated PHP files SHOULD have strict type mode enabled. PHP interfaces SHOULD NOT...
### Steps to reproduce 1. Install phpcs 2. Configure Magento2 coding standard 3. run any module which contains graphql ### Expected result 1.It should run the command and shows the...
### Rule Using `static::` for private constants and methods discouraged. ### Reason In case if someone will extend the class OR create plugin for it - he will get the...
use section does not actually need \ at the beginning of the classpath (leading backslash). Let’s enforce it by static tests to prevent appearing such cases in future _Originally posted...
### Rule Based on https://github.com/magento/magento2/issues/27962: \Magento\Framework cannot have plugins ### Reason ### Implementation
Now that PSR12 has been ~~released~~ accepted, when will we see an update to include it as part of the ruleset? https://github.com/squizlabs/PHP_CodeSniffer/blob/master/src/Standards/PSR12/ruleset.xml ToDo list: - [ ] Open PR to...
### Rule Same rules as https://github.com/magento/magento2/blob/2.3.4/dev/tests/static/testsuite/Magento/Test/Php/_files/phpmd/ruleset.xml ### Reason Running phpmd without requiring a full installation of Magento makes it easier to run the mess detection in isolation ### Implementation Provide...
### Rule **Inheritance from namespace other than `\PHPUnit\...` and the same that module is in is forbidden** ### Reason TLDR: Avoid unnecessary coupling between modules. While working with **Unit Tests**...
### Rule PHPDoc formatting for functions and methods. **Acceptance Criteria:** - Sniff covers described on [DevDocs requirements](https://devdocs.magento.com/guides/v2.3/coding-standards/docblock-standard-general.html): > **Functions and methods should have:** >A short description in case it adds...
### Rule Integration Test class should contain ```php /** * @magentoAppArea adminhtml */ ``` ### Reason This is required annotation to specify the area code for Controllers. Integration Tests fail...