Skip to content

Commit

Permalink
fix ReflectionProperty::getType
Browse files Browse the repository at this point in the history
  • Loading branch information
schlndh committed Sep 15, 2023
1 parent 1da5ae9 commit 13c5f34
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
"jetbrains/phpstorm-stubs": [
"patches/Memcache.patch",
"patches/PDO.patch",
"patches/ReflectionProperty.patch",
"patches/SessionHandler.patch",
"patches/SplHeapExtract.patch"
],
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions patches/ReflectionProperty.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- Reflection/ReflectionProperty.php 2023-09-07 12:59:56.000000000 +0200
+++ Reflection/ReflectionProperty.php 2023-09-15 13:24:07.900736741 +0200
@@ -248,7 +248,7 @@
* Gets property type
*
* @link https://php.net/manual/en/reflectionproperty.gettype.php
- * @return ReflectionNamedType|ReflectionUnionType|null Returns a {@see ReflectionType} if the
+ * @return ReflectionType|null Returns a {@see ReflectionType} if the
* property has a type, and {@see null} otherwise.
* @since 7.4
*/
1 change: 1 addition & 0 deletions tests/PHPStan/Analyser/NodeScopeResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public function dataFileAsserts(): iterable

if (PHP_VERSION_ID >= 70400) {
yield from $this->gatherAssertTypes(__DIR__ . '/data/native-types.php');
yield from $this->gatherAssertTypes(__DIR__ . '/data/reflection-type.php');
}

if (PHP_VERSION_ID >= 80100) {
Expand Down
15 changes: 15 additions & 0 deletions tests/PHPStan/Analyser/data/reflection-type.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace ReflectionTypeTest;

use function PHPStan\Testing\assertType;

function test(
\ReflectionProperty $reflectionProperty,
\ReflectionFunctionAbstract $reflectionFunctionAbstract,
\ReflectionParameter $reflectionParameter
){
assertType('ReflectionType|null', $reflectionProperty->getType());
assertType('ReflectionType|null', $reflectionFunctionAbstract->getReturnType());
assertType('ReflectionType|null', $reflectionParameter->getType());
}

0 comments on commit 13c5f34

Please sign in to comment.