Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template base interface/class check is inconsistent with simple type #6589

Closed
mvorisek opened this issue Feb 7, 2022 · 3 comments · Fixed by phpstan/phpstan-src#1001
Closed

Comments

@mvorisek
Copy link
Contributor

mvorisek commented Feb 7, 2022

Bug report

follow #6575 (reply in thread)

a) returning Field for expected Field2 does emit an error since level 3
b) returning Field for expected template of Field2 does NOT emit an error until level 7
c) returning Field for expected template of Field does NOT emit an error until level 7

I agree the c) example needs a compromise (fixed in phpstan rel. v1.4.6), but the b) one is clearly not consistent vs. non-template a).

Code snippet that reproduces the problem

https://phpstan.org/r/24ccc414-b3e2-4c7a-b2fe-d02b34722f92

Expected output

Template base interface/class check is consistent with simple type, eg. both checked at level 3.

Method HelloWorldTemplated::getField() should return Field2 but returns Field.
Method HelloWorldSimple::getField()    should return Field2 but returns Field.
@ondrejmirtes
Copy link
Member

I'm not saying this is a bug, but you're welcome to look into it and improve it. But I don't want this as an open issue because the current state is good enough.

@arnaud-lb
Copy link
Contributor

arnaud-lb commented Feb 7, 2022

I think that this bug is valid: Here we should have the same error at line 14 and 23: https://phpstan.org/r/9b1c490a-8f68-4978-be70-41b90e2f44d7

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants