From 58e32b3c2a3311e770924f118ccf0ac921c7fd78 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 2 Feb 2021 14:23:37 +0100 Subject: [PATCH] [ErrorHandler] fix parsing return types in DebugClassLoader --- phpunit | 3 --- src/Symfony/Component/ErrorHandler/DebugClassLoader.php | 4 ++-- .../Core/Tests/Authentication/Token/AbstractTokenTest.php | 4 ++-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/phpunit b/phpunit index 9141d249d2..619ba4674a 100755 --- a/phpunit +++ b/phpunit @@ -16,9 +16,6 @@ if (!getenv('SYMFONY_PHPUNIT_VERSION')) { putenv('SYMFONY_PHPUNIT_VERSION=9.5'); } } -if (!getenv('SYMFONY_PATCH_TYPE_DECLARATIONS')) { - putenv('SYMFONY_PATCH_TYPE_DECLARATIONS=deprecations=1'); -} if (getcwd() === realpath(__DIR__.'/src/Symfony/Bridge/PhpUnit')) { putenv('SYMFONY_DEPRECATIONS_HELPER=disabled'); } diff --git a/src/Symfony/Component/ErrorHandler/DebugClassLoader.php b/src/Symfony/Component/ErrorHandler/DebugClassLoader.php index c9587b482c..e5e6bb7a5b 100644 --- a/src/Symfony/Component/ErrorHandler/DebugClassLoader.php +++ b/src/Symfony/Component/ErrorHandler/DebugClassLoader.php @@ -535,7 +535,7 @@ class DebugClassLoader if (null !== (self::INTERNAL_TYPES[$use] ?? null)) { foreach (self::INTERNAL_TYPES[$use] as $method => $returnType) { if ('void' !== $returnType) { - self::$returnTypes[$class] += [$method => [$returnType, $returnType, $class, '']]; + self::$returnTypes[$class] += [$method => [$returnType, $returnType, $use, '']]; } } } @@ -612,7 +612,7 @@ class DebugClassLoader $this->patchMethod($method, $returnType, $declaringFile, $normalizedType); } - if (strncmp($ns, $declaringClass, $len)) { + if (false === strpos($doc, '@deprecated') && strncmp($ns, $declaringClass, $len)) { if ($canAddReturnType && 'docblock' === $this->patchTypes['force'] && false === strpos($method->getFileName(), \DIRECTORY_SEPARATOR.'vendor'.\DIRECTORY_SEPARATOR)) { $this->patchMethod($method, $returnType, $declaringFile, $normalizedType); } elseif ('' !== $declaringClass && $this->patchTypes['deprecations']) { diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php index 17984b86d9..b1e7993de7 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php @@ -320,12 +320,12 @@ class SerializableUser implements UserInterface, \Serializable return null; } - public function serialize() + public function serialize(): string { return serialize($this->name); } - public function unserialize($serialized) + public function unserialize($serialized): void { $this->name = unserialize($serialized); }