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

Call to static method on an unknown class #265

Closed
lookyman opened this issue May 10, 2017 · 4 comments
Closed

Call to static method on an unknown class #265

lookyman opened this issue May 10, 2017 · 4 comments

Comments

@lookyman
Copy link
Contributor

class Foo
{
	public function bar()
	{
		if (class_exists('\Bla')) {
			Bla::baz();
		}
	}
}

produces Call to static method baz() on an unknown class Bla, if the Bla class really does not exist. What should we do in this case? Or, what can we do?

@ondrejmirtes
Copy link
Member

Same argument as in #246 applies here:

I think it'd be better for the analysis if the function was defined in the environment - PHPStan can then check whether it's called correctly.

See the issue for more details and a code sample.

@lookyman
Copy link
Contributor Author

Right, thanks! ignoreErrors it is, then. :)

@ondrejmirtes
Copy link
Member

Or define the class ;)

@lock lock bot locked as resolved and limited conversation to collaborators Dec 20, 2019
@ondrejmirtes
Copy link
Member

This long-standing issue has now been fixed: phpstan/phpstan-src@1605bb2

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