From 929231607371b925390e2944d81cc7152fc94042 Mon Sep 17 00:00:00 2001 From: Bruce Weirdan Date: Sun, 24 Jan 2021 20:31:10 +0200 Subject: [PATCH] Remove ReflectionType::getName(), move ReflectionType::isBuiltin() (#5090) * Remove ReflectionType::getName(), move ReflectionType::isBuiltin() * `ReflectionType::getName()` was never there: https://3v4l.org/1iZt4 * `ReflectionType::isBuiltin()` was moved to `ReflectionNamedType::isBuiltin()` in PHP 8 Fixes vimeo/psalm#5089 * Fix test * Mark test as php 8.0 only --- dictionaries/CallMap.php | 6 ++---- dictionaries/CallMap_80_delta.php | 2 ++ tests/MethodCallTest.php | 13 ++++++++++++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/dictionaries/CallMap.php b/dictionaries/CallMap.php index 44bff21cd..dddad1e63 100644 --- a/dictionaries/CallMap.php +++ b/dictionaries/CallMap.php @@ -11479,9 +11479,9 @@ return [ 'ReflectionMethod::setAccessible' => ['void', 'visible'=>'bool'], 'ReflectionNamedType::__clone' => ['void'], 'ReflectionNamedType::__toString' => ['string'], -'ReflectionNamedType::allowsNull' => [''], +'ReflectionNamedType::allowsNull' => ['bool'], 'ReflectionNamedType::getName' => ['string'], -'ReflectionNamedType::isBuiltin' => [''], +'ReflectionNamedType::isBuiltin' => ['bool'], 'ReflectionObject::__clone' => ['void'], 'ReflectionObject::__construct' => ['void', 'argument'=>'object'], 'ReflectionObject::__toString' => ['string'], @@ -11579,8 +11579,6 @@ return [ 'ReflectionType::__clone' => ['void'], 'ReflectionType::__toString' => ['string'], 'ReflectionType::allowsNull' => ['bool'], -'ReflectionType::getName' => ['string'], -'ReflectionType::isBuiltin' => ['bool'], 'ReflectionZendExtension::__clone' => ['void'], 'ReflectionZendExtension::__construct' => ['void', 'name'=>'string'], 'ReflectionZendExtension::__toString' => ['string'], diff --git a/dictionaries/CallMap_80_delta.php b/dictionaries/CallMap_80_delta.php index 728cdc292..c3ad12e2c 100644 --- a/dictionaries/CallMap_80_delta.php +++ b/dictionaries/CallMap_80_delta.php @@ -100,6 +100,7 @@ return [ 'PhpToken::is' => ['bool', 'kind'=>'string|int|string[]|int[]'], 'PhpToken::isIgnorable' => ['bool'], 'PhpToken::getTokenName' => ['string'], +'ReflectionNamedType::isBuiltin' => ['bool'], 'proc_get_status' => ['array', 'process'=>'resource'], 'socket_accept' => ['Socket|false', 'socket'=>'Socket'], 'socket_addrinfo_bind' => ['?Socket', 'addrinfo'=>'AddressInfo'], @@ -289,6 +290,7 @@ return [ 'png2wbmp' => ['bool', 'pngname'=>'string', 'wbmpname'=>'string', 'dest_height'=>'int', 'dest_width'=>'int', 'threshold'=>'int'], 'proc_get_status' => ['array|false', 'process'=>'resource'], 'read_exif_data' => ['array', 'filename'=>'string', 'sections_needed='=>'string', 'sub_arrays='=>'bool', 'read_thumbnail='=>'bool'], +'ReflectionType::isBuiltin' => ['bool'], 'socket_addrinfo_lookup' => ['resource[]', 'node'=>'string', 'service='=>'mixed', 'hints='=>'array'], 'socket_accept' => ['resource|false', 'socket'=>'resource'], 'socket_addrinfo_bind' => ['?resource', 'addrinfo'=>'resource'], diff --git a/tests/MethodCallTest.php b/tests/MethodCallTest.php index dc176c2b4..2a35ac7fc 100644 --- a/tests/MethodCallTest.php +++ b/tests/MethodCallTest.php @@ -402,8 +402,19 @@ class MethodCallTest extends TestCase return "mixed"; } - return $type->getName(); + if ($type instanceof ReflectionUnionType) { + return "union"; + } + + if ($type instanceof ReflectionNamedType) { + return $type->getName(); + } + + throw new RuntimeException("unexpected type"); }', + 'assertions' => [], + 'error_levels' => [], + 'php_version' => '8.0' ], 'PDOMethod' => [ '