Support PHP 8 union and intersection types - #5
Open
sgiehl wants to merge 1 commit into
Open
Conversation
UnionType and IntersectionType cannot be cast to string, so parsing a method with such a parameter or return type threw 'Object of class PhpParser\Node\UnionType could not be converted to string'. Hit by Matomo 6, eg Piwik\Plugin\ConsoleCommand::handleSignal(): int|false.
sgiehl
added a commit
to matomo-org/developer-documentation
that referenced
this pull request
Aug 24, 2026
Sami cannot cast UnionType/IntersectionType to string, so generating the 6.x API reference aborted on eg ConsoleCommand::handleSignal(): int|false. Points tsteur/sami at matomo-org/Sami#5 and raises the generator PHP floor to 7.2.5; the declared >=5.3.0 was long untrue.
sgiehl
added a commit
to matomo-org/developer-documentation
that referenced
this pull request
Aug 25, 2026
Sami cannot cast UnionType/IntersectionType to string, so generating the 6.x API reference aborted on the union-typed signatures matomo-php-tracker 4.0 introduced. Points tsteur/sami at matomo-org/Sami#5 and raises the generator PHP floor to 8.1.0, matching what the locked dependencies actually require.
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.
UnionTypeandIntersectionTypeare the only type nodes that cannot be cast to string, soNodeVisitorthrewObject of class PhpParser\Node\UnionType could not be converted to stringwhen parsing a method that uses one.Adds an
elseifbranch at both sites (parameter types ~L174, return types ~L224) and a sharedgetCompositeTypeAsString()helper.Hit by Matomo 6:
Piwik\Plugin\ConsoleCommand::handleSignal(int $signal): int|falseaborts the whole API-reference generation for developer.matomo.org. Matomo 5 has no union types in the parsed scope, which is why this only surfaces now. Note the crash happens during parsing, before the class filter runs, so a non-@apiclass is enough to break the run.Verified against the real generation: with this patch
generator/generate.php --branch=6.x-devcompletes with exit 0, and the output is byte-identical to a run using an inline version of the same fix.Native property types need no equivalent change —
addProperty()reads only the@vardocblock.