3
3
namespace PHPStan \Reflection ;
4
4
5
5
use Attribute ;
6
+ use LogicException ;
6
7
use PhpParser \Node \Arg ;
7
8
use PhpParser \Node \Expr \StaticCall ;
8
9
use PhpParser \Node \Identifier ;
@@ -965,7 +966,11 @@ public function getEnumCases(): array
965
966
foreach ($ this ->reflection ->getCases () as $ case ) {
966
967
$ valueType = null ;
967
968
if ($ case instanceof ReflectionEnumBackedCase) {
968
- $ valueType = $ this ->initializerExprTypeResolver ->getType ($ case ->getValueExpression (), $ initializerExprContext );
969
+ try {
970
+ $ valueType = $ this ->initializerExprTypeResolver ->getType ($ case ->getValueExpression (), $ initializerExprContext );
971
+ } catch (LogicException ) {
972
+ // Enum case does not have a value
973
+ }
969
974
}
970
975
$ caseName = $ case ->getName ();
971
976
$ attributes = $ this ->attributeReflectionFactory ->fromNativeReflection ($ case ->getAttributes (), InitializerExprContext::fromClass ($ this ->getName (), $ this ->getFileName ()));
@@ -992,7 +997,11 @@ public function getEnumCase(string $name): EnumCaseReflection
992
997
$ case = $ this ->reflection ->getCase ($ name );
993
998
$ valueType = null ;
994
999
if ($ case instanceof ReflectionEnumBackedCase) {
995
- $ valueType = $ this ->initializerExprTypeResolver ->getType ($ case ->getValueExpression (), InitializerExprContext::fromClassReflection ($ this ));
1000
+ try {
1001
+ $ valueType = $ this ->initializerExprTypeResolver ->getType ($ case ->getValueExpression (), InitializerExprContext::fromClassReflection ($ this ));
1002
+ } catch (LogicException ) {
1003
+ // Enum case does not have a value
1004
+ }
996
1005
}
997
1006
998
1007
$ attributes = $ this ->attributeReflectionFactory ->fromNativeReflection ($ case ->getAttributes (), InitializerExprContext::fromClass ($ this ->getName (), $ this ->getFileName ()));
0 commit comments