php-git-hooks icon indicating copy to clipboard operation
php-git-hooks copied to clipboard

php-cs-fixer issue

Open scramatte opened this issue 6 years ago • 4 comments

Hi,

I've got a problem with php-cs-fixer

I've made a custom .php_cs config file as following because I need to ignore files that are located into database/* and don't follow PSR2 rules. Unfortunately I'm unable to get it working. Note that I use Lumen framework (Laravel ...)

My .php_cs config file

<?php

use PhpCsFixer\Config;
use PhpCsFixer\Finder;

$finder = PhpCsFixer\Finder::create()
    ->files()
    ->in('app')
    ->name('*.php')
    ->ignoreDotFiles(true)
    ->ignoreVCS(true);

return PhpCsFixer\Config::create()
    ->setRules(array(
        '@PSR0' => false,
        '@PSR1' => false,
        '@PSR2' => true
    ))
    ->setFinder($finder);

?>

My php-git-hooks.yaml

pre-commit:
    enabled: true
    execute:
        composer: true
        jsonlint: true
        phplint: true
        phpmd:
            enabled: true
            options: null
        phpcs:
            enabled: true
            standard: phpcs.xml
            ignore: null
        php-cs-fixer:
            enabled: true
            levels:
                psr0: false
                psr1: false
                psr2: true
                symfony: false
            options: null

Output when I try commit ...

Running PHPLINT...................................0K
Checking code style with PHPCS....................0K
Checking PSR2 code style with PHP-CS-FIXER........
Fail

Loaded config default from "/opt/eom/gisdata/.php_cs".
Using cache file ".php_cs.cache".
Paths from configuration file have been overridden by paths provided as command arguments.
Loaded config default from "/opt/eom/gisdata/.php_cs".
Using cache file ".php_cs.cache".
Paths from configuration file have been overridden by paths provided as command arguments.
Loaded config default from "/opt/eom/gisdata/.php_cs".
Using cache file ".php_cs.cache".
Paths from configuration file have been overridden by paths provided as command arguments.
Loaded config default from "/opt/eom/gisdata/.php_cs".
Using cache file ".php_cs.cache".

scramatte avatar Jan 13 '19 21:01 scramatte

it's a problem with output of php-cs-fixer. you can run it manually: php ./vendor/bin/php-cs-fixer --dry-run -v . and see, what files are wrong. also you can fix it automatically, exec php-cs-fixer without --dry-run option. it will make necessary changes, than your commit will pass this checs.

alexgivi avatar Jul 30 '19 10:07 alexgivi

This is not really a problem from the output of php-cs-fixer. they just use the standard output to show what's wrong. I send a fix proposal : #131

JLepeltier avatar Aug 09 '19 14:08 JLepeltier

In strongly advise tu use the option -v for a better result

JLepeltier avatar Aug 09 '19 15:08 JLepeltier

@JLepeltier https://github.com/bruli/php-git-hooks/pull/127/files this has already been solved... @bruli are you going to maintain your library? it seems not...

alexgivi avatar Aug 20 '19 17:08 alexgivi