travelopia / wordpress-coding-standards
Travelopia's PHP WordPress Coding Standards
Installs: 3 428
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 3
Open Issues: 3
Type:phpcodesniffer-standard
pkg:composer/travelopia/wordpress-coding-standards
Requires
- friendsofphp/php-cs-fixer: ^3.89
- wp-coding-standards/wpcs: ^3.2
Requires (Dev)
README
Official Travelopia WordPress PHP coding standards.
|
Built by the super talented team at Travelopia. |
|
Installation
Install the library via Composer:
$ composer require --dev travelopia/wordpress-coding-standards
That's it!
Usage
PHP_CodeSniffer (PHPCS)
Lint your PHP files with the following command:
$ ./vendor/bin/phpcs .
PHP-CS-Fixer
This package also includes custom PHP-CS-Fixer rules for automated code formatting.
Quick Start
Create a .php-cs-fixer.dist.php file in your project root:
<?php use PhpCsFixer\Finder; use Travelopia\WordPressCodingStandards\TravelopiaFixersConfig; $finder = Finder::create() ->in( __DIR__ ) ->name( '*.php' ) ->exclude( 'vendor' ) ->ignoreVCS( true ); $config = TravelopiaFixersConfig::create() ->setRiskyAllowed( true ) ->setIndent( "\t" ) ->setLineEnding( "\n" ) ->setRules( TravelopiaFixersConfig::getRules() ) ->setFinder( $finder ); return $config;
Run PHP-CS-Fixer
# Check for issues $ ./vendor/bin/php-cs-fixer fix --dry-run --diff # Fix issues $ ./vendor/bin/php-cs-fixer fix