Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Rector combine path and skip

Tags:

php

rector

I have a PHP Symfony project with much vendor and other sub dir files which should not bee touched by rector. So I setup the path variable to only check files within a specific folder tree. That works fine.

    return static function (RectorConfig $rectorConfig): void {
    $rectorConfig->paths([
        __DIR__ . '/plugins/*',
    ]);

But since this folder contains plugins which may have their own vendor & test directories, I want to skip these. Regarding the docs https://github.com/rectorphp/rector/blob/main/docs/how_to_ignore_rule_or_paths.md skip with wildcards is possible, but these skip rules will be ignored totally.

return static function (RectorConfig $rectorConfig): void {
    $rectorConfig->paths([
        __DIR__ . '/plugins/*',
    ]);

    $rectorConfig->skip([
        __DIR__ . '/plugins/*/tests',
        __DIR__ . '/plugins/*/vendor',
    ]);

What could be wrong with my config? Or does rector not allow to combine these options? The documentation doesn't provide such a case.

like image 864
dnaumann Avatar asked Jun 13 '26 13:06

dnaumann


1 Answers

After a while I found out that skip doesn't work with directories but with files. So the following configuration works.

return static function (RectorConfig $rectorConfig): void {
    $rectorConfig->paths([
        __DIR__ . '/plugins/*',
    ]);

    $rectorConfig->skip([
        __DIR__ . '/plugins/*/tests/**/*',
        __DIR__ . '/plugins/*/vendor/**/*',
    ]);
like image 101
dnaumann Avatar answered Jun 15 '26 07:06

dnaumann



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!