Skip to content

Fix transitive generic interface args in Reflection#3

Merged
azjezz merged 1 commit into
carthage-software:rfc/bound-erased-generic-types-historyfrom
prateekbhujel:prateekbhujel/generics-reflection-transitive-interface-args
May 12, 2026
Merged

Fix transitive generic interface args in Reflection#3
azjezz merged 1 commit into
carthage-software:rfc/bound-erased-generic-types-historyfrom
prateekbhujel:prateekbhujel/generics-reflection-transitive-interface-args

Conversation

@prateekbhujel
Copy link
Copy Markdown

ReflectionClass::getGenericArgumentsForParentInterface() handled direct generic interfaces, but missed bindings inherited through a non-generic intermediate class or interface.

Example:

interface Root<T> {}
interface Mid extends Root<int> {}
class C implements Mid {}

Mid reported Root<int>, but C reported an empty list for Root.

This keeps the inheritance checker behavior unchanged. Reflection now uses the existing binding walker for the matched ancestor and walks resolved parents/interfaces when answering a transitive interface query.

Tests run:

sapi/cli/php run-tests.php -q ext/reflection/tests/generics/ancestor_args_parent_interface.phpt Zend/tests/generics/reflection/namespace_relative_extends_implements_uses.phpt Zend/tests/generics/inheritance/diamond/interface_diamond_class_impl_covariant_missing.phpt Zend/tests/generics/inheritance/diamond/interface_diamond_class_impl_missing.phpt Zend/tests/generics/inheritance/diamond/invariant_class_diamond_bad_impl_rejected.phpt Zend/tests/generics/inheritance/diamond/invariant_interface_diamond_bad_impl_rejected.phpt Zend/tests/generics/inheritance/diamond/nullable_intersection_missing_branch_rejected.phpt Zend/tests/generics/inheritance/diamond/nullable_union_missing_null_rejected.phpt Zend/tests/generics/inheritance/diamond/property_hook_get_only_diamond_bad.phpt
sapi/cli/php run-tests.php -q Zend/tests/generics ext/reflection/tests/generics

Result: 407/407 passed for the full generics + Reflection generics run.

@azjezz azjezz merged commit f801084 into carthage-software:rfc/bound-erased-generic-types-history May 12, 2026
14 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants