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

False positive for missing BackedEnum::cases() #9065

Closed
BenMorel opened this issue Jan 6, 2023 · 2 comments · Fixed by #9067
Closed

False positive for missing BackedEnum::cases() #9065

BenMorel opened this issue Jan 6, 2023 · 2 comments · Fixed by #9067
Assignees

Comments

@BenMorel
Copy link
Contributor

BenMorel commented Jan 6, 2023

Not sure why, but the following code fails both on 5.4.0 and on the latest commit, 8329309:

<?php

interface FeatureFlagInterface extends BackedEnum
{
}

function test(FeatureFlagInterface $featureFlag): void
{
    $featureFlag::cases();
}

ERROR: UndefinedMethod - src/test.php:9:5 - Method FeatureFlagInterface::cases does not exist (see https://psalm.dev/022)
$featureFlag::cases();

Even though the Psalm website does not report any error, using the same commit:

https://psalm.dev/r/8e66ae9cd8


Reproduce:

mkdir -p bug/src && cd bug
cat > src/test.php <<'EOF'
<?php

interface FeatureFlagInterface extends BackedEnum
{
}

function test(FeatureFlagInterface $featureFlag): void
{
    $featureFlag::cases();
}
EOF
composer require vimeo/psalm:dev-master#8329309
vendor/bin/psalm --init src 1
vendor/bin/psalm
@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/8e66ae9cd8
<?php

interface FeatureFlagInterface extends BackedEnum
{
}

function test(FeatureFlagInterface $featureFlag): void
{
    $featureFlag::cases();
}
Psalm output (using commit 8329309):

No issues!

@weirdan weirdan self-assigned this Jan 6, 2023
weirdan added a commit to weirdan/psalm that referenced this issue Jan 6, 2023
Fixes vimeo#9065

Inheritance in stubs seems to be broken
@BenMorel
Copy link
Contributor Author

BenMorel commented Jan 8, 2023

Thanks for the fix! Do you know why psalm.dev did not report any issue, using the same commit?

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