Repository navigation
Language: compile-time inheritance variance (LSP vs Zend) - #3332
Merged
Merged
Conversation
Validate parameter contravariance and return covariance against parent classes and interfaces at compile time, matching Zend zend_inheritance.c. Co-authored-by: Cursor <cursoragent@cursor.com>
…heritance-variance
3 tasks
…#3323) Guard narrow parameter and widened return override violations that InheritanceVariance rejects at parseAndCompile time. Co-authored-by: Cursor <cursoragent@cursor.com>
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
lib/Compiler/InheritanceVariance.phpto validate parameter contravariance and return covariance when a class overrides a parent or interface method in the same compile unit.Compiler::compile()so incompatible overrides fail at compile time with Zend-shaped messages (Declaration of … must be compatible with …).Zend/zend_inheritance.c(zend_verify_type_compatibility),Zend/zend_type.c.Notes
B $x, childA $xwhenB extends A); narrower parameters and wider returns are rejected (matching Zend).Test plan
Closes #3323
Made with Cursor