feat: support static interface methods (PHP 8.3+)#458
Open
chadmandoo wants to merge 2 commits into
Open
Conversation
Interfaces may now declare `public static function` members. Adds InterfaceInfo.static_methods (+ static_method_order), recorded apart from instance methods (no vtable slot — static dispatch is by class, not vtable). Implementing classes satisfy them with a static method, validated by a new validate_interface_static_method (a concrete class omitting one errors; an abstract class may defer). Parent interfaces inherit static methods. Byte-parity regression test (static interface method + impl + call). Missing impl correctly errors; instance interfaces unregressed (the 2 pre-existing instanceof "linker failed" env failures are unchanged on clean integration). AIC epic illegalstudio#483 / EC-4 (illegalstudio#487). (cherry picked from commit 8db0923) (cherry picked from commit 7e1943f)
(cherry picked from commit 960d438)
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.
What
Adds support for PHP 8.3+ static interface methods — interfaces may now declare
public static functionmembers, and implementing classes satisfy them with a static method.Previously this errored at the schema stage: "Static interface methods are not supported yet".
How
InterfaceInfogainsstatic_methods(+static_method_order), recorded apart from instancemethods— static dispatch is by class, so they take no vtable slot.staticinterface method intostatic_methods(and inherits parent-interface static methods) instead of rejecting it.validate_interface_static_methodenforces conformance: a concrete class must declare a compatiblestaticmethod (an abstract class may defer); a missing implementation errors with "Class X must implement static interface method I::m".Verification
C::previews()→ identical output).