File tree Expand file tree Collapse file tree 3 files changed +24
-15
lines changed Expand file tree Collapse file tree 3 files changed +24
-15
lines changed Original file line number Diff line number Diff line change @@ -1423,6 +1423,19 @@ public function getAttributeClassFlags(): int
1423
1423
return $ flags ;
1424
1424
}
1425
1425
1426
+ public function getObjectType (): ObjectType
1427
+ {
1428
+ if (!$ this ->isGeneric ()) {
1429
+ return new ObjectType ($ this ->getName ());
1430
+ }
1431
+
1432
+ return new GenericObjectType (
1433
+ $ this ->getName (),
1434
+ $ this ->typeMapToList ($ this ->getActiveTemplateTypeMap ()),
1435
+ variances: $ this ->varianceMapToList ($ this ->getCallSiteVarianceMap ()),
1436
+ );
1437
+ }
1438
+
1426
1439
public function getTemplateTypeMap (): TemplateTypeMap
1427
1440
{
1428
1441
if ($ this ->templateTypeMap !== null ) {
Original file line number Diff line number Diff line change 7
7
use PHPStan \Internal \DeprecatedAttributeHelper ;
8
8
use PHPStan \Reflection \Deprecation \DeprecationProvider ;
9
9
use PHPStan \TrinaryLogic ;
10
+ use PHPStan \Type \Enum \EnumCaseObjectType ;
10
11
use PHPStan \Type \Type ;
11
12
12
13
/**
@@ -55,6 +56,14 @@ public function getName(): string
55
56
return $ this ->reflection ->getName ();
56
57
}
57
58
59
+ public function getEnumCaseObjectType (): EnumCaseObjectType
60
+ {
61
+ return new EnumCaseObjectType (
62
+ $ this ->declaringEnum ->getName (),
63
+ $ this ->getName (),
64
+ );
65
+ }
66
+
58
67
public function getBackingValueType (): ?Type
59
68
{
60
69
return $ this ->backingValueType ;
Original file line number Diff line number Diff line change @@ -133,19 +133,6 @@ public static function resetCaches(): void
133
133
self ::$ enumCases = [];
134
134
}
135
135
136
- private static function createFromReflection (ClassReflection $ reflection ): self
137
- {
138
- if (!$ reflection ->isGeneric ()) {
139
- return new ObjectType ($ reflection ->getName ());
140
- }
141
-
142
- return new GenericObjectType (
143
- $ reflection ->getName (),
144
- $ reflection ->typeMapToList ($ reflection ->getActiveTemplateTypeMap ()),
145
- variances: $ reflection ->varianceMapToList ($ reflection ->getCallSiteVarianceMap ()),
146
- );
147
- }
148
-
149
136
public function getClassName (): string
150
137
{
151
138
return $ this ->className ;
@@ -1639,7 +1626,7 @@ private function getParent(): ?ObjectType
1639
1626
return null ;
1640
1627
}
1641
1628
1642
- return $ this ->cachedParent = self :: createFromReflection ( $ parentReflection );
1629
+ return $ this ->cachedParent = $ parentReflection-> getObjectType ( );
1643
1630
}
1644
1631
1645
1632
/** @return ObjectType[] */
@@ -1653,7 +1640,7 @@ private function getInterfaces(): array
1653
1640
return $ this ->cachedInterfaces = [];
1654
1641
}
1655
1642
1656
- return $ this ->cachedInterfaces = array_map (static fn (ClassReflection $ interfaceReflection ): self => self :: createFromReflection ( $ interfaceReflection ), $ thisReflection ->getInterfaces ());
1643
+ return $ this ->cachedInterfaces = array_map (static fn (ClassReflection $ interfaceReflection ): self => $ interfaceReflection-> getObjectType ( ), $ thisReflection ->getInterfaces ());
1657
1644
}
1658
1645
1659
1646
public function tryRemove (Type $ typeToRemove ): ?Type
You can’t perform that action at this time.
0 commit comments