Official Travelopia WordPress PHP coding standards.
|
Built by the super talented team at Travelopia. |
|
Install the library via Composer:
$ composer require --dev travelopia/wordpress-coding-standards
That's it!
Lint your PHP files with the following command:
$ ./vendor/bin/phpcs .This package also includes custom PHP-CS-Fixer rules for automated code formatting.
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;# Check for issues
$ ./vendor/bin/php-cs-fixer fix --dry-run --diff
# Fix issues
$ ./vendor/bin/php-cs-fixer fix