Skip to content

Handle for infinite loop on recursive trait#5488

Open
samsonasik wants to merge 13 commits intophpstan:2.1.xfrom
samsonasik:infinite-loop
Open

Handle for infinite loop on recursive trait#5488
samsonasik wants to merge 13 commits intophpstan:2.1.xfrom
samsonasik:infinite-loop

Conversation

@samsonasik
Copy link
Copy Markdown
Contributor

@samsonasik samsonasik commented Apr 18, 2026

@BoyeMagnus @TomasVotruba if this can be patched here in phpstan, this should fix rector issue infinite loop on recursive trait usage

the test here I added cause phpunit error

➜  phpstan-src git:(infinite-loop) vendor/bin/phpunit tests/PHPStan/Type/FileTypeMapperTest.php |more
PHPUnit 11.5.52 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.4.16
Configuration: /Users/samsonasik/www/phpstan-src/phpunit.xml
Random Seed:   1776480340

.E.....                                                             7 / 7 (100%)

Time: 00:01.209, Memory: 150.73 MB

There was 1 error:

1) PHPStan\Type\FileTypeMapperTest::testRecursiveTraitUsedInAnonymousClassDoesNotLoopIndefinitely
Error: Maximum call stack size of 8339456 bytes (zend.max_allowed_stack_size - zend.reserved_stack_size) reached. Infinite recursion?

/Users/samsonasik/www/phpstan-src/vendor/nikic/php-parser/lib/PhpParser/NodeAbstract.php:108
/Users/samsonasik/www/phpstan-src/vendor/nikic/php-parser/lib/PhpParser/NodeAbstract.php:117
/Users/samsonasik/www/phpstan-src/vendor/ondrejmirtes/better-reflection/src/Util/GetLastDocComment.php:22

@phpstan-bot
Copy link
Copy Markdown
Collaborator

You've opened the pull request against the latest branch 2.2.x. PHPStan 2.2 is not going to be released for months. If your code is relevant on 2.1.x and you want it to be released sooner, please rebase your pull request and change its target to 2.1.x.

@samsonasik samsonasik changed the base branch from 2.2.x to 2.1.x April 18, 2026 02:46
@samsonasik
Copy link
Copy Markdown
Contributor Author

Fixed 🎉 /cc @BoyeMagnus @TomasVotruba

@samsonasik
Copy link
Copy Markdown
Contributor Author

@ondrejmirtes ready for review 👍

@samsonasik
Copy link
Copy Markdown
Contributor Author

@ondrejmirtes ready for review 👍

CI notice is unrelated.

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

Successfully merging this pull request may close these issues.

2 participants