Download the PHP package wieni/wmcodestyle without Composer
On this page you can find all versions of the php package wieni/wmcodestyle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wieni/wmcodestyle
More information about wieni/wmcodestyle
Files in wieni/wmcodestyle
Package wmcodestyle
Short Description A set of Wieni best practices, coding standards and tools to enforce them.
License MIT
Informations about the package wmcodestyle
wmcodestyle
A set of Wieni best practices, coding standards and tools to enforce them.
Why?
- A central location to keep track of our written coding standards and best practices
- Make configuration for tools to enforce our codestyle available in all of our repositories, without having to duplicate and sync them manually
Table of Contents
- Coding standards
- Tooling
- Installation
- Sync config files with your project
- PHP-CS-Fixer
- Rector
- PHPStan
- composer-normalize
- Running code style fixers
- Changelog
- Security
- License
- Acknowledgments
Coding standards
- General
- Drupal modules
- Model–view–controller (and presenter)
- Git
Tooling
Installation
This package requires PHP 7.1 or higher and can be installed using Composer:
Sync config files with your project
This package provides a command to sync any file from this repository to
your project. It is recommended to add it to the scripts
section of
composer.json so it is automatically executed at the appropriate time.
PHP-CS-Fixer
This package provides a configuration factory and multiple rule sets for
friendsofphp/php-cs-fixer
.
Configuration
Pick one of the rule sets:
Wieni\wmcodestyle\PhpCsFixer\Config\RuleSet\Php71
Wieni\wmcodestyle\PhpCsFixer\Config\RuleSet\Php73
Wieni\wmcodestyle\PhpCsFixer\Config\RuleSet\Php74
Wieni\wmcodestyle\PhpCsFixer\Config\RuleSet\Php80
Create a configuration file .php_cs.php
in the root of your project:
By default, risky rules are not used. To use them, pass --allow-risky=yes
to php-cs-fixer
or set the
WMCODESTYLE_RISKY=1
environment variable.
Git
All configuration examples use the caching feature, and if you want to
use it as well, you should add the cache folder to .gitignore
:
Configuration with override rules
:bulb: Optionally override rules from a rule set by passing in an array of rules to be merged in:
Rector
Instant upgrade and refactoring of your PHP code
This package provides multiple rule sets for rector/rector. These rule sets are largely identical to the default rule sets, with the exception of a couple individual rules we don't like/need. Instead of rector/rector, rector/rector-prefixed is added as dependency to make it easier to include this package in your Composer project.
Rule sets
Pick one of the rule sets:
Wieni\wmcodestyle\Rector\SetList\WieniSetList\CODE_QUALITY
Wieni\wmcodestyle\Rector\SetList\WieniSetList\CODING_STYLE
Wieni\wmcodestyle\Rector\SetList\WieniSetList\DEPENDENCY_INJECTION
Wieni\wmcodestyle\Rector\SetList\WieniSetList\EARLY_RETURN
Wieni\wmcodestyle\Rector\SetList\WieniSetList\TYPE_DECLARATION
Example configuration
Add Symfony container XML
To work with some Symfony rules, you now need to link your container XML file:
Dumping the container is not possible out-of-the-box when using Drupal, but our Container Dumper module makes this possible.
PHPStan
PHPStan focuses on finding errors in your code without actually running it. It catches whole classes of bugs even before you write tests for the code. It moves PHP closer to compiled languages in the sense that the correctness of each line of the code can be checked before you run the actual line.
Drupal
For better integration with Drupal, consider adding mglaman/phpstan-drupal
and phpstan/phpstan-symfony
to your project. These extensions are
required when using the drupal-module
or drupal-site
configs.
You can use the Container Dumper module to dump the Symfony container to an XML file. The Symfony extension can then use this file to get better insights into your project. Add the following to your PHPStan config:
Symfony
For better integration with Symfony, consider adding
phpstan/phpstan-symfony
and
phpstan/phpstan-doctrine
to your project.
composer-normalize
Provides a composer plugin for normalizing composer.json.
We highly recommend this Composer plugin to make sure your composer.json is formatted consistently.
Running code style fixers
Makefile
If you like Makefile
s, create a Makefile
with a
coding-standards
target:
Run
to automatically fix coding standard violations.
Composer script
If you like composer
scripts, add a coding-standards
script to composer.json
:
Run
Changelog
All notable changes to this project will be documented in the CHANGELOG file.
Security
If you discover any security-related issues, please email [email protected] instead of using the issue tracker.
License
Distributed under the MIT License. See the LICENSE file for more information.
Acknowledgments
All versions of wmcodestyle with dependencies
friendsofphp/php-cs-fixer Version ^3.0
phpstan/phpstan Version ^1.0
phpstan/phpstan-deprecation-rules Version ^1.0
phpstan/phpstan-strict-rules Version ^1.0
rector/rector Version ^0.13
symfony/console Version ^2.8 || ^3 || ^4 || ^5 || ^6
symfony/filesystem Version ^3 || ^4 || ^5 || ^6