phpro / grumphp

A PHP code-quality tool
MIT License
4.14k stars 430 forks source link

cs_fixer2 *.php* wildcard not workin, parsing only .php files! #284

Closed j3rrey closed 7 years ago

j3rrey commented 7 years ago
Q A
Branch master
Bug? yes
New feature? no
Question? no
Documentation? no
Related tickets

I've got lot's of .php5 files in our old code, but want to be able to run the php_cs_fixer2 task with grumphp. The php_cs_fixer2 Task only checks files with the extension " .php" even if I use it with another wildcard. e.g. " .php*" This seems to be hardcoded in: https://github.com/phpro/grumphp/blob/master/src/Task/PhpCsFixerV2.php#L59 One should be able to configure other file endings, as it is possible in the original repository.

I tried to put it into the php_cs.dist config file but that's not doing the trick :( Think this config is being loaded after the initialisation of which files to parse

<?php

$finder = PhpCsFixer\Finder::create()
    ->exclude(['vendor','tmpl_c'])
    ->name('*.php5');

return PhpCsFixer\Config::create()
    ->setRules([
        '@Symfony' =>  true,
        'encoding' => false,
        'psr0' => false,
        'psr4' => false,
        'self_accessor' => false,
        'no_short_echo_tag' => false,
        'array_syntax' => ['syntax' => 'short'],
    ])
    ->setFinder($finder);

My configuration

# grumphp.yml

parameters:
    bin_dir: "./vendor/bin"
    git_dir: "."
    hooks_dir: ~
    hooks_preset: local
    stop_on_failure: false
    ignore_unstaged_changes: false
    process_async_limit: 10
    process_async_wait: 1000
    process_timeout: 60
    ascii:
        failed: grumphp-grumpy.txt
        succeeded: grumphp-happy.txt
    tasks:
        git_blacklist:
            keywords:
                - "die("
                - "var_dump("
                - "print_f("
                - "dump("
                - "dd("
                - "exit;"
            triggered_by: ["php","php5"]
        git_commit_message:
            matchers:
                - /((MVP|FIN|VER)-([0-9]+))|#/
            case_insensitive: true
            multiline: true
            additional_modifiers: ''
        git_conflict: ~
        phpcsfixer2:
            allow_risky: false
            cache_file: ~
            config: "config/php_cs.dist"
            using_cache: false
            path_mode: ~
            verbose: true
        phpmd:
            exclude: []
            ruleset: ["config-dev/phpmd.xml.dist"]
            triggered_by: ["php", "php5"]
        phpversion:
            project: "5.6"
    testsuites: []
    extensions: []
veewee commented 7 years ago

It could be an option to add the triggered_by option (like e.g. phpmd) to the phpcsfixer2 task. I would accept a PR for that.

j3rrey commented 7 years ago

Thanks for merging, being so active and helpful, when will you do the release ?

veewee commented 7 years ago

No problem! I'll try to release somewhere next week.