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

rules in dynamic sets cannot be configured #186

Closed
ju1ius opened this issue Mar 14, 2024 · 2 comments
Closed

rules in dynamic sets cannot be configured #186

ju1ius opened this issue Mar 14, 2024 · 2 comments

Comments

@ju1ius
Copy link

ju1ius commented Mar 14, 2024

Hi,

Given the following configuration:

use PhpCsFixer\Fixer\FunctionNotation\FunctionDeclarationFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;

return ECSConfig::configure()
    ->withPhpCsFixerSets(perCS: true)
    ->withConfiguredRule(FunctionDeclarationFixer::class, [
        'closure_function_spacing' => 'none',
    ])
;

And the the following input file test.php:

<?php

$f = function($x) {};

Running ecs check test.php produces the following output:

    ---------- begin diff ----------
@@ -1,3 +1,3 @@
 <?php

-$f = function($x) {};
+$f = function ($x) {};
    ----------- end diff -----------


Applied checkers:

 * PhpCsFixer\Fixer\FunctionNotation\FunctionDeclarationFixer

But I expected the following:

[OK] No errors found. Great job - your code is shiny in style!
@ju1ius
Copy link
Author

ju1ius commented Mar 14, 2024

After reading #183, it seems to be related.

If I change the configuration to:

use PhpCsFixer\Fixer\FunctionNotation\FunctionDeclarationFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;

return ECSConfig::configure()
    ->withPaths([__DIR__ . '/test.php'])
    ->withPhpCsFixerSets(perCS: true)
    ->withConfiguredRule(FunctionDeclarationFixer::class, [
        'closure_function_spacing' => 'none',
    ])
;

Running ecs check (without any arguments) produces the expected output:

[OK] No errors found. Great job - your code is shiny in style!

BUT if I move the test.php file to tests/test.php, then change the configuration to:

use PhpCsFixer\Fixer\FunctionNotation\FunctionDeclarationFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;

return ECSConfig::configure()
    ->withPaths([__DIR__ . '/tests'])
    ->withPhpCsFixerSets(perCS: true)
    ->withConfiguredRule(FunctionDeclarationFixer::class, [
        'closure_function_spacing' => 'none',
    ])
;

Running ecs check (without any arguments) produces the wrong output:

1) tests/test.php

    ---------- begin diff ----------
@@ -1,3 +1,3 @@
 <?php

-$f = function($x) {};
+$f = function ($x) {};
    ----------- end diff -----------


Applied checkers:

 * PhpCsFixer\Fixer\FunctionNotation\FunctionDeclarationFixer

@TomasVotruba
Copy link
Contributor

Resolved in #188

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

2 participants