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

Incompatible declaration of RealPathFilterIterator::toRegex() #1635

Closed
andreaskienast opened this issue Jan 7, 2022 · 5 comments · Fixed by #1639
Closed

Incompatible declaration of RealPathFilterIterator::toRegex() #1635

andreaskienast opened this issue Jan 7, 2022 · 5 comments · Fixed by #1639
Labels
Milestone

Comments

@andreaskienast
Copy link

andreaskienast commented Jan 7, 2022

Question Answer
Infection version 0.25.5 (infection.phar --version)
Test Framework version PHPUnit/PhpSpec 9.5.11
symfony/finder version 4.4.36
PHP version 7.4.26 (php -v)
Platform Ubuntu
Github Repo -

Run infection with active filters is not possible anymore for us as we're hitting type incompatibilities (see the output in the summary).
The following command is sufficient to trigger the error:

php ./bin/infection --configuration=build/infection.json --filter=oh-noes

We're suspecting 6844063 to cause the issue.

Output with issue
    ____      ____          __  _
   /  _/___  / __/__  _____/ /_(_)___  ____
   / // __ \/ /_/ _ \/ ___/ __/ / __ \/ __ \
 _/ // / / / __/  __/ /__/ /_/ / /_/ / / / /
/___/_/ /_/_/  \___/\___/\__/_/\____/_/ /_/

Infection - PHP Mutation Testing Framework version 0.25.5

PHP Fatal error:  Declaration of Infection\FileSystem\Finder\Iterator\RealPathFilterIterator::toRegex(string $str): string must be compatible with Symfony\Component\Finder\Iterator\MultiplePcreFilterIterator::toRegex($str) in /var/www/html/vendor/infection/infection/src/FileSystem/Finder/Iterator/RealPathFilterIterator.php on line 80

Fatal error: Declaration of Infection\FileSystem\Finder\Iterator\RealPathFilterIterator::toRegex(string $str): string must be compatible with Symfony\Component\Finder\Iterator\MultiplePcreFilterIterator::toRegex($str) in /var/www/html/vendor/infection/infection/src/FileSystem/Finder/Iterator/RealPathFilterIterator.php on line 80
@maks-rafalko
Copy link
Member

maks-rafalko commented Jan 7, 2022

I believe we need to do the following change in Infection source code:

- protected function toRegex(string $str): string
+ protected function toRegex($str): string

because:

  • Covariance allows a child's method to return a more specific type than the return type of its parent's method.
  • Contravariance allows a parameter type to be less specific in a child method, than that of its parent.

then, Symfony 4-6 will be supported, see https://3v4l.org/gbbY7

Feel free to help

@maks-rafalko maks-rafalko added this to the next milestone Jan 7, 2022
maks-rafalko added a commit that referenced this issue Jan 8, 2022
Fixes #1635

because:

* Covariance allows a child's method to return a more specific type than the return type of its parent's method.
* Contravariance allows a parameter type to be less specific in a child method, than that of its parent.
maks-rafalko added a commit that referenced this issue Jan 8, 2022
Fixes #1635

because:

* Covariance allows a child's method to return a more specific type than the return type of its parent's method.
* Contravariance allows a parameter type to be less specific in a child method, than that of its parent.
@andreaskienast
Copy link
Author

Thank you for fixing this issue so fast!

@maks-rafalko
Copy link
Member

Released as 0.25.6

Let us know if it doesn't work please :)

@andreaskienast
Copy link
Author

I've pushed an update of infection to our CI and everything is fine again. Cheers! 🍻

@maks-rafalko
Copy link
Member

Cool, thank you!

@maks-rafalko maks-rafalko modified the milestones: next, 0.26.0 Jan 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants