Cannot create dynamic property %s::$%s

Description

It is not possible to add a property to an enumeration, and it is also not possible to create a property dynamically, on an enumeration object. This is valid for both normal and static properties.

Example

<?php

enum E: int {
    case Foo = 0;
}

$variable = E::Foo;
$variable->property = 1;

?>

Literal Examples

  • Cannot create dynamic property E::$property

Solutions

  • Don’t create a property on an enumeration.

  • Encapsulate the enumeration in an another class, and set the property on this class.