Join union types when rendering callable parameters and return - #4114
Open
lacatoire wants to merge 1 commit into
Open
Join union types when rendering callable parameters and return#4114lacatoire wants to merge 1 commit into
lacatoire wants to merge 1 commit into
Conversation
lacatoire
force-pushed
the
fix/issue-3995-callable-union-type
branch
from
April 17, 2026 15:39
e635b5f to
7554951
Compare
LinkRenderer::render returns string|list<string>, and the IterableAdapter matches any Compound type because Compound implements IteratorAggregate. CallableAdapter previously fed that result straight into sprintf, which triggered a PHP "Array to string conversion" warning for any callable that used a union type in its signature. Route both parameter and return type rendering through a small renderType helper that joins list<string> results with a | separator, mirroring what AbstractListAdapter already does for array/iterable element types. Fixes phpDocumentor#3995
lacatoire
force-pushed
the
fix/issue-3995-callable-union-type
branch
from
April 17, 2026 15:42
7554951 to
3e517ae
Compare
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.
LinkRenderer::renderis typedstring|list<string>, and theIterableAdaptermatches anyCompoundtype becauseCompoundimplementsIteratorAggregate.CallableAdapterused to feed that result straight intosprintf("%s", $type), which triggered a PHP Array to string conversion warning for any callable that carried a union type in its signature (see #3995).Route both parameter and return type rendering through a small
renderTypehelper that joinslist<string>results with a|separator, mirroring whatAbstractListAdapteralready does for array/iterable element types.Covered by new parameterised unit tests for union parameters, union return type, named/variadic/mixed union parameters.
Fixes #3995