File tree Expand file tree Collapse file tree 2 files changed +5
-30
lines changed
tests/PHPStan/Analyser/nsrt Expand file tree Collapse file tree 2 files changed +5
-30
lines changed Original file line number Diff line number Diff line change @@ -51,36 +51,11 @@ public function isResolvable(): bool
5151
5252 protected function getResult (): Type
5353 {
54- $ classReflections = $ this ->type ->getObjectClassReflections ();
55- if (count ($ classReflections ) !== 1 ) {
56- if (!$ this ->type ->hasConstant ($ this ->constantName )->yes ()) {
57- return new ErrorType ();
58- }
59-
54+ if ($ this ->type ->hasConstant ($ this ->constantName )->yes ()) {
6055 return $ this ->type ->getConstant ($ this ->constantName )->getValueType ();
6156 }
6257
63- $ constantClassReflection = $ classReflections [0 ];
64- if (!$ constantClassReflection ->hasConstant ($ this ->constantName )) {
65- return new ErrorType ();
66- }
67-
68- if ($ constantClassReflection ->isEnum () && $ constantClassReflection ->hasEnumCase ($ this ->constantName )) {
69- return new Enum \EnumCaseObjectType ($ constantClassReflection ->getName (), $ this ->constantName );
70- }
71-
72- $ constantReflection = $ constantClassReflection ->getConstant ($ this ->constantName );
73-
74- if (
75- !$ constantClassReflection ->isFinal ()
76- && !$ constantReflection ->isFinal ()
77- && !$ constantReflection ->hasPhpDocType ()
78- && !$ constantReflection ->hasNativeType ()
79- ) {
80- return new MixedType ();
81- }
82-
83- return $ constantReflection ->getValueType ();
58+ return new ErrorType ();
8459 }
8560
8661 /**
Original file line number Diff line number Diff line change @@ -22,8 +22,8 @@ class BarBaz extends FooBar
2222
2323function test (FooBar $ foo , BarBaz $ bar ): void
2424{
25- assertType (' mixed ' , $ foo ->test ());
26- assertType (' mixed ' , $ bar ->test ());
25+ assertType (" 'foo' " , $ foo ->test ());
26+ assertType (" 'bar' " , $ bar ->test ());
2727}
2828
2929final class FinalFoo
@@ -146,7 +146,7 @@ public function test(): string
146146
147147function testUntypedConstant (WithUntypedConstant $ foo ): void
148148{
149- assertType (' mixed ' , $ foo ->test ());
149+ assertType (" 'foo' " , $ foo ->test ());
150150}
151151
152152final class FinalChild extends FooBar
You can’t perform that action at this time.
0 commit comments