Skip to content

[CodeQuality] Skip anonymous class in AssertEmptyNullableObjectToAssertInstanceofRector - #792

Merged
TomasVotruba merged 1 commit into
mainfrom
fix-anonymous-class-assert-instanceof
Oct 8, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
fix-anonymous-class-assert-instanceof

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Fixes rectorphp/rector#9922

AssertEmptyNullableObjectToAssertInstanceofRector rewrote assertNotNull() on a nullable anonymous class into assertInstanceOf() using PHPStan's internal AnonymousClass<hash> name. That class does not exist at runtime, so the rewritten test errors with UnknownClassOrInterfaceException.

Now the rule skips when the non-null type is an anonymous class - there is no writable class name to emit, so assertNotNull() is left untouched.

@TomasVotruba
TomasVotruba merged commit 4acf210 into main Oct 8, 2026
8 checks passed
@TomasVotruba
TomasVotruba deleted the fix-anonymous-class-assert-instanceof branch October 8, 2026 21:41
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.

AssertEmptyNullableObjectToAssertInstanceofRector writes PHPStan's internal AnonymousClass<hash> name for anonymous classes

1 participant