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

Fix missing properties for UnitEnum and BackedEnum interfaces #971

Merged
merged 2 commits into from Jan 18, 2022

Conversation

ondrejmirtes
Copy link
Contributor

Phew, interfaces with properties...

This one actually fixes a couple of problems:

  1. When reflecting UnitEnum and BackedEnum, which aren't actually enums, just plain interfaces, BackedEnum didn't know about the "name" property because ReflectionClass code didn't inherit properties from interfaces (understandably).
  2. jetbrains/phpstorm-stubs 2021.3 have several bugs in enum stubs - the properties aren't readonly, and the BackedEnum value property has wrong type. Relevant PRs: BackedEnum value is int|string JetBrains/phpstorm-stubs#1316 + [phpstorm-stubs] WI-62762 mark enums properties readonly JetBrains/phpstorm-stubs#1278

@Ocramius
Copy link
Member

May I add: what the fuck?

@ondrejmirtes
Copy link
Contributor Author

Original issue from here :) phpstan/phpstan#6385

@ondrejmirtes
Copy link
Contributor Author

The CI fails because you need this commit :) ondrejmirtes@b5d9ca3

It's about updating phpstorm-stubs so that in earlier PHP versions classes and interfaces don't implement/extend things from newer PHP versions.

I think I'm gonna leave that to @kukulich because it needs some more work :)

@Ocramius
Copy link
Member

@ondrejmirtes does #972 cover the missing details needed for this one?

@Ocramius
Copy link
Member

@kukulich some agreement needed for #972: should it land on 5.0.x as a bugfix, or 5.1.x as improvement?

I'm tempted to move this one to 5.1.x and cut 5.1.0 once ready

@Ocramius Ocramius added this to the 5.0.7 milestone Jan 18, 2022
@ondrejmirtes
Copy link
Contributor Author

ondrejmirtes commented Jan 18, 2022

AFAIK #972 fixes PhpStormStubsSourceStubber which is currently buggy - you ask for some class reflection, ask for its parent class and it crashes because it extends something it doesn't exist yet. So it can land in 5.0.x.

@kukulich
Copy link
Collaborator

I agree with @ondrejmirtes, eg. SimpleXMLIterator implements Stringable (PHP 8.0 only) so it cannot be reflected on PHP < 8.0, hence I think it's bug.

@Ocramius
Copy link
Member

If anyone can rebase this one, we can 🚢

@ondrejmirtes
Copy link
Contributor Author

Looks like it's going to be green :)

Copy link
Member

@Ocramius Ocramius left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@Ocramius Ocramius changed the title Fix missing properties for UnitEnum and BackedEnum interfaces Fix missing properties for UnitEnum and BackedEnum interfaces Jan 18, 2022
@Ocramius Ocramius merged commit d5c9a1a into Roave:5.0.x Jan 18, 2022
@Ocramius
Copy link
Member

Thanks @ondrejmirtes!

@Ocramius Ocramius self-assigned this Jan 18, 2022
kukulich added a commit to kukulich/BetterReflection that referenced this pull request Sep 28, 2022
Interface really should not have any properties but we have UnitEnum and BackedEnum Roave#971
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants