Skip to content

Conversation

@VincentLanglet
Copy link
Contributor

@VincentLanglet VincentLanglet commented Nov 11, 2025

@VincentLanglet VincentLanglet changed the title Resolve value of BackEnum Resolve template with value of BackEnum Nov 11, 2025
@VincentLanglet VincentLanglet marked this pull request as ready for review November 11, 2025 14:51
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

@staabm
Copy link
Contributor

staabm commented Nov 11, 2025

interessting.. does it also solve phpstan/phpstan#13782 ?

@VincentLanglet
Copy link
Contributor Author

VincentLanglet commented Nov 11, 2025

interessting.. does it also solve phpstan/phpstan#13782 ?

You don't appear on the issue bot https://github.com/phpstan/phpstan-src/actions/runs/19269104831?pr=4548
But I can take a look after this one is merged

@staabm
Copy link
Contributor

staabm commented Nov 11, 2025

You don't appear on the issue bot

yes, thats because the issue does not yet have a label like "bug" or "feature request".
issue-bot does not look into unlabelled issues

if ($this->type->isEnum()->yes()) {
if (
$this->type instanceof TemplateType
&& $this->type->getBound()->equals(new ObjectType('BackedEnum'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be the other way arround?

Suggested change
&& $this->type->getBound()->equals(new ObjectType('BackedEnum'))
&& new ObjectType('BackedEnum')->isSuperTypeOf($this->type->getBound())->yes()?

Copy link
Contributor

@staabm staabm Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just had a look into the code-base. it seems we have spots where a Bound is compared using equals and sometimes it uses isSuperTypeOf.

I am not sure whether thats on purpose or an oversight

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isSuperTypeOf is better here indeed, in case someone use

interface SuperBackedEnum extends \BackedEnum

and a template of SuperBackedEnum.

test added

@VincentLanglet
Copy link
Contributor Author

You don't appear on the issue bot

yes, thats because the issue does not yet have a label like "bug" or "feature request". issue-bot does not look into unlabelled issues

Oh ok. Test added and seems like it does close phpstan/phpstan#13782.

@VincentLanglet
Copy link
Contributor Author

Hi @staabm, when I run

vendor/bin/phpunit tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php --filter=testBug12219

both mutator are caught locally.

Any idea why it could be reported on CI ? Is there some cache ?

@VincentLanglet
Copy link
Contributor Author

Hi @staabm, when I run

vendor/bin/phpunit tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php --filter=testBug12219

both mutator are caught locally.

Any idea why it could be reported on CI ? Is there some cache ?

As shown by 6cb52a2

if I tried the mutant reported by https://github.com/phpstan/phpstan-src/actions/runs/19963970402/job/57251263461?pr=4548

it failed.

I got the same issue with the following PR #4548

Either I misunderstand something, either it's buggy

@VincentLanglet VincentLanglet requested a review from staabm December 5, 2025 15:15
@staabm
Copy link
Contributor

staabm commented Dec 5, 2025

I had a look but cannot yet make sense of it

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

Labels

None yet

Projects

None yet

3 participants