prestashop / php-coding-standards
PrestaShop coding standards
Installs: 21 794
Dependents: 0
Suggesters: 0
Security: 0
Stars: 34
Watchers: 14
Forks: 18
Open Issues: 8
Requires
- php: >=7.2.5
- symfony/console: ~3.2 || ~4.0 || ~5.0 || ~6.0 || ~7.0
- symfony/filesystem: ~3.2 || ~4.0 || ~5.0 || ~6.0 || ~7.0
Requires (Dev)
Suggests
- phpstan/phpstan: ^0.12
- prestashop/autoindex: ^2.0
- prestashop/header-stamp: ^2.0
- squizlabs/php_codesniffer: ^3.4
This package is auto-updated.
Last update: 2024-11-06 21:06:50 UTC
README
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.
Related packages:
Installation
composer require --dev prestashop/php-dev-tools
## Development dependencies runtimes
composer require --dev friendsofphp/php-cs-fixer
composer require --dev phpstan/phpstan
composer require --dev prestashop/header-stamp
composer require --dev prestashop/autoindex
composer require --dev squizlabs/php_codesniffer
When this project is successfully added to your dependencies, you can enable each review tool on your projet.
Version Guidance
Usage
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 their respective binary:
PHP CS Fixer
Initialize the configuration with:
$ 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.
$ vendor/bin/php-cs-fixer fix
PHPStan
$ php vendor/bin/prestashop-coding-standards phpstan:init [--dest /path/to/my/project]
It'll create a default file phpstan.neon
in 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.
$ _PS_ROOT_DIR_=<Path_to_PrestaShop> php vendor/bin/phpstan --configuration=tests/phpstan/phpstan.neon analyse <path1 [path2 [...]]>
Autoindex
Applying an index.php file to all your project subfolders will be useful to avoid directories to be listed by the webserver.
$ vendor/bin/autoindex prestashop:add:index <path>
Header Stamp
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 --help
.