mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
Merge pull request #6984 from orklah/enumcase-in-attribute
allow using EnumCase in an Attribute
This commit is contained in:
commit
b4d25cbf60
@ -385,6 +385,10 @@ class StubsGenerator
|
||||
|
||||
return new VirtualArray($new_items);
|
||||
}
|
||||
|
||||
if ($atomic_type instanceof Type\Atomic\TEnumCase) {
|
||||
return new VirtualClassConstFetch(new VirtualName('\\' . $atomic_type->value), new VirtualIdentifier($atomic_type->case_name));
|
||||
}
|
||||
}
|
||||
|
||||
return new VirtualString('Psalm could not infer this type');
|
||||
|
@ -174,6 +174,31 @@ class EnumTest extends TestCase
|
||||
[],
|
||||
'8.1',
|
||||
],
|
||||
'EnumCaseInAttribute' => [
|
||||
'<?php
|
||||
class CreateController {
|
||||
#[Param(paramType: ParamType::FLAG)]
|
||||
public function actionGet(): void {}
|
||||
}
|
||||
|
||||
use Attribute;
|
||||
|
||||
#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
|
||||
class Param {
|
||||
public function __construct(
|
||||
public ParamType $paramType = ParamType::PARAM
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
enum ParamType {
|
||||
case FLAG;
|
||||
case PARAM;
|
||||
}',
|
||||
'assertions' => [],
|
||||
[],
|
||||
'8.1',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user