[FEATURE] \Hyperf\Constants\Annotation\Message key目前仅支持全小写格式,建议key的格式可以多样化
minororange opened this issue · comments
**
* @method string getActionName()
* @method string getEventName()
*/
#[Constants]
enum DemoEnum: string
{
use EnumConstantsTrait;
#[Message("创建", 'actionname')]
#[Message("created", 'EventName')]
case CREATED = 'created';
}
echo DemoEnum::CREATED->getActionName(); // 可以正常获取
echo DemoEnum::CREATED->getEventName(); // 获取不到
看了下源码,读取的时候,方法名传进去之后,get
后面的全部转化为了小写:\Hyperf\Constants\GetterTrait::getValue 45行
在 collect Message
这个 Annotation 的时候,并没有对 key 额外处理:\Hyperf\Constants\AnnotationReader::getAnnotations 44 行
建议 Message
key 支持多种格式(snake,camelCase,bigCamel等)
提了个 pr: #6813