Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

php-cs-fixer issue #123

Open
scramatte opened this issue Jan 13, 2019 · 4 comments
Open

php-cs-fixer issue #123

scramatte opened this issue Jan 13, 2019 · 4 comments

Comments

@scramatte
Copy link

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".

@alexgivi
Copy link

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.

@JLepeltier
Copy link
Contributor

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
Copy link
Contributor

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

@alexgivi
Copy link

@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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants