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

Using trait_exists() produces "UndefinedClass" #7395

Closed
wouterj opened this issue Jan 14, 2022 · 1 comment · Fixed by #10659
Closed

Using trait_exists() produces "UndefinedClass" #7395

wouterj opened this issue Jan 14, 2022 · 1 comment · Fixed by #10659

Comments

@wouterj
Copy link
Contributor

wouterj commented Jan 14, 2022

https://psalm.dev/r/4d535eda5a

I'm testing my library using different major versions of a dependency. Using trait_exists() is a nice way to check if the latest major version is installed. However, it seems like Psalm doesn't yet understand trait_exists() as well as it understands class_exists().

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/4d535eda5a
<?php

if (trait_exists(\Something::class)) {
}

if (class_exists(\Otherthing::class)) {
}
Psalm output (using commit 0ded59d):

ERROR: UndefinedClass - 3:18 - Class, interface or enum named Something does not exist

INFO: MixedArgument - 3:18 - Argument 1 of trait_exists cannot be mixed, expecting string

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants