[ErrorHandler] fix parsing return types in DebugClassLoader

This commit is contained in:
Nicolas Grekas 2021-02-02 14:23:37 +01:00
parent 9197199731
commit 58e32b3c2a
3 changed files with 4 additions and 7 deletions

View File

@ -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');
}

View File

@ -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']) {

View File

@ -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);
}