Skip to content

Commit 962a3cf

Browse files
phpstan-botclaude
andcommitted
Fix toPhpDocNode() to use actual type instead of hardcoded 'static'
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1535226 commit 962a3cf

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

src/Type/ClassConstantAccessType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public function traverseSimultaneously(Type $right, callable $cb): Type
129129

130130
public function toPhpDocNode(): TypeNode
131131
{
132-
return new ConstTypeNode(new ConstFetchNode('static', $this->constantName));
132+
return new ConstTypeNode(new ConstFetchNode((string) $this->type->toPhpDocNode(), $this->constantName));
133133
}
134134

135135
}

tests/PHPStan/Type/TypeToPhpDocNodeTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,18 @@ public static function dataToPhpDocNodeWithoutCheckingEquals(): iterable
522522
new ConstantFloatType(-0.0),
523523
'-0.0',
524524
];
525+
526+
$reflectionProvider = self::createReflectionProvider();
527+
528+
yield [
529+
new ClassConstantAccessType(new StaticType($reflectionProvider->getClass(stdClass::class)), 'FOO'),
530+
'static::FOO',
531+
];
532+
533+
yield [
534+
new ClassConstantAccessType(new ObjectType('stdClass'), 'FOO'),
535+
'stdClass::FOO',
536+
];
525537
}
526538

527539
#[DataProvider('dataToPhpDocNodeWithoutCheckingEquals')]

0 commit comments

Comments
 (0)