Skip to content

Fix GH-25340: ReflectionEnumBackedCase::getBackingValue() on non-backed case - #25343

Open
lazerg wants to merge 3 commits into
php:PHP-8.4from
lazerg:fix/gh-25340
Open

lazerg wants to merge 3 commits into
php:PHP-8.4from
lazerg:fix/gh-25340

Conversation

@lazerg

@lazerg lazerg commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

ReflectionEnumUnitCase and ReflectionEnumBackedCase only checked the constant in their own constructors, after ReflectionClassConstant::__construct() had already stored it. A subclass calling ReflectionClassConstant::__construct() directly skipped those checks, and so did a failed second __construct() call, which left the new constant in place. getBackingValue() then crashed, and getEnum()/getValue() returned the wrong types. The checks now live in ReflectionClassConstant::__construct() itself, keyed on the object's class, and run before anything is stored.

Fixes GH-25340

@ndossche

ndossche commented Nov 9, 2026

Copy link
Copy Markdown
Member

getBackingValue is likely not the only method assuming that we're actually operating on a backed enum, this would need to be blocked another way I presume.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants