Skip to content

Commit 16a8f17

Browse files
committed
Do not cache ClassReflection in ObjectType, such object cannot be dumped to cache
1 parent dd75630 commit 16a8f17

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/Analyser/MutatingScope.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2146,7 +2146,7 @@ private function resolveType(Expr $node): Type
21462146
}
21472147

21482148
if ($constantClassReflection->isEnum() && $constantClassReflection->hasEnumCase($constantName)) {
2149-
$types[] = new EnumCaseObjectType($constantClassReflection->getName(), $constantName, $constantClassReflection);
2149+
$types[] = new EnumCaseObjectType($constantClassReflection->getName(), $constantName);
21502150
continue;
21512151
}
21522152

src/PhpDoc/TypeNodeResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ private function resolveConstTypeNode(ConstTypeNode $typeNode, NameScope $nameSc
740740
}
741741

742742
if ($classReflection->isEnum() && $classReflection->hasEnumCase($classConstantName)) {
743-
$constantTypes[] = new EnumCaseObjectType($classReflection->getName(), $classConstantName, $classReflection);
743+
$constantTypes[] = new EnumCaseObjectType($classReflection->getName(), $classConstantName);
744744
continue;
745745
}
746746

@@ -759,7 +759,7 @@ private function resolveConstTypeNode(ConstTypeNode $typeNode, NameScope $nameSc
759759
}
760760

761761
if ($classReflection->isEnum() && $classReflection->hasEnumCase($constantName)) {
762-
return new EnumCaseObjectType($classReflection->getName(), $constantName, $classReflection);
762+
return new EnumCaseObjectType($classReflection->getName(), $constantName);
763763
}
764764

765765
return ConstantTypeHelper::getTypeFromValue($classReflection->getConstant($constantName)->getValue());

src/Type/ObjectType.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,32 +1046,32 @@ public function getNakedClassReflection(): ?ClassReflection
10461046
if ($this->classReflection !== null) {
10471047
return $this->classReflection;
10481048
}
1049+
10491050
$reflectionProvider = ReflectionProviderStaticAccessor::getInstance();
10501051
if (!$reflectionProvider->hasClass($this->className)) {
10511052
return null;
10521053
}
10531054

1054-
$this->classReflection = $reflectionProvider->getClass($this->className);
1055-
1056-
return $this->classReflection;
1055+
return $reflectionProvider->getClass($this->className);
10571056
}
10581057

10591058
public function getClassReflection(): ?ClassReflection
10601059
{
10611060
if ($this->classReflection !== null) {
10621061
return $this->classReflection;
10631062
}
1063+
10641064
$reflectionProvider = ReflectionProviderStaticAccessor::getInstance();
10651065
if (!$reflectionProvider->hasClass($this->className)) {
10661066
return null;
10671067
}
10681068

10691069
$classReflection = $reflectionProvider->getClass($this->className);
10701070
if ($classReflection->isGeneric()) {
1071-
return $this->classReflection = $classReflection->withTypes(array_values($classReflection->getTemplateTypeMap()->resolveToBounds()->getTypes()));
1071+
return $classReflection->withTypes(array_values($classReflection->getTemplateTypeMap()->resolveToBounds()->getTypes()));
10721072
}
10731073

1074-
return $this->classReflection = $classReflection;
1074+
return $classReflection;
10751075
}
10761076

10771077
/**

0 commit comments

Comments
 (0)