php-src
php-src copied to clipboard
Enums can't be initialized in the constructor
Description
I have the following code:
<?php
enum TKind {
case TK_PUNCT;
case TK_NUM;
case TK_EOF;
}
class A{
public TKind $kind;
public function __constructor($kindArg){
$this->kind = $kindArg;
}
}
$a = new A(Tkind::TK_PUNCT);
var_dump($a);
I am expecting $a->kind to be initialized, yet the output looks like the following,
object(A)#1 (0) {
["kind"]=>
uninitialized(TKind)
}
Demo: https://3v4l.org/18V1r#v8.1.5
PHP Version
8.1.5
Operating System
No response