Skip to content

Add failing test case for Attribute Closure crash - #8802

Merged
samsonasik merged 2 commits into
mainfrom
failing-test-closure
Oct 24, 2026
Merged

samsonasik merged 2 commits into
mainfrom
failing-test-closure

Conversation

@samsonasik

@samsonasik samsonasik commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

@TomasVotruba here failing test case you requested at #8788 (comment)

without the patch, it got error:

There was 1 error:

1) Rector\Tests\Php55\Rector\String_\StringClassNameToClassConstantRector\StringClassNameToClassConstantRectorTest::test@/Users/samsonasik/www/rector-src/rules-tests/Php55/Rector/String_/StringClassNameToClassConstantRector/Fixture/attribute_on_closure_and_arrow_function.php.inc with data ('/Users/samsonasik/www/rector-...hp.inc')
Rector\Exception\ShouldNotHappenException: Node "PhpParser\Node\Expr\ClassConstFetch" with is missing scope required for scope refresh

@samsonasik samsonasik changed the title Add failing test case for Attribute Closure Add failing test case for Attribute Closure crash Oct 24, 2026
@samsonasik
samsonasik force-pushed the failing-test-closure branch from e9c40fe to eb75944 Compare October 24, 2026 08:33
@samsonasik

Copy link
Copy Markdown
Member Author

@TomasVotruba Running the test now got:

➜  rector-src git:(failing-test-closure) vendor/bin/phpunit rules-tests/Php55/Rector/String_/StringClassNameToClassConstantRector
PHPUnit 13.4.3 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.4.25
Configuration: /Users/samsonasik/www/rector-src/phpunit.xml

E.............                                                    14 / 14 (100%)

Time: 00:00.323, Memory: 96.52 MB

There was 1 error:

1) Rector\Tests\Php55\Rector\String_\StringClassNameToClassConstantRector\StringClassNameToClassConstantRectorTest::test@/Users/samsonasik/www/rector-src/rules-tests/Php55/Rector/String_/StringClassNameToClassConstantRector/Fixture/attribute_on_closure_and_arrow_function.php.inc with data ('/Users/samsonasik/www/rector-...hp.inc')
Rector\Exception\ShouldNotHappenException: Node "PhpParser\Node\Expr\ClassConstFetch" with is missing scope required for scope refresh

/Users/samsonasik/www/rector-src/src/Application/ChangedNodeScopeRefresher.php:72
/Users/samsonasik/www/rector-src/src/Rector/RectorRunner.php:126

@TomasVotruba

Copy link
Copy Markdown
Member

Awesome 👍 Can you look into with without using scope here?
Seems it's a simple string to class rename here.

@samsonasik

Copy link
Copy Markdown
Member Author

The Scope is needed so ClassConstFetch that replace it can be refreshed.

@samsonasik

samsonasik commented Oct 24, 2026 •

Copy link
Copy Markdown
Member Author

@TomasVotruba I've fixed with set scope on attribute on closure and arrowfunction

62bbf54

it is needed so ClassConstFetch under closure can be refreshed.

@samsonasik
samsonasik merged commit 8733317 into main Oct 24, 2026
49 checks passed
@samsonasik
samsonasik deleted the failing-test-closure branch October 24, 2026 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants