Only set return native type from null return type when declaring class is built in on __toString()#3978
Closed
samsonasik wants to merge 8 commits intophpstan:2.1.xfrom
Closed
Only set return native type from null return type when declaring class is built in on __toString()#3978samsonasik wants to merge 8 commits intophpstan:2.1.xfrom
samsonasik wants to merge 8 commits intophpstan:2.1.xfrom
Conversation
Contributor
Author
|
@ondrejmirtes ready for review, not sure about the php 7.4 notice: https://github.com/phpstan/phpstan-src/actions/runs/14802288573/job/41563600230?pr=3978#step:6:226 since other php versions green, could you give me hint to make it green? Thank you. |
ondrejmirtes
requested changes
May 2, 2025
| } | ||
| if ($name === '__tostring') { | ||
| return $this->nativeReturnType = new StringType(); | ||
| return $this->nativeReturnType = $this->declaringClass->isBuiltin() |
Member
There was a problem hiding this comment.
- How is
__toString()different from other methods handled by this method? - Personally I'd like a test + revert of the commit that changed this (3854cbc) instead of this change.
Contributor
Author
There was a problem hiding this comment.
- we found by case, for current case is
__toString()so don't know what other needs - yes, I think revert is better for this case, as native is native on overridden method.
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.
Start from PHPStan 2.1.14, in
Rector, we got notice when downgrade code:This add
stringreturn toWithParentMixedReturn::__toString()see https://3v4l.org/IrE2q#v7.4.33The issue is when code consumed by user: https://3v4l.org/kdcEh#v7.4.33 it got error:
On our rector-src code, I patch there with use our AstResolver to specify on
__toStringwhen no return and non-built into return
MixedType@TomasVotruba if this accepted, we may can rollback to original implementation 👍