Closed
Description
Description
The following code:
<?php
enum Status: string
{
case DRAFT = 'draft';
case PUBLISHED = 'published';
case ARCHIVED = 'archived';
}
#[Attribute]
class ListensTo
{
public string $event;
public function __construct(string $event)
{
$this->event = $event;
}
}
#[ListensTo(Status::DRAFT->value)]
class TestClass {}
Resulted in this output:
PHP Fatal error: Constant expression contains invalid operations on line 23
But I expected it would work fine
PHP Version
PHP 8.1.4
Operating System
Ubuntu 20.04