From 5ac3ef73c2f747346f0d3962c51edaf42f161ea5 Mon Sep 17 00:00:00 2001 From: Jack Worman Date: Sun, 18 Dec 2022 14:35:28 -0600 Subject: [PATCH] Reflection class stub updates --- stubs/Php80.phpstub | 2 -- stubs/Reflection.phpstub | 17 +++++++++-------- tests/ReflectionTest.php | 11 +++++++++++ 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/stubs/Php80.phpstub b/stubs/Php80.phpstub index c9da1534a03..e26dffef45b 100644 --- a/stubs/Php80.phpstub +++ b/stubs/Php80.phpstub @@ -92,7 +92,6 @@ class ReflectionClass implements Reflector { * @template J as object * @param self|class-string $class * @psalm-assert-if-true self $this - * * @psalm-pure */ public function isSubclassOf(self|string $class): bool {} @@ -101,7 +100,6 @@ class ReflectionClass implements Reflector { * @template J as object * @param self|interface-string $interface * @psalm-assert-if-true self $this - * * @psalm-pure */ public function implementsInterface(self|string $interface): bool {} diff --git a/stubs/Reflection.phpstub b/stubs/Reflection.phpstub index b44d37620e4..9264e58dca4 100644 --- a/stubs/Reflection.phpstub +++ b/stubs/Reflection.phpstub @@ -147,15 +147,13 @@ class ReflectionClass implements Reflector { public function getReflectionConstants(?int $filter = null): array {} /** - * @return array - * + * @return array * @psalm-pure */ public function getInterfaces(): array {} /** - * @return list - * + * @return list * @psalm-pure */ public function getInterfaceNames(): array {} @@ -192,7 +190,12 @@ class ReflectionClass implements Reflector { */ public function getModifiers(): bool {} - /** @psalm-pure */ + /** + * @template J as object + * @param J $object + * @psalm-assert-if-true T&J $object + * @psalm-pure + */ public function isInstance(object $object): bool {} /** @@ -225,7 +228,6 @@ class ReflectionClass implements Reflector { * @template J as object * @param self|class-string $class * @psalm-assert-if-true self $this - * * @psalm-pure */ public function isSubclassOf($class): bool {} @@ -250,7 +252,6 @@ class ReflectionClass implements Reflector { * @template J as object * @param self|interface-string $interface * @psalm-assert-if-true self $this - * * @psalm-pure */ public function implementsInterface($interface): bool {} @@ -279,7 +280,7 @@ class ReflectionClass implements Reflector { public function getShortName(): string {} /** - * @return ?array + * @return ?list * @psalm-ignore-nullable-return * @psalm-pure */ diff --git a/tests/ReflectionTest.php b/tests/ReflectionTest.php index b8e7bb998a4..fb6e54cb387 100644 --- a/tests/ReflectionTest.php +++ b/tests/ReflectionTest.php @@ -32,5 +32,16 @@ public function providerValidCodeParse(): iterable PHP, 'assertions' => ['$a===' => 'ReflectionClass'], ]; + yield 'ReflectionClass::isInstance' => [ + 'code' => <<<'PHP' + isInstance($a)) { + throw new Exception(); + } + PHP, + 'assertions' => ['$a===' => 'Iterator&stdClass'], + ]; } }