From 10fc13e4a7ebdc3acb4a072eaa1e690ac265da14 Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Wed, 20 Feb 2019 18:42:11 +0100 Subject: [PATCH 1/2] [ErrorHandler] Handle return types in DebugClassLoader --- .../ErrorHandler/DebugClassLoader.php | 283 +++++++++++++++++- .../Tests/DebugClassLoaderTest.php | 38 +++ .../Tests/Fixtures/OutsideInterface.php | 11 + .../Tests/Fixtures/ReturnType.php | 46 +++ .../Tests/Fixtures/ReturnTypeGrandParent.php | 13 + .../Tests/Fixtures/ReturnTypeInterface.php | 11 + .../Tests/Fixtures/ReturnTypeParent.php | 201 +++++++++++++ .../Fixtures/ReturnTypeParentInterface.php | 11 + 8 files changed, 602 insertions(+), 12 deletions(-) create mode 100644 src/Symfony/Component/ErrorHandler/Tests/Fixtures/OutsideInterface.php create mode 100644 src/Symfony/Component/ErrorHandler/Tests/Fixtures/ReturnType.php create mode 100644 src/Symfony/Component/ErrorHandler/Tests/Fixtures/ReturnTypeGrandParent.php create mode 100644 src/Symfony/Component/ErrorHandler/Tests/Fixtures/ReturnTypeInterface.php create mode 100644 src/Symfony/Component/ErrorHandler/Tests/Fixtures/ReturnTypeParent.php create mode 100644 src/Symfony/Component/ErrorHandler/Tests/Fixtures/ReturnTypeParentInterface.php diff --git a/src/Symfony/Component/ErrorHandler/DebugClassLoader.php b/src/Symfony/Component/ErrorHandler/DebugClassLoader.php index eec3c7051e11..5819261e1f2e 100644 --- a/src/Symfony/Component/ErrorHandler/DebugClassLoader.php +++ b/src/Symfony/Component/ErrorHandler/DebugClassLoader.php @@ -27,6 +27,43 @@ */ class DebugClassLoader { + private const SPECIAL_RETURN_TYPES = [ + 'mixed' => 'mixed', + 'void' => 'void', + 'null' => 'null', + 'resource' => 'resource', + 'static' => 'object', + '$this' => 'object', + 'boolean' => 'bool', + 'true' => 'bool', + 'false' => 'bool', + 'integer' => 'int', + 'array' => 'array', + 'bool' => 'bool', + 'callable' => 'callable', + 'float' => 'float', + 'int' => 'integer', + 'iterable' => 'iterable', + 'object' => 'object', + 'string' => 'string', + 'self' => 'self', + 'parent' => 'parent', + ]; + + private const BUILTIN_RETURN_TYPES = [ + 'void' => true, + 'array' => true, + 'bool' => true, + 'callable' => true, + 'float' => true, + 'int' => true, + 'iterable' => true, + 'object' => true, + 'string' => true, + 'self' => true, + 'parent' => true, + ]; + private $classLoader; private $isFinder; private $loaded = []; @@ -40,6 +77,8 @@ class DebugClassLoader private static $annotatedParameters = []; private static $darwinCache = ['/' => ['/', []]]; private static $method = []; + private static $returnTypes = []; + private static $methodTraits = []; public function __construct(callable $classLoader) { @@ -218,11 +257,11 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array $deprecations = []; // Don't trigger deprecations for classes in the same vendor - if (2 > $len = 1 + (strpos($class, '\\') ?: strpos($class, '_'))) { - $len = 0; - $ns = ''; + if (2 > $vendorLen = 1 + (strpos($class, '\\') ?: strpos($class, '_'))) { + $vendorLen = 0; + $vendor = ''; } else { - $ns = str_replace('_', '\\', substr($class, 0, $len)); + $vendor = str_replace('_', '\\', substr($class, 0, $vendorLen)); } // Detect annotations on the class @@ -252,7 +291,7 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array } } - $parent = get_parent_class($class); + $parent = get_parent_class($class) ?: null; $parentAndOwnInterfaces = $this->getOwnInterfaces($class, $parent); if ($parent) { $parentAndOwnInterfaces[$parent] = $parent; @@ -271,13 +310,13 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array if (!isset(self::$checkedClasses[$use])) { $this->checkClass($use); } - if (isset(self::$deprecated[$use]) && strncmp($ns, str_replace('_', '\\', $use), $len) && !isset(self::$deprecated[$class])) { + if (isset(self::$deprecated[$use]) && strncmp($vendor, str_replace('_', '\\', $use), $vendorLen) && !isset(self::$deprecated[$class])) { $type = class_exists($class, false) ? 'class' : (interface_exists($class, false) ? 'interface' : 'trait'); $verb = class_exists($use, false) || interface_exists($class, false) ? 'extends' : (interface_exists($use, false) ? 'implements' : 'uses'); $deprecations[] = sprintf('The "%s" %s %s "%s" that is deprecated%s.', $class, $type, $verb, $use, self::$deprecated[$use]); } - if (isset(self::$internal[$use]) && strncmp($ns, str_replace('_', '\\', $use), $len)) { + if (isset(self::$internal[$use]) && strncmp($vendor, str_replace('_', '\\', $use), $vendorLen)) { $deprecations[] = sprintf('The "%s" %s is considered internal%s. It may change without further notice. You should not use it from "%s".', $use, class_exists($use, false) ? 'class' : (interface_exists($use, false) ? 'interface' : 'trait'), self::$internal[$use], $class); } if (isset(self::$method[$use])) { @@ -305,15 +344,24 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array } if (trait_exists($class)) { + $file = $refl->getFileName(); + + foreach ($refl->getMethods(\ReflectionMethod::IS_PUBLIC | \ReflectionMethod::IS_PROTECTED) as $method) { + if ($method->getFileName() === $file) { + self::$methodTraits[$file][$method->getStartLine()] = $class; + } + } + return $deprecations; } - // Inherit @final, @internal and @param annotations for methods + // Inherit @final, @internal, @param and @return annotations for methods self::$finalMethods[$class] = []; self::$internalMethods[$class] = []; self::$annotatedParameters[$class] = []; + self::$returnTypes[$class] = []; foreach ($parentAndOwnInterfaces as $use) { - foreach (['finalMethods', 'internalMethods', 'annotatedParameters'] as $property) { + foreach (['finalMethods', 'internalMethods', 'annotatedParameters', 'returnTypes'] as $property) { if (isset(self::${$property}[$use])) { self::${$property}[$class] = self::${$property}[$class] ? self::${$property}[$use] + self::${$property}[$class] : self::${$property}[$use]; } @@ -325,6 +373,16 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array continue; } + if (null === $ns = self::$methodTraits[$method->getFileName()][$method->getStartLine()] ?? null) { + $ns = $vendor; + $len = $vendorLen; + } elseif (2 > $len = 1 + (strpos($ns, '\\') ?: strpos($ns, '_'))) { + $len = 0; + $ns = ''; + } else { + $ns = str_replace('_', '\\', substr($ns, 0, $len)); + } + if ($parent && isset(self::$finalMethods[$parent][$method->name])) { list($declaringClass, $message) = self::$finalMethods[$parent][$method->name]; $deprecations[] = sprintf('The "%s::%s()" method is considered final%s. It may change without further notice as of its next major version. You should not extend it from "%s".', $declaringClass, $method->name, $message, $class); @@ -353,10 +411,26 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array } } + if (isset(self::$returnTypes[$class][$method->name]) && !$method->hasReturnType() && !($doc && preg_match('/\n\s+\* @return +(\S+)/', $doc))) { + list($returnType, $declaringClass, $declaringFile) = self::$returnTypes[$class][$method->name]; + + if (strncmp($ns, $declaringClass, $len)) { + //if (0 === strpos($class, 'Symfony\\')) { + // self::patchMethod($method, $returnType, $declaringFile); + //} + + $deprecations[] = sprintf('Method "%s::%s()" will return "%s" as of its next major version. Doing the same in child class "%s" will be required when upgrading.', $declaringClass, $method->name, $returnType, $class); + } + } + if (!$doc) { continue; } + if (!$method->hasReturnType() && false !== strpos($doc, '@return') && preg_match('/\n\s+\* @return +(\S+)/', $doc, $matches)) { + $this->setReturnType($matches[1], $method, $parent); + } + $finalOrInternal = false; foreach (['final', 'internal'] as $annotation) { @@ -496,11 +570,9 @@ private function darwinRealpath(string $real): string /** * `class_implements` includes interfaces from the parents so we have to manually exclude them. * - * @param string|false $parent - * * @return string[] */ - private function getOwnInterfaces(string $class, $parent): array + private function getOwnInterfaces(string $class, ?string $parent): array { $ownInterfaces = class_implements($class, false); @@ -518,4 +590,191 @@ private function getOwnInterfaces(string $class, $parent): array return $ownInterfaces; } + + private function setReturnType(string $types, \ReflectionMethod $method, ?string $parent): void + { + $nullable = false; + $typesMap = []; + foreach (explode('|', $types) as $t) { + $t = $this->normalizeType($t, $method->class, $parent); + $typesMap[strtolower($t)] = $t; + } + + if (isset($typesMap['array']) && isset($typesMap['iterable'])) { + if ('[]' === substr($typesMap['array'], -2)) { + $typesMap['iterable'] = $typesMap['array']; + } + unset($typesMap['array']); + } + + $normalizedType = key($typesMap); + $returnType = current($typesMap); + + foreach ($typesMap as $n => $t) { + if ('null' === $n) { + $nullable = true; + } elseif ('null' === $normalizedType) { + $normalizedType = $t; + $returnType = $t; + } elseif ($n !== $normalizedType) { + // ignore multi-types return declarations + return; + } + } + + if ('void' === $normalizedType) { + $nullable = false; + } elseif (!isset(self::BUILTIN_RETURN_TYPES[$normalizedType]) && isset(self::SPECIAL_RETURN_TYPES[$normalizedType])) { + // ignore other special return types + return; + } + + if ($nullable) { + $returnType = '?'.$returnType; + } + + self::$returnTypes[$method->class][$method->name] = [$returnType, $method->class, $method->getFileName()]; + } + + private function normalizeType(string $type, string $class, ?string $parent): string + { + if (isset(self::SPECIAL_RETURN_TYPES[$lcType = strtolower($type)])) { + if ('parent' === $lcType = self::SPECIAL_RETURN_TYPES[$lcType]) { + $lcType = null !== $parent ? '\\'.$parent : 'parent'; + } elseif ('self' === $lcType) { + $lcType = '\\'.$class; + } + + return $lcType; + } + + if ('[]' === substr($type, -2)) { + return 'array'; + } + + if (preg_match('/^(array|iterable|callable) *[<(]/', $lcType, $m)) { + return $m[1]; + } + + // We could resolve "use" statements to return the FQDN + // but this would be too expensive for a runtime checker + + return $type; + } + + /** + * Utility method to add @return annotations to the Symfony code-base where it triggers a self-deprecations. + */ + private static function patchMethod(\ReflectionMethod $method, string $returnType, string $declaringFile) + { + static $patchedMethods = []; + static $useStatements = []; + + if (!file_exists($file = $method->getFileName()) || isset($patchedMethods[$file][$startLine = $method->getStartLine()])) { + return; + } + + $patchedMethods[$file][$startLine] = true; + $patchedMethods[$file][0] = $patchedMethods[$file][0] ?? 0; + $startLine += $patchedMethods[$file][0] - 2; + $nullable = '?' === $returnType[0] ? '?' : ''; + $returnType = ltrim($returnType, '?'); + $code = file($file); + + if (!isset(self::BUILTIN_RETURN_TYPES[$returnType]) && ('\\' !== $returnType[0] || $p = strrpos($returnType, '\\', 1))) { + list($namespace, $useOffset, $useMap) = $useStatements[$file] ?? $useStatements[$file] = self::getUseStatements($file); + + if ('\\' !== $returnType[0]) { + list($declaringNamespace, , $declaringUseMap) = $useStatements[$declaringFile] ?? $useStatements[$declaringFile] = self::getUseStatements($declaringFile); + + $p = strpos($returnType, '\\', 1); + $alias = $p ? substr($returnType, 0, $p) : $returnType; + + if (isset($declaringUseMap[$alias])) { + $returnType = '\\'.$declaringUseMap[$alias].($p ? substr($returnType, $p) : ''); + } else { + $returnType = '\\'.$declaringNamespace.$returnType; + } + + $p = strrpos($returnType, '\\', 1); + } + + $alias = substr($returnType, 1 + $p); + $returnType = substr($returnType, 1); + + if (!isset($useMap[$alias]) && (class_exists($c = $namespace.$alias) || interface_exists($c) || trait_exists($c))) { + $useMap[$alias] = $c; + } + + if (!isset($useMap[$alias])) { + $useStatements[$file][2][$alias] = $returnType; + $code[$useOffset] = "use $returnType;\n".$code[$useOffset]; + ++$patchedMethods[$file][0]; + } elseif ($useMap[$alias] !== $returnType) { + $alias .= 'FIXME'; + $useStatements[$file][2][$alias] = $returnType; + $code[$useOffset] = "use $returnType as $alias;\n".$code[$useOffset]; + ++$patchedMethods[$file][0]; + } + + $returnType = $alias; + } + + if ($method->getDocComment()) { + $code[$startLine] = " * @return $nullable$returnType\n".$code[$startLine]; + } else { + $code[$startLine] .= <<assertTrue(class_exists(__NAMESPACE__.'\Fixtures\DefinitionInEvaluatedCode', true)); } + + public function testReturnType() + { + $deprecations = []; + set_error_handler(function ($type, $msg) use (&$deprecations) { $deprecations[] = $msg; }); + $e = error_reporting(E_USER_DEPRECATED); + + class_exists('Test\\'.__NAMESPACE__.'\\ReturnType', true); + + error_reporting($e); + restore_error_handler(); + + $this->assertSame([ + 'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeGrandParent::returnTypeGrandParent()" will return "string" as of its next major version. Doing the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" will be required when upgrading.', + 'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParentInterface::returnTypeParentInterface()" will return "string" as of its next major version. Doing the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" will be required when upgrading.', + 'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeInterface::returnTypeInterface()" will return "string" as of its next major version. Doing the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" will be required when upgrading.', + 'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParent::oneNonNullableReturnableType()" will return "void" as of its next major version. Doing the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" will be required when upgrading.', + 'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParent::oneNonNullableReturnableTypeWithNull()" will return "void" as of its next major version. Doing the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" will be required when upgrading.', + 'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParent::oneNullableReturnableType()" will return "array" as of its next major version. Doing the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" will be required when upgrading.', + 'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParent::oneNullableReturnableTypeWithNull()" will return "?bool" as of its next major version. Doing the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" will be required when upgrading.', + 'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParent::oneOtherType()" will return "\ArrayIterator" as of its next major version. Doing the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" will be required when upgrading.', + 'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParent::oneOtherTypeWithNull()" will return "?\ArrayIterator" as of its next major version. Doing the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" will be required when upgrading.', + 'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParent::manyIterables()" will return "array" as of its next major version. Doing the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" will be required when upgrading.', + 'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParent::nullableReturnableTypeNormalization()" will return "object" as of its next major version. Doing the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" will be required when upgrading.', + 'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParent::nonNullableReturnableTypeNormalization()" will return "void" as of its next major version. Doing the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" will be required when upgrading.', + 'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParent::commonNonObjectReturnedTypeNormalization()" will return "object" as of its next major version. Doing the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" will be required when upgrading.', + 'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParent::bracketsNormalization()" will return "array" as of its next major version. Doing the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" will be required when upgrading.', + 'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParent::booleanNormalization()" will return "bool" as of its next major version. Doing the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" will be required when upgrading.', + 'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParent::callableNormalization1()" will return "callable" as of its next major version. Doing the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" will be required when upgrading.', + 'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParent::callableNormalization2()" will return "callable" as of its next major version. Doing the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" will be required when upgrading.', + 'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParent::otherTypeNormalization()" will return "\ArrayIterator" as of its next major version. Doing the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" will be required when upgrading.', + 'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParent::arrayWithLessThanSignNormalization()" will return "array" as of its next major version. Doing the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" will be required when upgrading.', + ], $deprecations); + } } class ClassLoader @@ -435,6 +469,10 @@ public function ownAbstractBaseMethod() { } } elseif ('Test\\'.__NAMESPACE__.'\ExtendsVirtualMagicCall' === $class) { eval('namespace Test\\'.__NAMESPACE__.'; class ExtendsVirtualMagicCall extends \\'.__NAMESPACE__.'\Fixtures\VirtualClassMagicCall implements \\'.__NAMESPACE__.'\Fixtures\VirtualInterface { }'); + } elseif ('Test\\'.__NAMESPACE__.'\ReturnType' === $class) { + return $fixtureDir.\DIRECTORY_SEPARATOR.'ReturnType.php'; + } elseif ('Test\\'.__NAMESPACE__.'\Fixtures\OutsideInterface' === $class) { + return $fixtureDir.\DIRECTORY_SEPARATOR.'OutsideInterface.php'; } } } diff --git a/src/Symfony/Component/ErrorHandler/Tests/Fixtures/OutsideInterface.php b/src/Symfony/Component/ErrorHandler/Tests/Fixtures/OutsideInterface.php new file mode 100644 index 000000000000..43989a9060ab --- /dev/null +++ b/src/Symfony/Component/ErrorHandler/Tests/Fixtures/OutsideInterface.php @@ -0,0 +1,11 @@ + + */ + public function arrayWithLessThanSignNormalization() + { + } + + /** + * @return int + */ + public function notExtended() + { + } +} diff --git a/src/Symfony/Component/ErrorHandler/Tests/Fixtures/ReturnTypeParentInterface.php b/src/Symfony/Component/ErrorHandler/Tests/Fixtures/ReturnTypeParentInterface.php new file mode 100644 index 000000000000..d63e31165d11 --- /dev/null +++ b/src/Symfony/Component/ErrorHandler/Tests/Fixtures/ReturnTypeParentInterface.php @@ -0,0 +1,11 @@ + Date: Mon, 12 Aug 2019 13:50:52 +0200 Subject: [PATCH 2/2] Import return annotations from vendors --- .../Doctrine/ContainerAwareEventManager.php | 10 ++ .../Bridge/Doctrine/Logger/DbalLogger.php | 4 + .../Bridge/Doctrine/ManagerRegistry.php | 4 + .../Doctrine/Test/TestRepositoryFactory.php | 2 + .../Tests/Fixtures/Type/StringWrapperType.php | 2 + .../PropertyInfo/Fixtures/DoctrineFooType.php | 6 + .../Monolog/Handler/ChromePhpHandler.php | 2 + .../Bridge/Monolog/Handler/ConsoleHandler.php | 9 ++ .../HttpCodeActivationStrategy.php | 3 + .../NotFoundActivationStrategy.php | 3 + .../Bridge/Monolog/Handler/FirePHPHandler.php | 2 + .../Monolog/Handler/ServerLogHandler.php | 5 + .../LazyLoadingValueHolderGenerator.php | 2 + .../Bridge/Twig/Extension/AssetExtension.php | 2 + .../Bridge/Twig/Extension/CodeExtension.php | 2 + .../Bridge/Twig/Extension/DumpExtension.php | 7 ++ .../Twig/Extension/ExpressionExtension.php | 2 + .../Bridge/Twig/Extension/FormExtension.php | 9 ++ .../Extension/HttpFoundationExtension.php | 2 + .../Twig/Extension/HttpKernelExtension.php | 3 + .../Twig/Extension/LogoutUrlExtension.php | 2 + .../Twig/Extension/RoutingExtension.php | 2 + .../Twig/Extension/SecurityExtension.php | 2 + .../Twig/Extension/StopwatchExtension.php | 4 + .../Twig/Extension/TranslationExtension.php | 4 + .../Twig/Extension/WebLinkExtension.php | 2 + .../Twig/Extension/WorkflowExtension.php | 3 + .../Bridge/Twig/Extension/YamlExtension.php | 2 + .../TranslationDefaultDomainNodeVisitor.php | 4 + .../NodeVisitor/TranslationNodeVisitor.php | 4 + .../Twig/TokenParser/DumpTokenParser.php | 5 + .../Twig/TokenParser/StopwatchTokenParser.php | 7 ++ .../TokenParser/TransChoiceTokenParser.php | 5 + .../TransDefaultDomainTokenParser.php | 5 + .../Twig/TokenParser/TransTokenParser.php | 5 + .../Routing/LegacyRouteLoaderContainer.php | 2 + .../TwigBundle/Loader/FilesystemLoader.php | 2 + .../Twig/WebProfilerExtension.php | 2 + .../Cache/Adapter/AbstractAdapter.php | 2 + .../Cache/Adapter/AbstractTagAwareAdapter.php | 4 + .../Cache/Adapter/AdapterInterface.php | 2 + .../Component/Cache/Adapter/ArrayAdapter.php | 8 ++ .../Component/Cache/Adapter/ChainAdapter.php | 14 +++ .../Component/Cache/Adapter/NullAdapter.php | 14 +++ .../Cache/Adapter/PhpArrayAdapter.php | 12 ++ .../Component/Cache/Adapter/ProxyAdapter.php | 14 +++ .../Cache/Adapter/TagAwareAdapter.php | 14 +++ .../Cache/Adapter/TraceableAdapter.php | 14 +++ src/Symfony/Component/Cache/CacheItem.php | 10 ++ .../Component/Cache/DoctrineProvider.php | 10 ++ src/Symfony/Component/Cache/Psr16Cache.php | 14 +++ .../Component/Cache/Simple/AbstractCache.php | 8 ++ .../Component/Cache/Simple/ArrayCache.php | 8 ++ .../Component/Cache/Simple/ChainCache.php | 14 +++ .../Component/Cache/Simple/NullCache.php | 14 +++ .../Component/Cache/Simple/PhpArrayCache.php | 12 ++ .../Component/Cache/Simple/TraceableCache.php | 14 +++ .../Cache/Tests/Adapter/ProxyAdapterTest.php | 4 + .../Cache/Tests/Fixtures/ArrayCache.php | 15 +++ .../Cache/Tests/Fixtures/ExternalAdapter.php | 27 +++++ .../Cache/Tests/Simple/CacheTestCase.php | 3 + .../Cache/Traits/AbstractAdapterTrait.php | 4 + .../Component/Cache/Traits/AbstractTrait.php | 8 ++ .../Component/Cache/Traits/ArrayTrait.php | 6 + .../Component/Cache/Traits/PhpArrayTrait.php | 2 + .../Console/Logger/ConsoleLogger.php | 2 + .../Component/Debug/BufferingLogger.php | 3 + .../ErrorHandler/DebugClassLoader.php | 111 +++++++++++++----- .../ClassNotFoundFatalErrorHandler.php | 4 +- .../UndefinedFunctionFatalErrorHandler.php | 6 +- .../UndefinedMethodFatalErrorHandler.php | 2 +- .../Component/HttpKernel/Log/Logger.php | 2 + .../Component/HttpKernel/Tests/Logger.php | 27 +++++ .../Data/Generator/TimezoneDataGenerator.php | 6 +- .../Component/WebLink/GenericLinkProvider.php | 4 + src/Symfony/Component/WebLink/Link.php | 10 ++ .../Contracts/Service/ServiceLocatorTrait.php | 2 + 77 files changed, 555 insertions(+), 38 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php b/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php index 0c1ad35f0ba3..67ba6abf3d74 100644 --- a/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php +++ b/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php @@ -39,6 +39,8 @@ public function __construct(ContainerInterface $container) /** * {@inheritdoc} + * + * @return void */ public function dispatchEvent($eventName, EventArgs $eventArgs = null) { @@ -59,6 +61,8 @@ public function dispatchEvent($eventName, EventArgs $eventArgs = null) /** * {@inheritdoc} + * + * @return object[][] */ public function getListeners($event = null) { @@ -81,6 +85,8 @@ public function getListeners($event = null) /** * {@inheritdoc} + * + * @return bool */ public function hasListeners($event) { @@ -89,6 +95,8 @@ public function hasListeners($event) /** * {@inheritdoc} + * + * @return void */ public function addEventListener($events, $listener) { @@ -109,6 +117,8 @@ public function addEventListener($events, $listener) /** * {@inheritdoc} + * + * @return void */ public function removeEventListener($events, $listener) { diff --git a/src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php b/src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php index 63880a6d614a..42d68de902dd 100644 --- a/src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php +++ b/src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php @@ -34,6 +34,8 @@ public function __construct(LoggerInterface $logger = null, Stopwatch $stopwatch /** * {@inheritdoc} + * + * @return void */ public function startQuery($sql, array $params = null, array $types = null) { @@ -48,6 +50,8 @@ public function startQuery($sql, array $params = null, array $types = null) /** * {@inheritdoc} + * + * @return void */ public function stopQuery() { diff --git a/src/Symfony/Bridge/Doctrine/ManagerRegistry.php b/src/Symfony/Bridge/Doctrine/ManagerRegistry.php index ae481b572628..a81357a12108 100644 --- a/src/Symfony/Bridge/Doctrine/ManagerRegistry.php +++ b/src/Symfony/Bridge/Doctrine/ManagerRegistry.php @@ -29,6 +29,8 @@ abstract class ManagerRegistry extends AbstractManagerRegistry /** * {@inheritdoc} + * + * @return object */ protected function getService($name) { @@ -37,6 +39,8 @@ protected function getService($name) /** * {@inheritdoc} + * + * @return void */ protected function resetService($name) { diff --git a/src/Symfony/Bridge/Doctrine/Test/TestRepositoryFactory.php b/src/Symfony/Bridge/Doctrine/Test/TestRepositoryFactory.php index fbb1876202b1..afc49ed575bf 100644 --- a/src/Symfony/Bridge/Doctrine/Test/TestRepositoryFactory.php +++ b/src/Symfony/Bridge/Doctrine/Test/TestRepositoryFactory.php @@ -28,6 +28,8 @@ final class TestRepositoryFactory implements RepositoryFactory /** * {@inheritdoc} + * + * @return ObjectRepository */ public function getRepository(EntityManagerInterface $entityManager, $entityName) { diff --git a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/Type/StringWrapperType.php b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/Type/StringWrapperType.php index 0af4271ba73f..9e1cd621fe2a 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/Type/StringWrapperType.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/Type/StringWrapperType.php @@ -34,6 +34,8 @@ public function convertToPHPValue($value, AbstractPlatform $platform) /** * {@inheritdoc} + * + * @return string */ public function getName() { diff --git a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineFooType.php b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineFooType.php index 1b8cba50f3ec..68629066f5ee 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineFooType.php +++ b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineFooType.php @@ -27,6 +27,8 @@ class DoctrineFooType extends Type /** * {@inheritdoc} + * + * @return string */ public function getName() { @@ -35,6 +37,8 @@ public function getName() /** * {@inheritdoc} + * + * @return string */ public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) { @@ -76,6 +80,8 @@ public function convertToPHPValue($value, AbstractPlatform $platform) /** * {@inheritdoc} + * + * @return bool */ public function requiresSQLCommentHint(AbstractPlatform $platform) { diff --git a/src/Symfony/Bridge/Monolog/Handler/ChromePhpHandler.php b/src/Symfony/Bridge/Monolog/Handler/ChromePhpHandler.php index 4f98d58b1ffb..abd7cc57b33d 100644 --- a/src/Symfony/Bridge/Monolog/Handler/ChromePhpHandler.php +++ b/src/Symfony/Bridge/Monolog/Handler/ChromePhpHandler.php @@ -72,6 +72,8 @@ protected function sendHeader($header, $content) /** * Override default behavior since we check it in onKernelResponse. + * + * @return bool */ protected function headersAccepted() { diff --git a/src/Symfony/Bridge/Monolog/Handler/ConsoleHandler.php b/src/Symfony/Bridge/Monolog/Handler/ConsoleHandler.php index 413ced072bbf..8dd4808fe890 100644 --- a/src/Symfony/Bridge/Monolog/Handler/ConsoleHandler.php +++ b/src/Symfony/Bridge/Monolog/Handler/ConsoleHandler.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\Monolog\Handler; +use Monolog\Formatter\FormatterInterface; use Monolog\Formatter\LineFormatter; use Monolog\Handler\AbstractProcessingHandler; use Monolog\Logger; @@ -73,6 +74,8 @@ public function __construct(OutputInterface $output = null, bool $bubble = true, /** * {@inheritdoc} + * + * @return bool */ public function isHandling(array $record) { @@ -81,6 +84,8 @@ public function isHandling(array $record) /** * {@inheritdoc} + * + * @return bool */ public function handle(array $record) { @@ -142,6 +147,8 @@ public static function getSubscribedEvents() /** * {@inheritdoc} + * + * @return void */ protected function write(array $record) { @@ -151,6 +158,8 @@ protected function write(array $record) /** * {@inheritdoc} + * + * @return FormatterInterface */ protected function getDefaultFormatter() { diff --git a/src/Symfony/Bridge/Monolog/Handler/FingersCrossed/HttpCodeActivationStrategy.php b/src/Symfony/Bridge/Monolog/Handler/FingersCrossed/HttpCodeActivationStrategy.php index ae8fd3650a36..062ca2103bb7 100644 --- a/src/Symfony/Bridge/Monolog/Handler/FingersCrossed/HttpCodeActivationStrategy.php +++ b/src/Symfony/Bridge/Monolog/Handler/FingersCrossed/HttpCodeActivationStrategy.php @@ -45,6 +45,9 @@ public function __construct(RequestStack $requestStack, array $exclusions, $acti $this->exclusions = $exclusions; } + /** + * @return bool + */ public function isHandlerActivated(array $record) { $isActivated = parent::isHandlerActivated($record); diff --git a/src/Symfony/Bridge/Monolog/Handler/FingersCrossed/NotFoundActivationStrategy.php b/src/Symfony/Bridge/Monolog/Handler/FingersCrossed/NotFoundActivationStrategy.php index ed41929a2cef..08975d0c64b8 100644 --- a/src/Symfony/Bridge/Monolog/Handler/FingersCrossed/NotFoundActivationStrategy.php +++ b/src/Symfony/Bridge/Monolog/Handler/FingersCrossed/NotFoundActivationStrategy.php @@ -34,6 +34,9 @@ public function __construct(RequestStack $requestStack, array $excludedUrls, $ac $this->blacklist = '{('.implode('|', $excludedUrls).')}i'; } + /** + * @return bool + */ public function isHandlerActivated(array $record) { $isActivated = parent::isHandlerActivated($record); diff --git a/src/Symfony/Bridge/Monolog/Handler/FirePHPHandler.php b/src/Symfony/Bridge/Monolog/Handler/FirePHPHandler.php index b235fc101ea7..f006118223cb 100644 --- a/src/Symfony/Bridge/Monolog/Handler/FirePHPHandler.php +++ b/src/Symfony/Bridge/Monolog/Handler/FirePHPHandler.php @@ -74,6 +74,8 @@ protected function sendHeader($header, $content) /** * Override default behavior since we check the user agent in onKernelResponse. + * + * @return bool */ protected function headersAccepted() { diff --git a/src/Symfony/Bridge/Monolog/Handler/ServerLogHandler.php b/src/Symfony/Bridge/Monolog/Handler/ServerLogHandler.php index 22c035731dc5..c11fe901ea9a 100644 --- a/src/Symfony/Bridge/Monolog/Handler/ServerLogHandler.php +++ b/src/Symfony/Bridge/Monolog/Handler/ServerLogHandler.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\Monolog\Handler; +use Monolog\Formatter\FormatterInterface; use Monolog\Handler\AbstractHandler; use Monolog\Logger; use Symfony\Bridge\Monolog\Formatter\VarDumperFormatter; @@ -38,6 +39,8 @@ public function __construct(string $host, int $level = Logger::DEBUG, bool $bubb /** * {@inheritdoc} + * + * @return bool */ public function handle(array $record) { @@ -77,6 +80,8 @@ public function handle(array $record) /** * {@inheritdoc} + * + * @return FormatterInterface */ protected function getDefaultFormatter() { diff --git a/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/LazyLoadingValueHolderGenerator.php b/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/LazyLoadingValueHolderGenerator.php index 545a736711c9..de81bcb2916b 100644 --- a/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/LazyLoadingValueHolderGenerator.php +++ b/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/LazyLoadingValueHolderGenerator.php @@ -29,6 +29,8 @@ public function setFluentSafe(bool $fluentSafe) /** * {@inheritdoc} + * + * @return void */ public function generate(\ReflectionClass $originalClass, ClassGenerator $classGenerator) { diff --git a/src/Symfony/Bridge/Twig/Extension/AssetExtension.php b/src/Symfony/Bridge/Twig/Extension/AssetExtension.php index cc2cdb268e5b..289f8ec9654b 100644 --- a/src/Symfony/Bridge/Twig/Extension/AssetExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/AssetExtension.php @@ -31,6 +31,8 @@ public function __construct(Packages $packages) /** * {@inheritdoc} + * + * @return TwigFunction[] */ public function getFunctions() { diff --git a/src/Symfony/Bridge/Twig/Extension/CodeExtension.php b/src/Symfony/Bridge/Twig/Extension/CodeExtension.php index 9733884a9e5c..af4b49ab6596 100644 --- a/src/Symfony/Bridge/Twig/Extension/CodeExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/CodeExtension.php @@ -40,6 +40,8 @@ public function __construct($fileLinkFormat, string $projectDir, string $charset /** * {@inheritdoc} + * + * @return TwigFilter[] */ public function getFilters() { diff --git a/src/Symfony/Bridge/Twig/Extension/DumpExtension.php b/src/Symfony/Bridge/Twig/Extension/DumpExtension.php index 88b75368da20..6e0c4c856b14 100644 --- a/src/Symfony/Bridge/Twig/Extension/DumpExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/DumpExtension.php @@ -17,6 +17,7 @@ use Twig\Environment; use Twig\Extension\AbstractExtension; use Twig\Template; +use Twig\TokenParser\TokenParserInterface; use Twig\TwigFunction; /** @@ -35,6 +36,9 @@ public function __construct(ClonerInterface $cloner, HtmlDumper $dumper = null) $this->dumper = $dumper; } + /** + * @return TwigFunction[] + */ public function getFunctions() { return [ @@ -42,6 +46,9 @@ public function getFunctions() ]; } + /** + * @return TokenParserInterface[] + */ public function getTokenParsers() { return [new DumpTokenParser()]; diff --git a/src/Symfony/Bridge/Twig/Extension/ExpressionExtension.php b/src/Symfony/Bridge/Twig/Extension/ExpressionExtension.php index 21f6be4d6ec6..148adb90f93a 100644 --- a/src/Symfony/Bridge/Twig/Extension/ExpressionExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/ExpressionExtension.php @@ -24,6 +24,8 @@ class ExpressionExtension extends AbstractExtension { /** * {@inheritdoc} + * + * @return TwigFunction[] */ public function getFunctions() { diff --git a/src/Symfony/Bridge/Twig/Extension/FormExtension.php b/src/Symfony/Bridge/Twig/Extension/FormExtension.php index 909e20d58d69..38dd348fe79b 100644 --- a/src/Symfony/Bridge/Twig/Extension/FormExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/FormExtension.php @@ -15,6 +15,7 @@ use Symfony\Component\Form\ChoiceList\View\ChoiceView; use Symfony\Component\Form\FormView; use Twig\Extension\AbstractExtension; +use Twig\TokenParser\TokenParserInterface; use Twig\TwigFilter; use Twig\TwigFunction; use Twig\TwigTest; @@ -29,6 +30,8 @@ class FormExtension extends AbstractExtension { /** * {@inheritdoc} + * + * @return TokenParserInterface[] */ public function getTokenParsers() { @@ -40,6 +43,8 @@ public function getTokenParsers() /** * {@inheritdoc} + * + * @return TwigFunction[] */ public function getFunctions() { @@ -60,6 +65,8 @@ public function getFunctions() /** * {@inheritdoc} + * + * @return TwigFilter[] */ public function getFilters() { @@ -71,6 +78,8 @@ public function getFilters() /** * {@inheritdoc} + * + * @return TwigTest[] */ public function getTests() { diff --git a/src/Symfony/Bridge/Twig/Extension/HttpFoundationExtension.php b/src/Symfony/Bridge/Twig/Extension/HttpFoundationExtension.php index e7421b16d72e..6f192c24e3d7 100644 --- a/src/Symfony/Bridge/Twig/Extension/HttpFoundationExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/HttpFoundationExtension.php @@ -57,6 +57,8 @@ public function __construct($urlHelper) /** * {@inheritdoc} + * + * @return TwigFunction[] */ public function getFunctions() { diff --git a/src/Symfony/Bridge/Twig/Extension/HttpKernelExtension.php b/src/Symfony/Bridge/Twig/Extension/HttpKernelExtension.php index f8b93ada1547..64135a9c1dc4 100644 --- a/src/Symfony/Bridge/Twig/Extension/HttpKernelExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/HttpKernelExtension.php @@ -22,6 +22,9 @@ */ class HttpKernelExtension extends AbstractExtension { + /** + * @return TwigFunction[] + */ public function getFunctions() { return [ diff --git a/src/Symfony/Bridge/Twig/Extension/LogoutUrlExtension.php b/src/Symfony/Bridge/Twig/Extension/LogoutUrlExtension.php index e8bc6190cd65..4c25bf1c5b8a 100644 --- a/src/Symfony/Bridge/Twig/Extension/LogoutUrlExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/LogoutUrlExtension.php @@ -31,6 +31,8 @@ public function __construct(LogoutUrlGenerator $generator) /** * {@inheritdoc} + * + * @return TwigFunction[] */ public function getFunctions() { diff --git a/src/Symfony/Bridge/Twig/Extension/RoutingExtension.php b/src/Symfony/Bridge/Twig/Extension/RoutingExtension.php index cec847594995..23920e491893 100644 --- a/src/Symfony/Bridge/Twig/Extension/RoutingExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/RoutingExtension.php @@ -34,6 +34,8 @@ public function __construct(UrlGeneratorInterface $generator) /** * {@inheritdoc} + * + * @return TwigFunction[] */ public function getFunctions() { diff --git a/src/Symfony/Bridge/Twig/Extension/SecurityExtension.php b/src/Symfony/Bridge/Twig/Extension/SecurityExtension.php index 439c31aad3df..0efc286086a5 100644 --- a/src/Symfony/Bridge/Twig/Extension/SecurityExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/SecurityExtension.php @@ -50,6 +50,8 @@ public function isGranted($role, $object = null, $field = null) /** * {@inheritdoc} + * + * @return TwigFunction[] */ public function getFunctions() { diff --git a/src/Symfony/Bridge/Twig/Extension/StopwatchExtension.php b/src/Symfony/Bridge/Twig/Extension/StopwatchExtension.php index 19dfed23e3bc..fb67ad92c645 100644 --- a/src/Symfony/Bridge/Twig/Extension/StopwatchExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/StopwatchExtension.php @@ -14,6 +14,7 @@ use Symfony\Bridge\Twig\TokenParser\StopwatchTokenParser; use Symfony\Component\Stopwatch\Stopwatch; use Twig\Extension\AbstractExtension; +use Twig\TokenParser\TokenParserInterface; /** * Twig extension for the stopwatch helper. @@ -36,6 +37,9 @@ public function getStopwatch() return $this->stopwatch; } + /** + * @return TokenParserInterface[] + */ public function getTokenParsers() { return [ diff --git a/src/Symfony/Bridge/Twig/Extension/TranslationExtension.php b/src/Symfony/Bridge/Twig/Extension/TranslationExtension.php index 9e927ecdf032..bd3c2eb8932d 100644 --- a/src/Symfony/Bridge/Twig/Extension/TranslationExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/TranslationExtension.php @@ -68,6 +68,8 @@ public function getTranslator() /** * {@inheritdoc} + * + * @return TwigFilter[] */ public function getFilters() { @@ -100,6 +102,8 @@ public function getTokenParsers() /** * {@inheritdoc} + * + * @return NodeVisitorInterface[] */ public function getNodeVisitors() { diff --git a/src/Symfony/Bridge/Twig/Extension/WebLinkExtension.php b/src/Symfony/Bridge/Twig/Extension/WebLinkExtension.php index 63bfa2eba026..123cceba0d92 100644 --- a/src/Symfony/Bridge/Twig/Extension/WebLinkExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/WebLinkExtension.php @@ -33,6 +33,8 @@ public function __construct(RequestStack $requestStack) /** * {@inheritdoc} + * + * @return TwigFunction[] */ public function getFunctions() { diff --git a/src/Symfony/Bridge/Twig/Extension/WorkflowExtension.php b/src/Symfony/Bridge/Twig/Extension/WorkflowExtension.php index 85b4f7a4d73c..7c01f27dc903 100644 --- a/src/Symfony/Bridge/Twig/Extension/WorkflowExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/WorkflowExtension.php @@ -31,6 +31,9 @@ public function __construct(Registry $workflowRegistry) $this->workflowRegistry = $workflowRegistry; } + /** + * @return TwigFunction[] + */ public function getFunctions() { return [ diff --git a/src/Symfony/Bridge/Twig/Extension/YamlExtension.php b/src/Symfony/Bridge/Twig/Extension/YamlExtension.php index 3284ec5cd3d0..f1965b90b279 100644 --- a/src/Symfony/Bridge/Twig/Extension/YamlExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/YamlExtension.php @@ -25,6 +25,8 @@ class YamlExtension extends AbstractExtension { /** * {@inheritdoc} + * + * @return TwigFilter[] */ public function getFilters() { diff --git a/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php b/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php index d98b87b2b328..bcc88f193367 100644 --- a/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php +++ b/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php @@ -39,6 +39,8 @@ public function __construct() /** * {@inheritdoc} + * + * @return Node */ protected function doEnterNode(Node $node, Environment $env) { @@ -91,6 +93,8 @@ protected function doEnterNode(Node $node, Environment $env) /** * {@inheritdoc} + * + * @return Node|null */ protected function doLeaveNode(Node $node, Environment $env) { diff --git a/src/Symfony/Bridge/Twig/NodeVisitor/TranslationNodeVisitor.php b/src/Symfony/Bridge/Twig/NodeVisitor/TranslationNodeVisitor.php index 3da4141cdd2e..2d3e1d1ba19e 100644 --- a/src/Symfony/Bridge/Twig/NodeVisitor/TranslationNodeVisitor.php +++ b/src/Symfony/Bridge/Twig/NodeVisitor/TranslationNodeVisitor.php @@ -49,6 +49,8 @@ public function getMessages() /** * {@inheritdoc} + * + * @return Node */ protected function doEnterNode(Node $node, Environment $env) { @@ -89,6 +91,8 @@ protected function doEnterNode(Node $node, Environment $env) /** * {@inheritdoc} + * + * @return Node|null */ protected function doLeaveNode(Node $node, Environment $env) { diff --git a/src/Symfony/Bridge/Twig/TokenParser/DumpTokenParser.php b/src/Symfony/Bridge/Twig/TokenParser/DumpTokenParser.php index a4d7d6f69007..1a7326d5555f 100644 --- a/src/Symfony/Bridge/Twig/TokenParser/DumpTokenParser.php +++ b/src/Symfony/Bridge/Twig/TokenParser/DumpTokenParser.php @@ -12,6 +12,7 @@ namespace Symfony\Bridge\Twig\TokenParser; use Symfony\Bridge\Twig\Node\DumpNode; +use Twig\Node\Node; use Twig\Token; use Twig\TokenParser\AbstractTokenParser; @@ -30,6 +31,8 @@ class DumpTokenParser extends AbstractTokenParser { /** * {@inheritdoc} + * + * @return Node */ public function parse(Token $token) { @@ -44,6 +47,8 @@ public function parse(Token $token) /** * {@inheritdoc} + * + * @return string */ public function getTag() { diff --git a/src/Symfony/Bridge/Twig/TokenParser/StopwatchTokenParser.php b/src/Symfony/Bridge/Twig/TokenParser/StopwatchTokenParser.php index 54dcf6d391b0..2c306b1a8604 100644 --- a/src/Symfony/Bridge/Twig/TokenParser/StopwatchTokenParser.php +++ b/src/Symfony/Bridge/Twig/TokenParser/StopwatchTokenParser.php @@ -13,6 +13,7 @@ use Symfony\Bridge\Twig\Node\StopwatchNode; use Twig\Node\Expression\AssignNameExpression; +use Twig\Node\Node; use Twig\Token; use Twig\TokenParser\AbstractTokenParser; @@ -30,6 +31,9 @@ public function __construct(bool $stopwatchIsAvailable) $this->stopwatchIsAvailable = $stopwatchIsAvailable; } + /** + * @return Node + */ public function parse(Token $token) { $lineno = $token->getLine(); @@ -56,6 +60,9 @@ public function decideStopwatchEnd(Token $token) return $token->test('endstopwatch'); } + /** + * @return string + */ public function getTag() { return 'stopwatch'; diff --git a/src/Symfony/Bridge/Twig/TokenParser/TransChoiceTokenParser.php b/src/Symfony/Bridge/Twig/TokenParser/TransChoiceTokenParser.php index a3b0f9a56e94..2fa234fe14a0 100644 --- a/src/Symfony/Bridge/Twig/TokenParser/TransChoiceTokenParser.php +++ b/src/Symfony/Bridge/Twig/TokenParser/TransChoiceTokenParser.php @@ -15,6 +15,7 @@ use Twig\Error\SyntaxError; use Twig\Node\Expression\AbstractExpression; use Twig\Node\Expression\ArrayExpression; +use Twig\Node\Node; use Twig\Node\TextNode; use Twig\Token; @@ -29,6 +30,8 @@ class TransChoiceTokenParser extends TransTokenParser { /** * {@inheritdoc} + * + * @return Node */ public function parse(Token $token) { @@ -82,6 +85,8 @@ public function decideTransChoiceFork($token) /** * {@inheritdoc} + * + * @return string */ public function getTag() { diff --git a/src/Symfony/Bridge/Twig/TokenParser/TransDefaultDomainTokenParser.php b/src/Symfony/Bridge/Twig/TokenParser/TransDefaultDomainTokenParser.php index 72fbda77b8e4..1f03c6ab8985 100644 --- a/src/Symfony/Bridge/Twig/TokenParser/TransDefaultDomainTokenParser.php +++ b/src/Symfony/Bridge/Twig/TokenParser/TransDefaultDomainTokenParser.php @@ -12,6 +12,7 @@ namespace Symfony\Bridge\Twig\TokenParser; use Symfony\Bridge\Twig\Node\TransDefaultDomainNode; +use Twig\Node\Node; use Twig\Token; use Twig\TokenParser\AbstractTokenParser; @@ -24,6 +25,8 @@ class TransDefaultDomainTokenParser extends AbstractTokenParser { /** * {@inheritdoc} + * + * @return Node */ public function parse(Token $token) { @@ -36,6 +39,8 @@ public function parse(Token $token) /** * {@inheritdoc} + * + * @return string */ public function getTag() { diff --git a/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php b/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php index b94ce8072f48..ec3d4896d00a 100644 --- a/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php +++ b/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php @@ -15,6 +15,7 @@ use Twig\Error\SyntaxError; use Twig\Node\Expression\AbstractExpression; use Twig\Node\Expression\ArrayExpression; +use Twig\Node\Node; use Twig\Node\TextNode; use Twig\Token; use Twig\TokenParser\AbstractTokenParser; @@ -28,6 +29,8 @@ class TransTokenParser extends AbstractTokenParser { /** * {@inheritdoc} + * + * @return Node */ public function parse(Token $token) { @@ -86,6 +89,8 @@ public function decideTransFork($token) /** * {@inheritdoc} + * + * @return string */ public function getTag() { diff --git a/src/Symfony/Bundle/FrameworkBundle/Routing/LegacyRouteLoaderContainer.php b/src/Symfony/Bundle/FrameworkBundle/Routing/LegacyRouteLoaderContainer.php index fa110ddb5dd0..741fe210f200 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Routing/LegacyRouteLoaderContainer.php +++ b/src/Symfony/Bundle/FrameworkBundle/Routing/LegacyRouteLoaderContainer.php @@ -43,6 +43,8 @@ public function get($id) /** * {@inheritdoc} + * + * @return bool */ public function has($id) { diff --git a/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php b/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php index 1757a5997ced..3f6179d27f4d 100644 --- a/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php +++ b/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php @@ -47,6 +47,8 @@ public function __construct(FileLocatorInterface $locator, TemplateNameParserInt * {@inheritdoc} * * The name parameter might also be a TemplateReferenceInterface. + * + * @return bool */ public function exists($name) { diff --git a/src/Symfony/Bundle/WebProfilerBundle/Twig/WebProfilerExtension.php b/src/Symfony/Bundle/WebProfilerBundle/Twig/WebProfilerExtension.php index 80c597e0407c..e7f80cba8694 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Twig/WebProfilerExtension.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Twig/WebProfilerExtension.php @@ -62,6 +62,8 @@ public function leave(Profile $profile) /** * {@inheritdoc} + * + * @return TwigFunction[] */ public function getFunctions() { diff --git a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php index 80f60e5f3efd..bb6e090c2892 100644 --- a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php @@ -144,6 +144,8 @@ public static function createConnection($dsn, array $options = []) /** * {@inheritdoc} + * + * @return bool */ public function commit() { diff --git a/src/Symfony/Component/Cache/Adapter/AbstractTagAwareAdapter.php b/src/Symfony/Component/Cache/Adapter/AbstractTagAwareAdapter.php index 57e21d52d94e..5d8d40aafe97 100644 --- a/src/Symfony/Component/Cache/Adapter/AbstractTagAwareAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/AbstractTagAwareAdapter.php @@ -151,6 +151,8 @@ abstract protected function doInvalidate(array $tagIds): bool; /** * {@inheritdoc} + * + * @return bool */ public function commit() { @@ -213,6 +215,8 @@ public function commit() * {@inheritdoc} * * Overloaded in order to deal with tags for adjusted doDelete() signature. + * + * @return bool */ public function deleteItems(array $keys) { diff --git a/src/Symfony/Component/Cache/Adapter/AdapterInterface.php b/src/Symfony/Component/Cache/Adapter/AdapterInterface.php index 6da364d97fe5..c40ae42b55fa 100644 --- a/src/Symfony/Component/Cache/Adapter/AdapterInterface.php +++ b/src/Symfony/Component/Cache/Adapter/AdapterInterface.php @@ -39,6 +39,8 @@ public function getItems(array $keys = []); * {@inheritdoc} * * @param string $prefix + * + * @return bool */ public function clear(/*string $prefix = ''*/); } diff --git a/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php b/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php index 43b56dca8f2b..d93dcbd79ca1 100644 --- a/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php @@ -96,6 +96,8 @@ public function getItems(array $keys = []) /** * {@inheritdoc} + * + * @return bool */ public function deleteItems(array $keys) { @@ -108,6 +110,8 @@ public function deleteItems(array $keys) /** * {@inheritdoc} + * + * @return bool */ public function save(CacheItemInterface $item) { @@ -139,6 +143,8 @@ public function save(CacheItemInterface $item) /** * {@inheritdoc} + * + * @return bool */ public function saveDeferred(CacheItemInterface $item) { @@ -147,6 +153,8 @@ public function saveDeferred(CacheItemInterface $item) /** * {@inheritdoc} + * + * @return bool */ public function commit() { diff --git a/src/Symfony/Component/Cache/Adapter/ChainAdapter.php b/src/Symfony/Component/Cache/Adapter/ChainAdapter.php index a29a771ce422..eb1f4404bfd6 100644 --- a/src/Symfony/Component/Cache/Adapter/ChainAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ChainAdapter.php @@ -178,6 +178,8 @@ private function generateItems(iterable $items, int $adapterIndex) /** * {@inheritdoc} + * + * @return bool */ public function hasItem($key) { @@ -194,6 +196,8 @@ public function hasItem($key) * {@inheritdoc} * * @param string $prefix + * + * @return bool */ public function clear(/*string $prefix = ''*/) { @@ -214,6 +218,8 @@ public function clear(/*string $prefix = ''*/) /** * {@inheritdoc} + * + * @return bool */ public function deleteItem($key) { @@ -229,6 +235,8 @@ public function deleteItem($key) /** * {@inheritdoc} + * + * @return bool */ public function deleteItems(array $keys) { @@ -244,6 +252,8 @@ public function deleteItems(array $keys) /** * {@inheritdoc} + * + * @return bool */ public function save(CacheItemInterface $item) { @@ -259,6 +269,8 @@ public function save(CacheItemInterface $item) /** * {@inheritdoc} + * + * @return bool */ public function saveDeferred(CacheItemInterface $item) { @@ -274,6 +286,8 @@ public function saveDeferred(CacheItemInterface $item) /** * {@inheritdoc} + * + * @return bool */ public function commit() { diff --git a/src/Symfony/Component/Cache/Adapter/NullAdapter.php b/src/Symfony/Component/Cache/Adapter/NullAdapter.php index 159d43e2c947..a2fdd36373b0 100644 --- a/src/Symfony/Component/Cache/Adapter/NullAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/NullAdapter.php @@ -67,6 +67,8 @@ public function getItems(array $keys = []) /** * {@inheritdoc} + * + * @return bool */ public function hasItem($key) { @@ -77,6 +79,8 @@ public function hasItem($key) * {@inheritdoc} * * @param string $prefix + * + * @return bool */ public function clear(/*string $prefix = ''*/) { @@ -85,6 +89,8 @@ public function clear(/*string $prefix = ''*/) /** * {@inheritdoc} + * + * @return bool */ public function deleteItem($key) { @@ -93,6 +99,8 @@ public function deleteItem($key) /** * {@inheritdoc} + * + * @return bool */ public function deleteItems(array $keys) { @@ -101,6 +109,8 @@ public function deleteItems(array $keys) /** * {@inheritdoc} + * + * @return bool */ public function save(CacheItemInterface $item) { @@ -109,6 +119,8 @@ public function save(CacheItemInterface $item) /** * {@inheritdoc} + * + * @return bool */ public function saveDeferred(CacheItemInterface $item) { @@ -117,6 +129,8 @@ public function saveDeferred(CacheItemInterface $item) /** * {@inheritdoc} + * + * @return bool */ public function commit() { diff --git a/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php b/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php index 22592406536e..71ace29d1c88 100644 --- a/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php @@ -165,6 +165,8 @@ public function getItems(array $keys = []) /** * {@inheritdoc} + * + * @return bool */ public function hasItem($key) { @@ -180,6 +182,8 @@ public function hasItem($key) /** * {@inheritdoc} + * + * @return bool */ public function deleteItem($key) { @@ -195,6 +199,8 @@ public function deleteItem($key) /** * {@inheritdoc} + * + * @return bool */ public function deleteItems(array $keys) { @@ -225,6 +231,8 @@ public function deleteItems(array $keys) /** * {@inheritdoc} + * + * @return bool */ public function save(CacheItemInterface $item) { @@ -237,6 +245,8 @@ public function save(CacheItemInterface $item) /** * {@inheritdoc} + * + * @return bool */ public function saveDeferred(CacheItemInterface $item) { @@ -249,6 +259,8 @@ public function saveDeferred(CacheItemInterface $item) /** * {@inheritdoc} + * + * @return bool */ public function commit() { diff --git a/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php b/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php index 5dd9cf953060..e1937fa71ae9 100644 --- a/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php @@ -139,6 +139,8 @@ public function getItems(array $keys = []) /** * {@inheritdoc} + * + * @return bool */ public function hasItem($key) { @@ -149,6 +151,8 @@ public function hasItem($key) * {@inheritdoc} * * @param string $prefix + * + * @return bool */ public function clear(/*string $prefix = ''*/) { @@ -163,6 +167,8 @@ public function clear(/*string $prefix = ''*/) /** * {@inheritdoc} + * + * @return bool */ public function deleteItem($key) { @@ -171,6 +177,8 @@ public function deleteItem($key) /** * {@inheritdoc} + * + * @return bool */ public function deleteItems(array $keys) { @@ -185,6 +193,8 @@ public function deleteItems(array $keys) /** * {@inheritdoc} + * + * @return bool */ public function save(CacheItemInterface $item) { @@ -193,6 +203,8 @@ public function save(CacheItemInterface $item) /** * {@inheritdoc} + * + * @return bool */ public function saveDeferred(CacheItemInterface $item) { @@ -201,6 +213,8 @@ public function saveDeferred(CacheItemInterface $item) /** * {@inheritdoc} + * + * @return bool */ public function commit() { diff --git a/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php b/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php index 45bc94d82a96..b0b0645d02aa 100644 --- a/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php @@ -151,6 +151,8 @@ public function invalidateTags(array $tags) /** * {@inheritdoc} + * + * @return bool */ public function hasItem($key) { @@ -215,6 +217,8 @@ public function getItems(array $keys = []) * {@inheritdoc} * * @param string $prefix + * + * @return bool */ public function clear(/*string $prefix = ''*/) { @@ -239,6 +243,8 @@ public function clear(/*string $prefix = ''*/) /** * {@inheritdoc} + * + * @return bool */ public function deleteItem($key) { @@ -247,6 +253,8 @@ public function deleteItem($key) /** * {@inheritdoc} + * + * @return bool */ public function deleteItems(array $keys) { @@ -261,6 +269,8 @@ public function deleteItems(array $keys) /** * {@inheritdoc} + * + * @return bool */ public function save(CacheItemInterface $item) { @@ -274,6 +284,8 @@ public function save(CacheItemInterface $item) /** * {@inheritdoc} + * + * @return bool */ public function saveDeferred(CacheItemInterface $item) { @@ -287,6 +299,8 @@ public function saveDeferred(CacheItemInterface $item) /** * {@inheritdoc} + * + * @return bool */ public function commit() { diff --git a/src/Symfony/Component/Cache/Adapter/TraceableAdapter.php b/src/Symfony/Component/Cache/Adapter/TraceableAdapter.php index 1fe830ff2f0b..7e9dac803c32 100644 --- a/src/Symfony/Component/Cache/Adapter/TraceableAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/TraceableAdapter.php @@ -89,6 +89,8 @@ public function getItem($key) /** * {@inheritdoc} + * + * @return bool */ public function hasItem($key) { @@ -102,6 +104,8 @@ public function hasItem($key) /** * {@inheritdoc} + * + * @return bool */ public function deleteItem($key) { @@ -115,6 +119,8 @@ public function deleteItem($key) /** * {@inheritdoc} + * + * @return bool */ public function save(CacheItemInterface $item) { @@ -128,6 +134,8 @@ public function save(CacheItemInterface $item) /** * {@inheritdoc} + * + * @return bool */ public function saveDeferred(CacheItemInterface $item) { @@ -169,6 +177,8 @@ public function getItems(array $keys = []) * {@inheritdoc} * * @param string $prefix + * + * @return bool */ public function clear(/*string $prefix = ''*/) { @@ -187,6 +197,8 @@ public function clear(/*string $prefix = ''*/) /** * {@inheritdoc} + * + * @return bool */ public function deleteItems(array $keys) { @@ -201,6 +213,8 @@ public function deleteItems(array $keys) /** * {@inheritdoc} + * + * @return bool */ public function commit() { diff --git a/src/Symfony/Component/Cache/CacheItem.php b/src/Symfony/Component/Cache/CacheItem.php index 3cc3fb8f2e47..9ae096881c02 100644 --- a/src/Symfony/Component/Cache/CacheItem.php +++ b/src/Symfony/Component/Cache/CacheItem.php @@ -36,6 +36,8 @@ final class CacheItem implements ItemInterface /** * {@inheritdoc} + * + * @return string */ public function getKey() { @@ -52,6 +54,8 @@ public function get() /** * {@inheritdoc} + * + * @return bool */ public function isHit() { @@ -60,6 +64,8 @@ public function isHit() /** * {@inheritdoc} + * + * @return static */ public function set($value) { @@ -70,6 +76,8 @@ public function set($value) /** * {@inheritdoc} + * + * @return static */ public function expiresAt($expiration) { @@ -86,6 +94,8 @@ public function expiresAt($expiration) /** * {@inheritdoc} + * + * @return static */ public function expiresAfter($time) { diff --git a/src/Symfony/Component/Cache/DoctrineProvider.php b/src/Symfony/Component/Cache/DoctrineProvider.php index 3cc186962ed3..ee3102617e22 100644 --- a/src/Symfony/Component/Cache/DoctrineProvider.php +++ b/src/Symfony/Component/Cache/DoctrineProvider.php @@ -58,6 +58,8 @@ protected function doFetch($id) /** * {@inheritdoc} + * + * @return bool */ protected function doContains($id) { @@ -66,6 +68,8 @@ protected function doContains($id) /** * {@inheritdoc} + * + * @return bool */ protected function doSave($id, $data, $lifeTime = 0) { @@ -80,6 +84,8 @@ protected function doSave($id, $data, $lifeTime = 0) /** * {@inheritdoc} + * + * @return bool */ protected function doDelete($id) { @@ -88,6 +94,8 @@ protected function doDelete($id) /** * {@inheritdoc} + * + * @return bool */ protected function doFlush() { @@ -96,6 +104,8 @@ protected function doFlush() /** * {@inheritdoc} + * + * @return array|null */ protected function doGetStats() { diff --git a/src/Symfony/Component/Cache/Psr16Cache.php b/src/Symfony/Component/Cache/Psr16Cache.php index d67615eb7750..36d77a71a05c 100644 --- a/src/Symfony/Component/Cache/Psr16Cache.php +++ b/src/Symfony/Component/Cache/Psr16Cache.php @@ -85,6 +85,8 @@ public function get($key, $default = null) /** * {@inheritdoc} + * + * @return bool */ public function set($key, $value, $ttl = null) { @@ -108,6 +110,8 @@ public function set($key, $value, $ttl = null) /** * {@inheritdoc} + * + * @return bool */ public function delete($key) { @@ -122,6 +126,8 @@ public function delete($key) /** * {@inheritdoc} + * + * @return bool */ public function clear() { @@ -130,6 +136,8 @@ public function clear() /** * {@inheritdoc} + * + * @return iterable */ public function getMultiple($keys, $default = null) { @@ -178,6 +186,8 @@ public function getMultiple($keys, $default = null) /** * {@inheritdoc} + * + * @return bool */ public function setMultiple($values, $ttl = null) { @@ -229,6 +239,8 @@ public function setMultiple($values, $ttl = null) /** * {@inheritdoc} + * + * @return bool */ public function deleteMultiple($keys) { @@ -249,6 +261,8 @@ public function deleteMultiple($keys) /** * {@inheritdoc} + * + * @return bool */ public function has($key) { diff --git a/src/Symfony/Component/Cache/Simple/AbstractCache.php b/src/Symfony/Component/Cache/Simple/AbstractCache.php index 1a2abd9678a8..c01db702f7e4 100644 --- a/src/Symfony/Component/Cache/Simple/AbstractCache.php +++ b/src/Symfony/Component/Cache/Simple/AbstractCache.php @@ -69,6 +69,8 @@ public function get($key, $default = null) /** * {@inheritdoc} + * + * @return bool */ public function set($key, $value, $ttl = null) { @@ -79,6 +81,8 @@ public function set($key, $value, $ttl = null) /** * {@inheritdoc} + * + * @return iterable */ public function getMultiple($keys, $default = null) { @@ -105,6 +109,8 @@ public function getMultiple($keys, $default = null) /** * {@inheritdoc} + * + * @return bool */ public function setMultiple($values, $ttl = null) { @@ -142,6 +148,8 @@ public function setMultiple($values, $ttl = null) /** * {@inheritdoc} + * + * @return bool */ public function deleteMultiple($keys) { diff --git a/src/Symfony/Component/Cache/Simple/ArrayCache.php b/src/Symfony/Component/Cache/Simple/ArrayCache.php index 5cd228f6431b..7174825707bb 100644 --- a/src/Symfony/Component/Cache/Simple/ArrayCache.php +++ b/src/Symfony/Component/Cache/Simple/ArrayCache.php @@ -66,6 +66,8 @@ public function get($key, $default = null) /** * {@inheritdoc} + * + * @return iterable */ public function getMultiple($keys, $default = null) { @@ -85,6 +87,8 @@ public function getMultiple($keys, $default = null) /** * {@inheritdoc} + * + * @return bool */ public function deleteMultiple($keys) { @@ -100,6 +104,8 @@ public function deleteMultiple($keys) /** * {@inheritdoc} + * + * @return bool */ public function set($key, $value, $ttl = null) { @@ -112,6 +118,8 @@ public function set($key, $value, $ttl = null) /** * {@inheritdoc} + * + * @return bool */ public function setMultiple($values, $ttl = null) { diff --git a/src/Symfony/Component/Cache/Simple/ChainCache.php b/src/Symfony/Component/Cache/Simple/ChainCache.php index 70eb8fc780d8..683683dd87af 100644 --- a/src/Symfony/Component/Cache/Simple/ChainCache.php +++ b/src/Symfony/Component/Cache/Simple/ChainCache.php @@ -82,6 +82,8 @@ public function get($key, $default = null) /** * {@inheritdoc} + * + * @return iterable */ public function getMultiple($keys, $default = null) { @@ -123,6 +125,8 @@ private function generateItems(iterable $values, int $cacheIndex, $miss, $defaul /** * {@inheritdoc} + * + * @return bool */ public function has($key) { @@ -137,6 +141,8 @@ public function has($key) /** * {@inheritdoc} + * + * @return bool */ public function clear() { @@ -152,6 +158,8 @@ public function clear() /** * {@inheritdoc} + * + * @return bool */ public function delete($key) { @@ -167,6 +175,8 @@ public function delete($key) /** * {@inheritdoc} + * + * @return bool */ public function deleteMultiple($keys) { @@ -185,6 +195,8 @@ public function deleteMultiple($keys) /** * {@inheritdoc} + * + * @return bool */ public function set($key, $value, $ttl = null) { @@ -200,6 +212,8 @@ public function set($key, $value, $ttl = null) /** * {@inheritdoc} + * + * @return bool */ public function setMultiple($values, $ttl = null) { diff --git a/src/Symfony/Component/Cache/Simple/NullCache.php b/src/Symfony/Component/Cache/Simple/NullCache.php index d1ca6f71873b..b55f25812cbf 100644 --- a/src/Symfony/Component/Cache/Simple/NullCache.php +++ b/src/Symfony/Component/Cache/Simple/NullCache.php @@ -32,6 +32,8 @@ public function get($key, $default = null) /** * {@inheritdoc} + * + * @return iterable */ public function getMultiple($keys, $default = null) { @@ -42,6 +44,8 @@ public function getMultiple($keys, $default = null) /** * {@inheritdoc} + * + * @return bool */ public function has($key) { @@ -50,6 +54,8 @@ public function has($key) /** * {@inheritdoc} + * + * @return bool */ public function clear() { @@ -58,6 +64,8 @@ public function clear() /** * {@inheritdoc} + * + * @return bool */ public function delete($key) { @@ -66,6 +74,8 @@ public function delete($key) /** * {@inheritdoc} + * + * @return bool */ public function deleteMultiple($keys) { @@ -74,6 +84,8 @@ public function deleteMultiple($keys) /** * {@inheritdoc} + * + * @return bool */ public function set($key, $value, $ttl = null) { @@ -82,6 +94,8 @@ public function set($key, $value, $ttl = null) /** * {@inheritdoc} + * + * @return bool */ public function setMultiple($values, $ttl = null) { diff --git a/src/Symfony/Component/Cache/Simple/PhpArrayCache.php b/src/Symfony/Component/Cache/Simple/PhpArrayCache.php index 566609359d56..15578c07b0b5 100644 --- a/src/Symfony/Component/Cache/Simple/PhpArrayCache.php +++ b/src/Symfony/Component/Cache/Simple/PhpArrayCache.php @@ -87,6 +87,8 @@ public function get($key, $default = null) /** * {@inheritdoc} + * + * @return iterable */ public function getMultiple($keys, $default = null) { @@ -109,6 +111,8 @@ public function getMultiple($keys, $default = null) /** * {@inheritdoc} + * + * @return bool */ public function has($key) { @@ -124,6 +128,8 @@ public function has($key) /** * {@inheritdoc} + * + * @return bool */ public function delete($key) { @@ -139,6 +145,8 @@ public function delete($key) /** * {@inheritdoc} + * + * @return bool */ public function deleteMultiple($keys) { @@ -173,6 +181,8 @@ public function deleteMultiple($keys) /** * {@inheritdoc} + * + * @return bool */ public function set($key, $value, $ttl = null) { @@ -188,6 +198,8 @@ public function set($key, $value, $ttl = null) /** * {@inheritdoc} + * + * @return bool */ public function setMultiple($values, $ttl = null) { diff --git a/src/Symfony/Component/Cache/Simple/TraceableCache.php b/src/Symfony/Component/Cache/Simple/TraceableCache.php index 05b63bfebfd1..b1436d852b11 100644 --- a/src/Symfony/Component/Cache/Simple/TraceableCache.php +++ b/src/Symfony/Component/Cache/Simple/TraceableCache.php @@ -58,6 +58,8 @@ public function get($key, $default = null) /** * {@inheritdoc} + * + * @return bool */ public function has($key) { @@ -71,6 +73,8 @@ public function has($key) /** * {@inheritdoc} + * + * @return bool */ public function delete($key) { @@ -84,6 +88,8 @@ public function delete($key) /** * {@inheritdoc} + * + * @return bool */ public function set($key, $value, $ttl = null) { @@ -97,6 +103,8 @@ public function set($key, $value, $ttl = null) /** * {@inheritdoc} + * + * @return bool */ public function setMultiple($values, $ttl = null) { @@ -124,6 +132,8 @@ public function setMultiple($values, $ttl = null) /** * {@inheritdoc} + * + * @return iterable */ public function getMultiple($keys, $default = null) { @@ -152,6 +162,8 @@ public function getMultiple($keys, $default = null) /** * {@inheritdoc} + * + * @return bool */ public function clear() { @@ -165,6 +177,8 @@ public function clear() /** * {@inheritdoc} + * + * @return bool */ public function deleteMultiple($keys) { diff --git a/src/Symfony/Component/Cache/Tests/Adapter/ProxyAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/ProxyAdapterTest.php index 24f92ca9a599..13e5aedad044 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/ProxyAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/ProxyAdapterTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Cache\Tests\Adapter; use Psr\Cache\CacheItemInterface; +use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\ArrayAdapter; use Symfony\Component\Cache\Adapter\FilesystemAdapter; use Symfony\Component\Cache\Adapter\ProxyAdapter; @@ -28,6 +29,9 @@ class ProxyAdapterTest extends AdapterTestCase 'testPrune' => 'ProxyAdapter just proxies', ]; + /** + * @return CacheItemPoolInterface + */ public function createCachePool($defaultLifetime = 0, $testMethod = null) { if ('testGetMetadata' === $testMethod) { diff --git a/src/Symfony/Component/Cache/Tests/Fixtures/ArrayCache.php b/src/Symfony/Component/Cache/Tests/Fixtures/ArrayCache.php index 95b39d54bd8b..c00a3aef05ae 100644 --- a/src/Symfony/Component/Cache/Tests/Fixtures/ArrayCache.php +++ b/src/Symfony/Component/Cache/Tests/Fixtures/ArrayCache.php @@ -13,6 +13,9 @@ protected function doFetch($id) return $this->doContains($id) ? $this->data[$id][0] : false; } + /** + * @return bool + */ protected function doContains($id) { if (!isset($this->data[$id])) { @@ -24,6 +27,9 @@ protected function doContains($id) return !$expiry || microtime(true) < $expiry || !$this->doDelete($id); } + /** + * @return bool + */ protected function doSave($id, $data, $lifeTime = 0) { $this->data[$id] = [$data, $lifeTime ? microtime(true) + $lifeTime : false]; @@ -31,6 +37,9 @@ protected function doSave($id, $data, $lifeTime = 0) return true; } + /** + * @return bool + */ protected function doDelete($id) { unset($this->data[$id]); @@ -38,6 +47,9 @@ protected function doDelete($id) return true; } + /** + * @return bool + */ protected function doFlush() { $this->data = []; @@ -45,6 +57,9 @@ protected function doFlush() return true; } + /** + * @return array|null + */ protected function doGetStats() { return null; diff --git a/src/Symfony/Component/Cache/Tests/Fixtures/ExternalAdapter.php b/src/Symfony/Component/Cache/Tests/Fixtures/ExternalAdapter.php index deb0b3bc3402..0481b16bcd85 100644 --- a/src/Symfony/Component/Cache/Tests/Fixtures/ExternalAdapter.php +++ b/src/Symfony/Component/Cache/Tests/Fixtures/ExternalAdapter.php @@ -29,46 +29,73 @@ public function __construct(int $defaultLifetime = 0) $this->cache = new ArrayAdapter($defaultLifetime); } + /** + * @return CacheItemInterface + */ public function getItem($key) { return $this->cache->getItem($key); } + /** + * @return iterable + */ public function getItems(array $keys = []) { return $this->cache->getItems($keys); } + /** + * @return bool + */ public function hasItem($key) { return $this->cache->hasItem($key); } + /** + * @return bool + */ public function clear() { return $this->cache->clear(); } + /** + * @return bool + */ public function deleteItem($key) { return $this->cache->deleteItem($key); } + /** + * @return bool + */ public function deleteItems(array $keys) { return $this->cache->deleteItems($keys); } + /** + * @return bool + */ public function save(CacheItemInterface $item) { return $this->cache->save($item); } + /** + * @return bool + */ public function saveDeferred(CacheItemInterface $item) { return $this->cache->saveDeferred($item); } + /** + * @return bool + */ public function commit() { return $this->cache->commit(); diff --git a/src/Symfony/Component/Cache/Tests/Simple/CacheTestCase.php b/src/Symfony/Component/Cache/Tests/Simple/CacheTestCase.php index d23a0ff84eda..5cad7858be85 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/CacheTestCase.php +++ b/src/Symfony/Component/Cache/Tests/Simple/CacheTestCase.php @@ -26,6 +26,9 @@ protected function setUp(): void } } + /** + * @return array + */ public static function validKeys() { return array_merge(parent::validKeys(), [["a\0b"]]); diff --git a/src/Symfony/Component/Cache/Traits/AbstractAdapterTrait.php b/src/Symfony/Component/Cache/Traits/AbstractAdapterTrait.php index 52c897d239d7..1b1c9a2b2672 100644 --- a/src/Symfony/Component/Cache/Traits/AbstractAdapterTrait.php +++ b/src/Symfony/Component/Cache/Traits/AbstractAdapterTrait.php @@ -84,6 +84,8 @@ public function getItems(array $keys = []) /** * {@inheritdoc} + * + * @return bool */ public function save(CacheItemInterface $item) { @@ -97,6 +99,8 @@ public function save(CacheItemInterface $item) /** * {@inheritdoc} + * + * @return bool */ public function saveDeferred(CacheItemInterface $item) { diff --git a/src/Symfony/Component/Cache/Traits/AbstractTrait.php b/src/Symfony/Component/Cache/Traits/AbstractTrait.php index 07205758a8a0..dc5c7ff0e195 100644 --- a/src/Symfony/Component/Cache/Traits/AbstractTrait.php +++ b/src/Symfony/Component/Cache/Traits/AbstractTrait.php @@ -82,6 +82,8 @@ abstract protected function doSave(array $values, $lifetime); /** * {@inheritdoc} + * + * @return bool */ public function hasItem($key) { @@ -104,6 +106,8 @@ public function hasItem($key) * {@inheritdoc} * * @param string $prefix + * + * @return bool */ public function clear(/*string $prefix = ''*/) { @@ -133,6 +137,8 @@ public function clear(/*string $prefix = ''*/) /** * {@inheritdoc} + * + * @return bool */ public function deleteItem($key) { @@ -141,6 +147,8 @@ public function deleteItem($key) /** * {@inheritdoc} + * + * @return bool */ public function deleteItems(array $keys) { diff --git a/src/Symfony/Component/Cache/Traits/ArrayTrait.php b/src/Symfony/Component/Cache/Traits/ArrayTrait.php index 56b7c982d10a..c13cc1a56ce8 100644 --- a/src/Symfony/Component/Cache/Traits/ArrayTrait.php +++ b/src/Symfony/Component/Cache/Traits/ArrayTrait.php @@ -53,6 +53,8 @@ public function getValues() /** * {@inheritdoc} + * + * @return bool */ public function hasItem($key) { @@ -68,6 +70,8 @@ public function hasItem($key) * {@inheritdoc} * * @param string $prefix + * + * @return bool */ public function clear(/*string $prefix = ''*/) { @@ -88,6 +92,8 @@ public function clear(/*string $prefix = ''*/) /** * {@inheritdoc} + * + * @return bool */ public function deleteItem($key) { diff --git a/src/Symfony/Component/Cache/Traits/PhpArrayTrait.php b/src/Symfony/Component/Cache/Traits/PhpArrayTrait.php index 6548ec115cf2..89dd8100ba37 100644 --- a/src/Symfony/Component/Cache/Traits/PhpArrayTrait.php +++ b/src/Symfony/Component/Cache/Traits/PhpArrayTrait.php @@ -124,6 +124,8 @@ public function warmUp(array $values) * {@inheritdoc} * * @param string $prefix + * + * @return bool */ public function clear(/*string $prefix = ''*/) { diff --git a/src/Symfony/Component/Console/Logger/ConsoleLogger.php b/src/Symfony/Component/Console/Logger/ConsoleLogger.php index 3a2853daeef9..32361189f282 100644 --- a/src/Symfony/Component/Console/Logger/ConsoleLogger.php +++ b/src/Symfony/Component/Console/Logger/ConsoleLogger.php @@ -61,6 +61,8 @@ public function __construct(OutputInterface $output, array $verbosityLevelMap = /** * {@inheritdoc} + * + * @return void */ public function log($level, $message, array $context = []) { diff --git a/src/Symfony/Component/Debug/BufferingLogger.php b/src/Symfony/Component/Debug/BufferingLogger.php index 6e308f224728..7025050fa277 100644 --- a/src/Symfony/Component/Debug/BufferingLogger.php +++ b/src/Symfony/Component/Debug/BufferingLogger.php @@ -26,6 +26,9 @@ class BufferingLogger extends AbstractLogger { private $logs = []; + /** + * @return void + */ public function log($level, $message, array $context = []) { $this->logs[] = [$level, $message, $context]; diff --git a/src/Symfony/Component/ErrorHandler/DebugClassLoader.php b/src/Symfony/Component/ErrorHandler/DebugClassLoader.php index 5819261e1f2e..f1506a92ece7 100644 --- a/src/Symfony/Component/ErrorHandler/DebugClassLoader.php +++ b/src/Symfony/Component/ErrorHandler/DebugClassLoader.php @@ -67,6 +67,7 @@ class DebugClassLoader private $classLoader; private $isFinder; private $loaded = []; + private $compatPatch; private static $caseCheck; private static $checkedClasses = []; private static $final = []; @@ -84,6 +85,7 @@ public function __construct(callable $classLoader) { $this->classLoader = $classLoader; $this->isFinder = \is_array($classLoader) && method_exists($classLoader[0], 'findFile'); + $this->compatPatch = getenv('SYMFONY_PATCH_TYPE_DECLARATIONS_COMPAT') ?: null; if (!isset(self::$caseCheck)) { $file = file_exists(__FILE__) ? __FILE__ : rtrim(realpath('.'), \DIRECTORY_SEPARATOR); @@ -412,14 +414,18 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array } if (isset(self::$returnTypes[$class][$method->name]) && !$method->hasReturnType() && !($doc && preg_match('/\n\s+\* @return +(\S+)/', $doc))) { - list($returnType, $declaringClass, $declaringFile) = self::$returnTypes[$class][$method->name]; + list($normalizedType, $returnType, $declaringClass, $declaringFile) = self::$returnTypes[$class][$method->name]; + + if (null !== $this->compatPatch && 0 === strpos($class, $this->compatPatch)) { + self::fixReturnStatements($method, $normalizedType); + } if (strncmp($ns, $declaringClass, $len)) { - //if (0 === strpos($class, 'Symfony\\')) { - // self::patchMethod($method, $returnType, $declaringFile); - //} + if (null !== $this->compatPatch && 0 === strpos($class, $this->compatPatch)) { + self::patchMethod($method, $returnType, $declaringFile); + } - $deprecations[] = sprintf('Method "%s::%s()" will return "%s" as of its next major version. Doing the same in child class "%s" will be required when upgrading.', $declaringClass, $method->name, $returnType, $class); + $deprecations[] = sprintf('Method "%s::%s()" will return "%s" as of its next major version. Doing the same in child class "%s" will be required when upgrading.', $declaringClass, $method->name, $normalizedType, $class); } } @@ -429,6 +435,10 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array if (!$method->hasReturnType() && false !== strpos($doc, '@return') && preg_match('/\n\s+\* @return +(\S+)/', $doc, $matches)) { $this->setReturnType($matches[1], $method, $parent); + + if (null !== $this->compatPatch && 0 === strpos($class, $this->compatPatch)) { + self::fixReturnStatements($method, self::$returnTypes[$class][$method->name][0] ?? '?'); + } } $finalOrInternal = false; @@ -456,7 +466,7 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array foreach ($matches as list(, $parameterType, $parameterName)) { if (!isset($definedParameters[$parameterName])) { $parameterType = trim($parameterType); - self::$annotatedParameters[$class][$method->name][$parameterName] = sprintf('The "%%s::%s()" method will require a new "%s$%s" argument in the next major version of its parent class "%s", not defining it is deprecated.', $method->name, $parameterType ? $parameterType.' ' : '', $parameterName, $method->class); + self::$annotatedParameters[$class][$method->name][$parameterName] = sprintf('The "%%s::%s()" method will require a new "%s$%s" argument in the next major version of its parent class "%s", not defining it is deprecated.', $method->name, $parameterType ? $parameterType.' ' : '', $parameterName, $class); } } } @@ -596,8 +606,12 @@ private function setReturnType(string $types, \ReflectionMethod $method, ?string $nullable = false; $typesMap = []; foreach (explode('|', $types) as $t) { - $t = $this->normalizeType($t, $method->class, $parent); - $typesMap[strtolower($t)] = $t; + $typesMap[$this->normalizeType($t, $method->class, $parent)] = $t; + } + + if (isset($typesMap['array']) && (isset($typesMap['Traversable']) || isset($typesMap['\Traversable']))) { + $typesMap['iterable'] = 'array' !== $typesMap['array'] ? $typesMap['array'] : 'iterable'; + unset($typesMap['array'], $typesMap['Traversable'], $typesMap['\Traversable']); } if (isset($typesMap['array']) && isset($typesMap['iterable'])) { @@ -630,10 +644,11 @@ private function setReturnType(string $types, \ReflectionMethod $method, ?string } if ($nullable) { - $returnType = '?'.$returnType; + $normalizedType = '?'.$normalizedType; + $returnType .= '|null'; } - self::$returnTypes[$method->class][$method->name] = [$returnType, $method->class, $method->getFileName()]; + self::$returnTypes[$method->class][$method->name] = [$normalizedType, $returnType, $method->class, $method->getFileName()]; } private function normalizeType(string $type, string $class, ?string $parent): string @@ -677,55 +692,70 @@ private static function patchMethod(\ReflectionMethod $method, string $returnTyp $patchedMethods[$file][$startLine] = true; $patchedMethods[$file][0] = $patchedMethods[$file][0] ?? 0; $startLine += $patchedMethods[$file][0] - 2; - $nullable = '?' === $returnType[0] ? '?' : ''; - $returnType = ltrim($returnType, '?'); + $returnType = explode('|', $returnType); $code = file($file); - if (!isset(self::BUILTIN_RETURN_TYPES[$returnType]) && ('\\' !== $returnType[0] || $p = strrpos($returnType, '\\', 1))) { + foreach ($returnType as $i => $type) { + if (preg_match('/((?:\[\])+)$/', $type, $m)) { + $type = substr($type, 0, -\strlen($m[1])); + $format = '%s'.$m[1]; + } elseif (preg_match('/^(array|iterable)<([^,>]++)>$/', $type, $m)) { + $type = $m[2]; + $format = $m[1].'<%s>'; + } else { + $format = null; + } + + if (isset(self::SPECIAL_RETURN_TYPES[$type]) || ('\\' === $type[0] && !$p = strrpos($type, '\\', 1))) { + continue; + } + list($namespace, $useOffset, $useMap) = $useStatements[$file] ?? $useStatements[$file] = self::getUseStatements($file); - if ('\\' !== $returnType[0]) { + if ('\\' !== $type[0]) { list($declaringNamespace, , $declaringUseMap) = $useStatements[$declaringFile] ?? $useStatements[$declaringFile] = self::getUseStatements($declaringFile); - $p = strpos($returnType, '\\', 1); - $alias = $p ? substr($returnType, 0, $p) : $returnType; + $p = strpos($type, '\\', 1); + $alias = $p ? substr($type, 0, $p) : $type; if (isset($declaringUseMap[$alias])) { - $returnType = '\\'.$declaringUseMap[$alias].($p ? substr($returnType, $p) : ''); + $type = '\\'.$declaringUseMap[$alias].($p ? substr($type, $p) : ''); } else { - $returnType = '\\'.$declaringNamespace.$returnType; + $type = '\\'.$declaringNamespace.$type; } - $p = strrpos($returnType, '\\', 1); + $p = strrpos($type, '\\', 1); } - $alias = substr($returnType, 1 + $p); - $returnType = substr($returnType, 1); + $alias = substr($type, 1 + $p); + $type = substr($type, 1); if (!isset($useMap[$alias]) && (class_exists($c = $namespace.$alias) || interface_exists($c) || trait_exists($c))) { $useMap[$alias] = $c; } if (!isset($useMap[$alias])) { - $useStatements[$file][2][$alias] = $returnType; - $code[$useOffset] = "use $returnType;\n".$code[$useOffset]; + $useStatements[$file][2][$alias] = $type; + $code[$useOffset] = "use $type;\n".$code[$useOffset]; ++$patchedMethods[$file][0]; - } elseif ($useMap[$alias] !== $returnType) { + } elseif ($useMap[$alias] !== $type) { $alias .= 'FIXME'; - $useStatements[$file][2][$alias] = $returnType; - $code[$useOffset] = "use $returnType as $alias;\n".$code[$useOffset]; + $useStatements[$file][2][$alias] = $type; + $code[$useOffset] = "use $type as $alias;\n".$code[$useOffset]; ++$patchedMethods[$file][0]; } - $returnType = $alias; + $returnType[$i] = null !== $format ? sprintf($format, $alias) : $alias; } + $returnType = implode('|', $returnType); + if ($method->getDocComment()) { - $code[$startLine] = " * @return $nullable$returnType\n".$code[$startLine]; + $code[$startLine] = " * @return $returnType\n".$code[$startLine]; } else { $code[$startLine] .= <<getFileName())) { + return; + } + + $fixedCode = $code = file($file); + $end = $method->getEndLine(); + for ($i = $method->getStartLine(); $i < $end; ++$i) { + if ('void' === $returnType) { + $fixedCode[$i] = str_replace(' return null;', ' return;', $code[$i]); + } elseif ('mixed' === $returnType || '?' === $returnType[0]) { + $fixedCode[$i] = str_replace(' return;', ' return null;', $code[$i]); + } else { + $fixedCode[$i] = str_replace(' return;', " return $returnType!?;", $code[$i]); + } + } + + if ($fixedCode !== $code) { + file_put_contents($file, $fixedCode); + } + } } diff --git a/src/Symfony/Component/ErrorHandler/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php b/src/Symfony/Component/ErrorHandler/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php index b59b0d451737..ee9930c09785 100644 --- a/src/Symfony/Component/ErrorHandler/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php +++ b/src/Symfony/Component/ErrorHandler/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php @@ -33,11 +33,11 @@ public function handleError(array $error, FatalErrorException $exception) $notFoundSuffix = '\' not found'; $notFoundSuffixLen = \strlen($notFoundSuffix); if ($notFoundSuffixLen > $messageLen) { - return; + return null; } if (0 !== substr_compare($error['message'], $notFoundSuffix, -$notFoundSuffixLen)) { - return; + return null; } foreach (['class', 'interface', 'trait'] as $typeName) { diff --git a/src/Symfony/Component/ErrorHandler/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.php b/src/Symfony/Component/ErrorHandler/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.php index 9e3affb14dba..b944b8e11cd8 100644 --- a/src/Symfony/Component/ErrorHandler/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.php +++ b/src/Symfony/Component/ErrorHandler/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.php @@ -30,17 +30,17 @@ public function handleError(array $error, FatalErrorException $exception) $notFoundSuffix = '()'; $notFoundSuffixLen = \strlen($notFoundSuffix); if ($notFoundSuffixLen > $messageLen) { - return; + return null; } if (0 !== substr_compare($error['message'], $notFoundSuffix, -$notFoundSuffixLen)) { - return; + return null; } $prefix = 'Call to undefined function '; $prefixLen = \strlen($prefix); if (0 !== strpos($error['message'], $prefix)) { - return; + return null; } $fullyQualifiedFunctionName = substr($error['message'], $prefixLen, -$notFoundSuffixLen); diff --git a/src/Symfony/Component/ErrorHandler/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php b/src/Symfony/Component/ErrorHandler/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php index 49de27446945..90bb09837e6d 100644 --- a/src/Symfony/Component/ErrorHandler/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php +++ b/src/Symfony/Component/ErrorHandler/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php @@ -28,7 +28,7 @@ public function handleError(array $error, FatalErrorException $exception) { preg_match('/^Call to undefined method (.*)::(.*)\(\)$/', $error['message'], $matches); if (!$matches) { - return; + return null; } $className = $matches[1]; diff --git a/src/Symfony/Component/HttpKernel/Log/Logger.php b/src/Symfony/Component/HttpKernel/Log/Logger.php index 3969487b7749..c27bb3f07048 100644 --- a/src/Symfony/Component/HttpKernel/Log/Logger.php +++ b/src/Symfony/Component/HttpKernel/Log/Logger.php @@ -65,6 +65,8 @@ public function __construct(string $minLevel = null, $output = 'php://stderr', c /** * {@inheritdoc} + * + * @return void */ public function log($level, $message, array $context = []) { diff --git a/src/Symfony/Component/HttpKernel/Tests/Logger.php b/src/Symfony/Component/HttpKernel/Tests/Logger.php index 8ae756132cc4..1f80e48ae9e7 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Logger.php +++ b/src/Symfony/Component/HttpKernel/Tests/Logger.php @@ -41,46 +41,73 @@ public function clear() ]; } + /** + * @return void + */ public function log($level, $message, array $context = []) { $this->logs[$level][] = $message; } + /** + * @return void + */ public function emergency($message, array $context = []) { $this->log('emergency', $message, $context); } + /** + * @return void + */ public function alert($message, array $context = []) { $this->log('alert', $message, $context); } + /** + * @return void + */ public function critical($message, array $context = []) { $this->log('critical', $message, $context); } + /** + * @return void + */ public function error($message, array $context = []) { $this->log('error', $message, $context); } + /** + * @return void + */ public function warning($message, array $context = []) { $this->log('warning', $message, $context); } + /** + * @return void + */ public function notice($message, array $context = []) { $this->log('notice', $message, $context); } + /** + * @return void + */ public function info($message, array $context = []) { $this->log('info', $message, $context); } + /** + * @return void + */ public function debug($message, array $context = []) { $this->log('debug', $message, $context); diff --git a/src/Symfony/Component/Intl/Data/Generator/TimezoneDataGenerator.php b/src/Symfony/Component/Intl/Data/Generator/TimezoneDataGenerator.php index 8ed517fe4243..d30e8d4644b4 100644 --- a/src/Symfony/Component/Intl/Data/Generator/TimezoneDataGenerator.php +++ b/src/Symfony/Component/Intl/Data/Generator/TimezoneDataGenerator.php @@ -84,13 +84,13 @@ protected function generateDataForLocale(BundleEntryReaderInterface $reader, $te // Don't generate aliases, as they are resolved during runtime // Unless an alias is needed as fallback for de-duplication purposes if (isset($this->localeAliases[$displayLocale]) && !$this->generatingFallback) { - return; + return null; } $localeBundle = $reader->read($tempDir, $displayLocale); if (!isset($localeBundle['zoneStrings']) || null === $localeBundle['zoneStrings']) { - return; + return null; } $data = [ @@ -115,7 +115,7 @@ protected function generateDataForLocale(BundleEntryReaderInterface $reader, $te $data['Meta'] = array_diff($data['Meta'], $fallback['Meta']); } if (!$data['Names'] && !$data['Meta']) { - return; + return null; } $this->zoneIds = array_merge($this->zoneIds, array_keys($data['Names'])); diff --git a/src/Symfony/Component/WebLink/GenericLinkProvider.php b/src/Symfony/Component/WebLink/GenericLinkProvider.php index 5c8b2e71144d..9dd0e6733fbd 100644 --- a/src/Symfony/Component/WebLink/GenericLinkProvider.php +++ b/src/Symfony/Component/WebLink/GenericLinkProvider.php @@ -61,6 +61,8 @@ public function getLinksByRel($rel): array /** * {@inheritdoc} + * + * @return static */ public function withLink(LinkInterface $link) { @@ -72,6 +74,8 @@ public function withLink(LinkInterface $link) /** * {@inheritdoc} + * + * @return static */ public function withoutLink(LinkInterface $link) { diff --git a/src/Symfony/Component/WebLink/Link.php b/src/Symfony/Component/WebLink/Link.php index a7d034c1fae8..a43028443c62 100644 --- a/src/Symfony/Component/WebLink/Link.php +++ b/src/Symfony/Component/WebLink/Link.php @@ -92,6 +92,8 @@ public function getAttributes(): array /** * {@inheritdoc} + * + * @return static */ public function withHref($href) { @@ -104,6 +106,8 @@ public function withHref($href) /** * {@inheritdoc} + * + * @return static */ public function withRel($rel) { @@ -115,6 +119,8 @@ public function withRel($rel) /** * {@inheritdoc} + * + * @return static */ public function withoutRel($rel) { @@ -126,6 +132,8 @@ public function withoutRel($rel) /** * {@inheritdoc} + * + * @return static */ public function withAttribute($attribute, $value) { @@ -137,6 +145,8 @@ public function withAttribute($attribute, $value) /** * {@inheritdoc} + * + * @return static */ public function withoutAttribute($attribute) { diff --git a/src/Symfony/Contracts/Service/ServiceLocatorTrait.php b/src/Symfony/Contracts/Service/ServiceLocatorTrait.php index 71b1b7460dff..4ec6eb4276cf 100644 --- a/src/Symfony/Contracts/Service/ServiceLocatorTrait.php +++ b/src/Symfony/Contracts/Service/ServiceLocatorTrait.php @@ -36,6 +36,8 @@ public function __construct(array $factories) /** * {@inheritdoc} + * + * @return bool */ public function has($id) {