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.

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