Skip to content

Commit 646f4c4

Browse files
committed
[phpstorm-stubs] Handle 'static' in PhpDoc as declaring class short name
1 parent c79be6d commit 646f4c4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tests/StubsTypeHintsTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,12 @@ public static function testClassesMethodsSignatureTypeHintsConformPhpDocInMethod
500500
fn (string $type) => self::handleTemplateTypes($type, $classTemplateTypes),
501501
)
502502
);
503+
// Treat PhpDoc 'static' as the declaring class short name (e.g., DateTime)
504+
$classShortName = self::getTypePossibleNamespace(ltrim($classId, '\\'));
505+
$unifiedPhpDocTypes = array_map(
506+
static fn (string $t) => $t === 'static' ? $classShortName : $t,
507+
$unifiedPhpDocTypes
508+
);
503509
$unifiedSignatureTypes = array_map(self::getTypePossibleNamespace(...), $function->returnTypesFromSignature);
504510
if (count($unifiedSignatureTypes) === 1) {
505511
$type = array_pop($unifiedSignatureTypes);

0 commit comments

Comments
 (0)