Download the PHP package wptechnix/coding-standards without Composer
On this page you can find all versions of the php package wptechnix/coding-standards. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wptechnix/coding-standards
More information about wptechnix/coding-standards
Files in wptechnix/coding-standards
Package coding-standards
Short Description A modern PHP coding standard (PHPCS) compatible with PSR-12, featuring additional rules for strictness and type safety.
License MIT
Informations about the package coding-standards
WPTechnix Coding Standards
PHP 8.0+ coding standards enforcing strict types, immutability, and PSR-12 compliance.
About
This is a coding standard for PHP_CodeSniffer. It builds upon rules from Slevomat Coding Standard and PHPCSExtra, with a focus on:
Type Safety:
declare(strict_types=1)required in all files- Parameter, return, property, and class constant type hints required
- Union, intersection, and DNF types supported
- Disallows mixed type hint and array type hint syntax (use generics in PHPDoc)
- Strict comparison operators (
===,!==) enforced
Modern PHP 8.0+ Features:
- Constructor property promotion required
- Arrow functions required for single-expression closures
- Null-safe operator and null coalesce operators required where applicable
- Non-capturing catch blocks (PHP 8.0+)
- Numeric literal separators for readability
- Trailing commas in multiline structures
Immutability & Code Quality:
- Readonly properties enforced, public mutable properties forbidden
- Disallows
empty()function - Early returns required
- Alphabetically sorted use statements and array keys
- Proper class member ordering and spacing
- PHPDoc requirements with proper formatting
Installation
Install this package as a development dependency using Composer.
Automatic Registration (Optional)
For automatic registration of the standard with PHP_CodeSniffer, optionally install the Dealerdirect Composer Installer:
Without Dealerdirect, you can still use the standard by manually referencing it in your phpcs.xml file.
Usage
To use this coding standard, add <rule ref="WPTechnix"/> to your phpcs.xml
configuration.
Here are the contents of an example phpcs.xml.dist file that you may place in
the root of your repository:
Then, run PHP_CodeSniffer:
To automatically fix violations:
Project-Specific Coding Standards
This base standard can be extended for project-specific coding requirements. The following projects xtend WPTechnix coding standards:
- WPTechnix WordPress Coding Standards - Extends this standard with WordPress-specific rules and conventions
Contributing
Contributions are welcome! To contribute, please familiarize yourself with CONTRIBUTING.md.
Copyright and License
The wptechnix/coding-standards library is copyright © WPTechnix and licensed for use under the terms of the MIT License (MIT). Please see LICENSE for more information.
All versions of coding-standards with dependencies
squizlabs/php_codesniffer Version ^3.13.0 || ^4.0
phpcsstandards/phpcsextra Version ^1.4
slevomat/coding-standard Version ^8.22