Skip to content

AllowDynamicProperties validation should error on enums #15731

Closed
@DanielEScherzer

Description

@DanielEScherzer

Description

The following code:

<?php

#[AllowDynamicProperties]
enum Example {
    case MyCase;
}

$c = Example::MyCase;
$c->prop = 'foo';

Resulted in this output:

Fatal error: Uncaught Error: Cannot create dynamic property Example::$prop in /in/Aqipu:9
Stack trace:
#0 {main}
  thrown in /in/Aqipu on line 9

Process exited with code 255.

But I expected this output instead:

Fatal error: Cannot apply #[AllowDynamicProperties] to enum in /in/Aqipu on line 4

Process exited with code 255.

PHP Version

PHP 8.2

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions