Skip to content

Conversation

VincentLanglet
Copy link
Contributor

Copy link
Member

@ondrejmirtes ondrejmirtes left a comment

Choose a reason for hiding this comment

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

I don't want this huge refactoring. I don't think it makes sense to support Foo::* in an array shape key, because the result would no longer be ConstantArrayType, but ArrayType only.

The handling of Foo::BAR in an array shape key needs new code, not reusing of an existing code. For example supporting enums does not make sense there either.

Also, I realized that support for static:: is currently insufficient. It's not going to do what people expect in subclasses. But that's a story for another day.

@VincentLanglet
Copy link
Contributor Author

I don't want this huge refactoring. I don't think it makes sense to support Foo::* in an array shape key, because the result would no longer be ConstantArrayType, but ArrayType only.

The handling of Foo::BAR in an array shape key needs new code, not reusing of an existing code. For example supporting enums does not make sense there either.

Also, I realized that support for static:: is currently insufficient. It's not going to do what people expect in subclasses. But that's a story for another day.

Ok so I tried another way.

I still created a method resolveArrayShapeOffsetType because there is a lot of early return in the ConstFetchNode handling code.

Then I used a simpler version for the ConstFetchNode by

  • removing * support
  • removing Enum support

@ondrejmirtes ondrejmirtes merged commit 08b44e8 into phpstan:2.1.x Sep 7, 2025
441 of 453 checks passed
@ondrejmirtes
Copy link
Member

Thank you.

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

Successfully merging this pull request may close these issues.

Cannot use constant as key in array shape Constants in return array syntax
2 participants