mediotype / code-standard
Mediotype Engineering Code Standard
This package's canonical repository appears to be gone and the package has been frozen as a result.
Installs: 19 313
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 31
Forks: 0
Open Issues: 8
Type:phpcodesniffer-standard
Requires
- magento/magento-coding-standard: @stable
- squizlabs/php_codesniffer: ^3.5
Requires (Dev)
This package is auto-updated.
Last update: 2023-05-28 17:03:08 UTC
README
A collection of code tests designed to enforce the Mediotype way.
How to Install
For local development, deploy as follows:
composer require --dev mediotype/code-standard:@stable
How to Use
To run sniffs manually, run:
php vendor/bin/phpcs \
--standard=Mediotype \
/path/to/your/code
PHPStorm Code Sniff Integration
To add Mediotype sniffs to PHPStorm code sniffer integration, first make sure you have CodeStandard repository cloned locally and that composer dependencies are installed.
Then, in PHPStorm, navigate to:
- Preferences > Languages & Frameworks > PHP > Quality Tools
Open Code Sniffer tab, click "..." icon, click file system icon near PHP Code Sniffer path field and then select path to phpcs binary from CodingStandard project. At the end it could look similar to following one:
./vendor/bin/phpcs
When it's done, you can use Validate button to check if everything is configured correctly.
Close configuration window, and in the main PHPStorm configuration window navigate to:
- Preferences > Editor > Inspections
Locate PHP Code Sniffer in the inspections list, change Coding Standard to Custom and open selector. In the new window click on file system icon and browse ruleset.xml from the CodingStandard repository. Finally, it can look as follows:
./vendor/mediotype/code-standard/ruleset.xml
Close configuration window, now custom ruleset should now be used by both background and manual inspection.
PHPStorm Code Style Scheme
In addition to code sniffs, a PHP code style scheme is provided with this standard:
./PHPStormProjectConfig.xml
To apply this configuration, download it to your local machine. Then, navigate to:
- Preferences > Editor > Code Style > PHP
In the Scheme selector, choose whether you want to apply at Project or Global scope. Then, click the "more" icon, and select Import Scheme > Intellij IDEA code style XML. Select the given scheme file and apply your changes.
Your IDE will not automatically format your code according to our standard.
Code Arrangement
The provided code style scheme can also arrange your PHP class structure to conform to our standard. To use the feature, open any PHP class you wish to arrange, then while it is the active file, select Code > Rearrange Code.
(c) 2018-2021 Blue Acorn iCi