Repository navigation
Conversation
getMethodArgs() only recognised union types as unsupported and called isBuiltin() on every other parameter type. For an intersection type that is a ReflectionIntersectionType, so building such a class ended in an Error instead of a DependencyResolutionException, and the nullable fallback of a dependent class could not catch it. Any type that is not a named type is now treated like a union type: null for a nullable argument, otherwise a DependencyResolutionException. The PHPStan baseline entries hiding the problem are removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
Autowiring a class with an intersection-typed constructor argument (
__construct(A&B $x)) ended inError: Call to undefined method ReflectionIntersectionType::isBuiltin():getMethodArgs()only treatedReflectionUnionTypeas unsupported and calledisBuiltin()/getName()on every other type. Because it is anErrorand not aDependencyResolutionException, a class depending on such a class through a nullable argument could not fall back tonulleither. PHPStan reported the calls, but they were hidden in the baseline.Every parameter type that is not a
ReflectionNamedType(union, intersection and DNF types) is now handled the same way: a nullable argument receivesnull, any other one throws aDependencyResolutionException. The message now reads "Union and intersection typehints are not supported." The two baseline entries are removed. This also finishes what #46 reported for PHP 8 types.Testing Instructions
Tests/CompoundTypeTest.phpcovers required and nullable union and intersection types, and a class that depends on an intersection-typed class through a nullable argument. Before the change the intersection cases end in anError; after it, all pass.php vendor/bin/phpstan analysereports no errors without the removed baseline entries.Documentation Changes Required
docs/overview.md("When it does not work") now describes how union and intersection types are handled.Fixes #46
🤖 Generated with Claude Code