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

After upgrade to 0.12.78 #4577

Closed
dakorpar opened this issue Feb 20, 2021 · 4 comments
Closed

After upgrade to 0.12.78 #4577

dakorpar opened this issue Feb 20, 2021 · 4 comments

Comments

@dakorpar
Copy link

dakorpar commented Feb 20, 2021

Bug report

After upgrading to 0.12.78 looks like

	if ($classType->isSubclassOf(BaseRequest::class)) {
		$request = $classType->newInstance();

$request is being recognized as object instead of BaseRequest,

159 Call to an undefined method object::whatever().

works well on 0.12.77 and does not report this error.

Code snippet that reproduces the problem

	if ($classType->isSubclassOf(BaseRequest::class)) {
		$request = $classType->newInstance();
		request->whatever();

	}

https://phpstan.org/r/e1fc69b5-0542-4286-9d52-c85234392b07

ignore the first error, second one is problem

Expected output

no issue here

@ondrejmirtes
Copy link
Member

Hi, I'm pretty sure this haven't changed in 0.12.78, just verified when running this locally. It's very possible that the type inference got smarter in 0.12.78 and your variable is now of type object instead of mixed for example. One of likely changes to cause this is for example phpstan/phpstan-src@0f64ca7 or phpstan/phpstan-src@bf320b0.

Can you provide a piece of code that you verify locally passing on 0.12.77 and failing on 0.12.78?

@ondrejmirtes
Copy link
Member

Anyway, I just wrote a little extension that makes PHPStan understand this code anyway: phpstan/phpstan-src@d3b5d60

@dakorpar
Copy link
Author

dakorpar commented Feb 22, 2021

@ondrejmirtes I actually runned phpstan on 0.12.77 and 0.12.78 it threw error only on 0.12.78.
However maybe it is because before it recognized var as mixed.
Thanks!

@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 Apr 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants