1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Merge pull request #6667 from SCIF/bugfix-5135-reflectionnamedtype-stub

This commit is contained in:
Bruce Weirdan 2021-10-14 13:26:50 +03:00 committed by GitHub
commit 6abdb092bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 0 deletions

View File

@ -123,3 +123,16 @@ class ReflectionParameter {
public function getType() : ?ReflectionType {}
}
/**
* @psalm-immutable
*/
class ReflectionNamedType extends ReflectionType
{
public function getName(): string {}
/**
* @psalm-assert-if-false class-string $this->getName()
*/
public function isBuiltin(): bool {}
}

View File

@ -1463,6 +1463,17 @@ class AssertAnnotationTest extends TestCase
}
}',
],
'reflectionNameTypeClassStringIfNotBuiltin' => [
'<?php
/** @return class-string|null */
function getPropertyType(\ReflectionProperty $reflectionItem): ?string {
$type = $reflectionItem->getType();
return ($type instanceof \ReflectionNamedType) && !$type->isBuiltin() ? $type->getName() : null;
}',
[],
[],
'7.4',
],
'withHasTypeCall' => [
'<?php
/**