PrestaShop coding standards
This repository includes tools to check that repositories are following the standards defined by the PrestaShop community and provides configuration files for some of them.
composer require --dev prestashop/php-dev-tools
When this project is successfully added to your dependencies, you can enable each review tool on your projet.
|Version||Status||Packagist -||Namespace||Repo||Docs||PHP Version|
$ php vendor/bin/prestashop-coding-standards cs-fixer:init [--dest /path/to/my/project]
It'll create a configuration file
.php-cs-fixer.dist.php in the root of your project.
Upgrade note : When upgrading from 4.1.0 to newer version, you should re-run the init script or rename your
.php_cs.dist file to
.php-cs-fixer.dist.php in order to match the new requirements of cs-fixer.
$ php vendor/bin/prestashop-coding-standards phpstan:init [--dest /path/to/my/project]
It'll create a default file
tests/phpstan, that are required to run phpstan.
The default phpstan level is the lowest available, but we recommend you to update this value to get more recommandations.
PHPStan is not provided by our dependencies, because of the PHP compatibility from projects using this repository. We recommend you to install it globally on your environment:
composer global require phpstan/phpstan:^0.12
The configuration files added in your project can be freely modified in order to match your needs.
Running the tools can be done by calling its binary:
$ vendor/bin/php-cs-fixer fix
If you have installed PHPStan globally and made the folder available in your PATH:
$ _PS_ROOT_DIR_=<Path_to_PrestaShop> phpstan --configuration=tests/phpstan/phpstan.neon analyse <path1 [path2 [...]]>
Otherwise, you can specify the path to the PHPStan binary. For instance:
$ _PS_ROOT_DIR_=<Path_to_PrestaShop> php ~/.composer/vendor/bin/phpstan.phar --configuration=tests/phpstan/phpstan.neon analyse <path1 [path2 [...]]>
Applying an index.php file to all your project subfolders will be useful to avoid directories to be listed by the webserver.
Your license headers can be updated by applying the header stamp.
Here is an example of call, applying the default license on a PrestaShop module:
$ vendor/bin/header-stamp --license=assets/afl.txt --exclude=vendor,node_modules
Available options are provided with