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

Invalid mutator config #1479

Closed
theofidry opened this issue Feb 7, 2021 · 7 comments
Closed

Invalid mutator config #1479

theofidry opened this issue Feb 7, 2021 · 7 comments
Assignees
Labels
Milestone

Comments

@theofidry
Copy link
Member

At first glance:

{
    "mutators": {
        "MBString": {
            "settings": {
                "mb_strcut": false
            }
        }
    }
}

results in an error although I believe it's the correct way to configure it or at least it's the one suggested from the schema...

Error (in PHP 7.4, infection 0.21.0):

PHP Fatal error:  Uncaught TypeError: Return value of Infection\Mutator\MutatorResolver::Infection\Mutator\{closure}() must be of the type array, object returned in /path/to/vendor/infection/infection/src/Mutator/MutatorResolver.php:142
Stack trace:
@maks-rafalko
Copy link
Member

maks-rafalko commented Feb 7, 2021

I can't reproduce the issue for 0.21 and master locally for Infection itself.

It also works for 0.20.1

Could you please provide the whole config (probably it's a combination of settings leading to this issue), or minimal reproducible case?

@theofidry
Copy link
Member Author

Hm for some reasons I cannot reproduce it anymore locally... I'll close it for now and open it again with a more thorough investigation or a reproducer

@Spomky
Copy link

Spomky commented Feb 27, 2021

Hi,

I have the same issue updating from v0.20 to v0.21.
Surprisingly, if I removed global-ignoreSourceCodeByRegex or MBString keys it works fine (but not as expected).
Both keys cannot be used together.

Hereafter the trace:

./vendor/bin/infection -s --threads=$(nproc) --min-msi=95 --min-covered-msi=95
PHP Fatal error:  Uncaught TypeError: Argument 1 passed to Infection\Mutator\MutatorResolver::Infection\Mutator\{closure}() must be of the type array, object given in /mnt/vendor/infection/infection/src/Mutator/MutatorResolver.php:142
Stack trace:
#0 [internal function]: Infection\Mutator\MutatorResolver::Infection\Mutator\{closure}()
#1 /mnt/vendor/infection/infection/src/Mutator/MutatorResolver.php(143): array_map()
#2 /mnt/vendor/infection/infection/src/Mutator/MutatorResolver.php(90): Infection\Mutator\MutatorResolver::resolveSettings()
#3 /mnt/vendor/infection/infection/src/Configuration/ConfigurationFactory.php(196): Infection\Mutator\MutatorResolver->resolve()
#4 /mnt/vendor/infection/infection/src/Configuration/ConfigurationFactory.php(137): Infection\Configuration\ConfigurationFactory->resolveMutators()
#5 /mnt/vendor/infection/infection/src/Mutator/MutatorResolver.php on line 142

My configuration file:

{
    "source": {
        "directories": [
            "src"
        ]
    },
    "logs": {
        "text": "infection.log"
    },
    "mutators": {
        "@default": true,
        "global-ignoreSourceCodeByRegex": [
           "\\$this->logger.*",
           "\\$this->cache->save.*",
           "parent::build(\\$container);"
        ],
        "MBString": {
            "settings": {
                "mb_substr": false,
                "mb_strlen": false
            }
        }
    }
}

@theofidry
Copy link
Member Author

Can't reproduce it on the playground but it has not been updated to 0.21 yet: https://infection-php.dev/r/yg6k

@maks-rafalko
Copy link
Member

Good news: deployed 0.21.2 to Playground
Bad news: I can reproduce it: https://infection-php.dev/r/ww32

@maks-rafalko
Copy link
Member

maks-rafalko commented Mar 3, 2021

Fixed and released https://github.com/infection/infection/releases/tag/0.21.4

cc @Spomky

@Spomky
Copy link

Spomky commented Mar 4, 2021

Excellent! I will update ASAP my projects and check if it is fine now.
Thank you for the quick fix.

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

No branches or pull requests

3 participants