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

Incorrect exeptions with enums #1384

Closed
SimonVorgers opened this issue Dec 8, 2023 · 2 comments
Closed

Incorrect exeptions with enums #1384

SimonVorgers opened this issue Dec 8, 2023 · 2 comments
Assignees
Labels

Comments

@SimonVorgers
Copy link

I have a question related to this MR

Can you tell us why this should throw an exception?

File:

enum Foo: int {
    case ONE = 1;
}
class Bat {
    const ONE_VALUE = Foo::ONE;
}

Should be supported since php 8.1.0 🤔
Because now, its throwing every time an exception.

File:

if ($classReflection instanceof ReflectionEnum) {
  throw Exception\UnableToCompileNode::becauseOfValueIsEnum($context, $classReflection, $node);
}

The comment from original issue could also work.

Thanks in advance

@Ocramius
Copy link
Member

Ocramius commented Dec 8, 2023

this should throw an exception?

Static analysis should work, but retrieving the value of an ENUM is not possible, because ENUMs only exist as instances.

The core invariant of BetterReflection, which is what should make it "better", is that it shouldn't load any code: instantiating an ENUM will cause autoloading, which will already break this core design constraint that is the foundation of the entire library.

@Ocramius
Copy link
Member

Ocramius commented Mar 8, 2024

Closing: explained above

@Ocramius Ocramius closed this as completed Mar 8, 2024
@Ocramius Ocramius self-assigned this Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants