drupol / phpcsfixer-configs-drupal

Base PHP CS Fixer configurations for Drupal 7 and 8.
MIT License
7 stars 5 forks source link

Extensions other than .php are not detected automatically #5

Closed FlorentTorregrosa closed 1 year ago

FlorentTorregrosa commented 4 years ago

Hello,

First thanks for this package which ease the integration of PHP CS Fixer on Drupal.

I have added it in my Drupal project skeleton. https://gitlab.com/florenttorregrosa-drupal/docker-drupal-project/-/commit/33998dc883c8a65fdcc55891dc9d18ae4a8501c4

But I noticed that files with Drupal extension (.module, .install, etc.) are not detected automatically.

Steps required to reproduce the problem

  1. Make a Coding standard error in a .module file
  2. Execute PHP-CS-Fixer

Expected Result

Actual Result

dpi commented 2 years ago

You will need to include patterns in your Finder, as in:

$finder = \PhpCsFixer\Finder::create()
  ->name('*.inc')
  ->name('*.module')
  ->name('*.profile')
  ->name('*.theme')
FlorentTorregrosa commented 2 years ago

Hi, thanks for the reply.

But when I var_dump() the finder of the current config, the extensions are already included:

object(PhpCsFixer\Finder)#685 (19) {
  ["mode":"Symfony\Component\Finder\Finder":private]=>
  int(1)
  ["names":"Symfony\Component\Finder\Finder":private]=>
  array(10) {
    [0]=>
    string(5) "*.php"
    [1]=>
    string(5) "*.php"
    [2]=>
    string(7) ".php_cs"
    [3]=>
    string(12) ".php_cs.dist"
    [4]=>
    string(5) "*.inc"
    [5]=>
    string(9) "*.install"
    [6]=>
    string(8) "*.module"
    [7]=>
    string(9) "*.profile"
    [8]=>
    string(5) "*.php"
    [9]=>
    string(7) "*.theme"
  }
FlorentTorregrosa commented 1 year ago

Hi,

I think this is coming from Symfony Finder, because when I inject custom finder like in comment https://github.com/drupol/phpcsfixer-configs-drupal/issues/5#issuecomment-1124055116, the foo.module file is detected.

But with Symfony Finder, even if *.module is in the list of patterns it is not found.

FlorentTorregrosa commented 1 year ago

With this comment, https://github.com/drupol/phpcsfixer-configs-drupal/issues/8#issuecomment-1764550086, I had been able to fix my problem. Thanks @WengerK

Compared to comment https://github.com/drupol/phpcsfixer-configs-drupal/issues/5#issuecomment-1124055116, I was missing the part where it says to the ruleset to use the finder:

$custom_config->setFinder($finder);