Add support for PHP 8.4 interface properties#4087
Open
lacatoire wants to merge 8 commits intophpDocumentor:masterfrom
Open
Add support for PHP 8.4 interface properties#4087lacatoire wants to merge 8 commits intophpDocumentor:masterfrom
lacatoire wants to merge 8 commits intophpDocumentor:masterfrom
Conversation
PHP 8.4 allows declaring properties in interfaces using property hooks. Wire the property support through the descriptor layer and templates: - Accept InterfaceInterface in PropertyDescriptor::setParent() - Add property collection to InterfaceInterface and InterfaceDescriptor - Assemble properties in InterfaceAssembler - Display properties in the default interface template Depends on phpDocumentor/Reflection#739. Fixes phpDocumentor#4061
jaapio
requested changes
Apr 10, 2026
Replace manual property methods with the HasProperties trait, keeping only the overridden getInheritedProperties() to handle interface multi-parent inheritance. Point composer to the reflection fork branch that adds Interface_::getProperties() to fix PHPStan.
Member
|
I merged your changes in reflection a new versio (6.6.0) contains the fixes. |
InterfaceDescriptor uses the HasProperties trait but does not implement ChildInterface, so the parent recursion branch in getMagicProperties() is unreachable for it. PHPStan still observes the always-false instanceof while analysing the trait in that context; a scoped ignoreError documents why the report is expected.
…-parent inheritance
- Wrap Constants/Properties/Methods ToC links in {% if X is not empty %}
to match class.html.twig and stop emitting dangling anchors for empty
sections.
- Replace 'constants.deprecated' with 'constant.deprecated' inside the
Constants loop (the loop variable is the singular form).
- Add a unit test covering getInheritedProperties() with multiple parent
interfaces, which is unique to interfaces (extends A, B).
…operties # Conflicts: # composer.json # composer.lock
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
PHP 8.4 allows declaring properties in interfaces using property hooks:
This was not supported, causing a crash:
Expected an instance of any of Class_, Trait_. Got: Interface_.InterfaceInterfaceinPropertyDescriptor::setParent()InterfaceInterface/InterfaceDescriptorwith inheritance supportInterfaceAssemblerFixes #4061