Repository navigation
Resolve a self-typed parameter to its declaring class - #160
Merged
Merged
Conversation
A generated override wrote `self` through, and inside the generated class that names the generated subclass, so PHP 8.3/8.4 rejected the signature as narrowed. A trait method was affected on 8.5 too. The keyword check in qualify() was also case-sensitive, so `SELF` rendered as `\SELF`. Fixes #158
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Merged
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.
Fixes #158
What
selfwas written through into the generated override, whereselfnames the generated subclass. PHP 8.3/8.4 rejected the signature as narrowed. It now renders as the declaring class, the wayparentalready did (TypeRenderer::resolveSelf()); returns keep the keyword, where a subclass is a legal narrowing.selfunresolved on every version. The declaring class Reflection reports for it is the using class, which is whatselfmeans there.qualify()compared relative keywords case-sensitively, soSELF/Parent/STATICrendered as\SELF— a fatal on 8.3/8.4 in both parameter and return position.Tests
tests/Fixture/Unify/: class (self,?self), interface, trait + user.TargetUnifierEdgeTest: end-to-end doubles for each shape, rendered type carries noself.TypeRendererTest: unit cases, plus an uppercaseSELFdeclared viaevalinside a trait (the only place 8.5 keeps the keyword literal, so the case is exercised on every version).Verification
php:8.3-cliandphp:8.4-cli: 1182 passed.composer build+composer rector(8.5): green.make mutation-diff: 17 mutants, 0 escaped, covered MSI 100%.selfcase, on 8.5 at the trait case.