Skip to content

Commit 3da993b

Browse files
committed
Better fixes
1 parent 0c18bb9 commit 3da993b

File tree

3 files changed

+3
-10
lines changed

3 files changed

+3
-10
lines changed

src/Analyser/MutatingScope.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3012,13 +3012,10 @@ private function transformStaticType(Type $type): Type
30123012
if (!$this->isInClass()) {
30133013
return $type;
30143014
}
3015-
if ($type instanceof ThisType) {
3016-
return $traverse($type);
3017-
}
30183015
if ($type instanceof StaticType) {
30193016
$classReflection = $this->getClassReflection();
30203017
$changedType = $type->changeBaseClass($classReflection);
3021-
if ($classReflection->isFinal()) {
3018+
if ($classReflection->isFinal() && !$type instanceof ThisType) {
30223019
$changedType = $changedType->getStaticObjectType();
30233020
}
30243021
return $traverse($changedType);

src/Analyser/NodeScopeResolver.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6157,13 +6157,9 @@ public function getPhpDocs(Scope $scope, Node\FunctionLike|Node\Stmt\Property $n
61576157
private function transformStaticType(ClassReflection $declaringClass, Type $type): Type
61586158
{
61596159
return TypeTraverser::map($type, static function (Type $type, callable $traverse) use ($declaringClass): Type {
6160-
if ($type instanceof ThisType) {
6161-
return $traverse($type);
6162-
}
6163-
61646160
if ($type instanceof StaticType) {
61656161
$changedType = $type->changeBaseClass($declaringClass);
6166-
if ($declaringClass->isFinal()) {
6162+
if ($declaringClass->isFinal() && !$type instanceof ThisType) {
61676163
$changedType = $changedType->getStaticObjectType();
61686164
}
61696165
return $traverse($changedType);

src/Type/StaticType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ private function transformStaticType(Type $type, ClassMemberAccessAnswerer $scop
299299
$isFinal = $classReflection->isFinal();
300300
}
301301
$type = $type->changeBaseClass($classReflection);
302-
if (!$isFinal) {
302+
if (!$isFinal || $type instanceof ThisType) {
303303
return $type;
304304
}
305305

0 commit comments

Comments
 (0)