Skip to content

simgroep/coding-standards

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simgroep/coding-standards

Coding standard configuration for SIMGroep PHP projects using friendsofphp/php-cs-fixer

Installation

$ composer require simgroep/coding-standards

Configuration

To customize the default configuration in your project you can add a .php-cs-fixer.php to your project and include the default configuration like this:

<?php


$config = require 'vendor/simgroep/coding-standards/php-cs-fixer.dist.php';

$config->setFinder(
    \PhpCsFixer\Finder::create()
        ->in([
            getcwd() . '/src',
            getcwd() . '/test',
        ])
    )
;

return $config;

LEGACY NOTE the deprecated name for the configuration file was .php_cs, and for a legacy use may still require the vendor/simgroep/coding-standards/.php_cs.dist instead

Symfony example

When applying the coding standards to a standard Symfony project you can customize the configuration for a blacklisting approach like this:

<?php

$config = require 'vendor/simgroep/coding-standards/.php_cs.dist';

$config->setFinder(
    \PhpCsFixer\Finder::create()
        ->in(getcwd())
        ->exclude('app')
        ->exclude('bin')
        ->exclude('var/cache')
        ->exclude('vendor')
    )
;

return $config;

Usage

Only check for coding standard violations:

$ ./vendor/bin/php-cs-fixer fix --dry-run --diff --config=vendor/simgroep/coding-standard/.php_cs.dist --stop-on-violation --allow-risky=yes

Fix coding standard violations:

$ ./vendor/bin/php-cs-fixer fix --diff --config=vendor/simgroep/coding-standard/.php_cs.dist --stop-on-violation --allow-risky=yes

PhpStorm integration

Start by installing this library global:

$ composer global require simgroep/coding-standards

Open PhpStorm and navigate to "Settings" -> "Tools" -> "File Watchers" add one (+). Disable "Immediate file synchronization".

Program: /Users/<username>/.composer/vendor/bin/php-cs-fixer

Arguments: fix $FileDir$/$FileName$ --config=/Users/<username>/.composer/vendor/simgroep/coding-standards/.php_cs.dist

Working dir: $ProjectFileDir$

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • PHP 100.0%