看下面的代码:
<?php
enum Types:string {
case A = 'a';
case B = 'b';
}
#[Attribute(Attribute::TARGET_CLASS)]
class MyAttribute {
public function __construct(public readonly array $mapping)
{
}
}
#[MyAttribute(mapping: [Types::A->value => ''])]
class Entity {
}
有错误 常量表达式包含无效操作。我想在我的属性中使用枚举值来定义配置。看起来这是 php 中的错误。应该报告还是什么?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号