Skip to content

Use PHP-CS-Fixer instead of PHPCS for Pimcore projects #41

@youwe-petervanderwal

Description

@youwe-petervanderwal

Reason: in PIM teams we have agreement to use PER 3.0 coding standards, which is not supported by PHPCS but is supported by PHP-CS-Fixer

Local (successful) test, so similar should be possible to implement via Testing Suite.
Would even be better if Testing Suite offers the choice between the two coding standard solutions.

composer require --dev php-cs-fixer/shim
# grumphp.yml

imports:
  - resource: 'vendor/youwe/testing-suite/config/pimcore/grumphp.yml'

grumphp:
    tasks:
        # Disable PHPCS in favor of PHP-CS-Fixer
        phpcs:
            metadata:
                enabled: false
        phpcsfixer: ~
# .php-cs-fixer.dist.php

<?php

declare(strict_types=1);

$finder = PhpCsFixer\Finder::create()
    ->in(__DIR__)
    ->exclude([
        # Symfony files
        'bin/console',
        'public/index.php',
        # Full var folder, this contains all kind of auto-generated files (from cache to class definitions)
        'var',
        # Configuration written by Pimcore (which is written to var/ or to config/pimcore depending on settings)
        'config/pimcore',
    ]);

return (new PhpCsFixer\Config())
    ->setRules([
        '@PER-CS2.0' => true, // Edit: later on PHP CS Fixer also released '@PER-CS3.0'
    ])
    ->setFinder($finder);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions