diff --git a/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php b/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php index a88b90d946b7..c5f34ce951a2 100644 --- a/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php +++ b/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php @@ -14,6 +14,7 @@ use Doctrine\Common\Collections\Collection; use Doctrine\Common\Persistence\ManagerRegistry; use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\ORM\QueryBuilder; use Symfony\Bridge\Doctrine\Form\ChoiceList\DoctrineChoiceLoader; use Symfony\Bridge\Doctrine\Form\ChoiceList\EntityLoaderInterface; use Symfony\Bridge\Doctrine\Form\ChoiceList\IdReader; @@ -51,12 +52,10 @@ abstract class DoctrineType extends AbstractType implements ResetInterface * * @param object $choice The object * - * @return string The string representation of the object - * * @internal This method is public to be usable as callback. It should not * be used in user code. */ - public static function createChoiceLabel($choice) + public static function createChoiceLabel($choice): string { return (string) $choice; } @@ -73,12 +72,10 @@ public static function createChoiceLabel($choice) * @param string $value The choice value. Corresponds to the object's * ID here. * - * @return string The field name - * * @internal This method is public to be usable as callback. It should not * be used in user code. */ - public static function createChoiceName($choice, $key, $value) + public static function createChoiceName($choice, $key, $value): string { return str_replace('-', '_', (string) $value); } @@ -88,17 +85,15 @@ public static function createChoiceName($choice, $key, $value) * For instance in ORM two query builders with an equal SQL string and * equal parameters are considered to be equal. * - * @param object $queryBuilder - * - * @return array|false Array with important QueryBuilder parts or false if - * they can't be determined + * @return array|null Array with important QueryBuilder parts or null if + * they can't be determined * * @internal This method is public to be usable as callback. It should not * be used in user code. */ - public function getQueryBuilderPartsForCachingHash($queryBuilder) + public function getQueryBuilderPartsForCachingHash(QueryBuilder $queryBuilder): ?array { - return false; + return null; } public function __construct(ManagerRegistry $registry) @@ -127,7 +122,7 @@ public function configureOptions(OptionsResolver $resolver) // If there is no QueryBuilder we can safely cache DoctrineChoiceLoader, // also if concrete Type can return important QueryBuilder parts to generate // hash key we go for it as well - if (!$options['query_builder'] || false !== ($qbParts = $this->getQueryBuilderPartsForCachingHash($options['query_builder']))) { + if (!$options['query_builder'] || null !== $qbParts = $this->getQueryBuilderPartsForCachingHash($options['query_builder'])) { $hash = CachingFactoryDecorator::generateHash([ $options['em'], $options['class'], diff --git a/src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php b/src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php index 9325416645f9..87d131a8c2ed 100644 --- a/src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php +++ b/src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php @@ -68,14 +68,10 @@ public function getBlockPrefix() * We consider two query builders with an equal SQL string and * equal parameters to be equal. * - * @param QueryBuilder $queryBuilder - * - * @return array - * * @internal This method is public to be usable as callback. It should not * be used in user code. */ - public function getQueryBuilderPartsForCachingHash($queryBuilder) + public function getQueryBuilderPartsForCachingHash(QueryBuilder $queryBuilder): ?array { return [ $queryBuilder->getQuery()->getSQL(), diff --git a/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/LazyLoadingValueHolderGenerator.php b/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/LazyLoadingValueHolderGenerator.php index de81bcb2916b..5dd40af9b342 100644 --- a/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/LazyLoadingValueHolderGenerator.php +++ b/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/LazyLoadingValueHolderGenerator.php @@ -29,10 +29,8 @@ public function setFluentSafe(bool $fluentSafe) /** * {@inheritdoc} - * - * @return void */ - public function generate(\ReflectionClass $originalClass, ClassGenerator $classGenerator) + public function generate(\ReflectionClass $originalClass, ClassGenerator $classGenerator): void { parent::generate($originalClass, $classGenerator); diff --git a/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php b/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php index 85628aee9363..0854f7f18360 100644 --- a/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php +++ b/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php @@ -40,7 +40,7 @@ public function __construct(string $salt = '') /** * {@inheritdoc} */ - public function isProxyCandidate(Definition $definition) + public function isProxyCandidate(Definition $definition): bool { return ($definition->isLazy() || $definition->hasTag('proxy')) && $this->proxyGenerator->getProxifiedClass($definition); } @@ -48,7 +48,7 @@ public function isProxyCandidate(Definition $definition) /** * {@inheritdoc} */ - public function getProxyFactoryCode(Definition $definition, $id, $factoryCode = null) + public function getProxyFactoryCode(Definition $definition, $id, $factoryCode = null): string { $instantiation = 'return'; @@ -82,7 +82,7 @@ public function getProxyFactoryCode(Definition $definition, $id, $factoryCode = /** * {@inheritdoc} */ - public function getProxyCode(Definition $definition) + public function getProxyCode(Definition $definition): string { $code = $this->classGenerator->generate($this->generateProxyClass($definition)); diff --git a/src/Symfony/Bridge/Twig/Extension/RoutingExtension.php b/src/Symfony/Bridge/Twig/Extension/RoutingExtension.php index 23920e491893..ad14e0521a2f 100644 --- a/src/Symfony/Bridge/Twig/Extension/RoutingExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/RoutingExtension.php @@ -93,7 +93,7 @@ public function getUrl($name, $parameters = [], $schemeRelative = false) * * @final */ - public function isUrlGenerationSafe(Node $argsNode) + public function isUrlGenerationSafe(Node $argsNode): array { // support named arguments $paramsNode = $argsNode->hasNode('parameters') ? $argsNode->getNode('parameters') : ( diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/RouterCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/RouterCacheWarmer.php index e9eec5e6c760..61d9f21a5aaf 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/RouterCacheWarmer.php +++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/RouterCacheWarmer.php @@ -57,7 +57,7 @@ public function warmUp($cacheDir) * * @return bool always true */ - public function isOptional() + public function isOptional(): bool { return true; } @@ -65,7 +65,7 @@ public function isOptional() /** * {@inheritdoc} */ - public static function getSubscribedServices() + public static function getSubscribedServices(): array { return [ 'router' => RouterInterface::class, diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php index 33160d8900d5..dc8ea90ab4eb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php @@ -213,11 +213,9 @@ protected function validateInput(InputInterface $input) /** * Loads the ContainerBuilder from the cache. * - * @return ContainerBuilder - * * @throws \LogicException */ - protected function getContainerBuilder() + protected function getContainerBuilder(): ContainerBuilder { if ($this->containerBuilder) { return $this->containerBuilder; diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php index 0995990b86ed..ca2404f613d9 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php @@ -84,23 +84,12 @@ public function describe(OutputInterface $output, $object, array $options = []) } } - /** - * Returns the output. - * - * @return OutputInterface The output - */ - protected function getOutput() + protected function getOutput(): OutputInterface { return $this->output; } - /** - * Writes content to output. - * - * @param string $content - * @param bool $decorated - */ - protected function write($content, $decorated = false) + protected function write(string $content, bool $decorated = false) { $this->output->write($content, false, $decorated ? OutputInterface::OUTPUT_NORMAL : OutputInterface::OUTPUT_RAW); } @@ -182,10 +171,8 @@ abstract protected function describeCallable($callable, array $options = []); * Formats a value as string. * * @param mixed $value - * - * @return string */ - protected function formatValue($value) + protected function formatValue($value): string { if (\is_object($value)) { return sprintf('object(%s)', \get_class($value)); @@ -202,10 +189,8 @@ protected function formatValue($value) * Formats a parameter. * * @param mixed $value - * - * @return string */ - protected function formatParameter($value) + protected function formatParameter($value): string { if (\is_bool($value) || \is_array($value) || (null === $value)) { $jsonString = json_encode($value); @@ -246,10 +231,8 @@ protected function resolveServiceDefinition(ContainerBuilder $builder, $serviceI /** * @param bool $showHidden - * - * @return array */ - protected function findDefinitionsByTag(ContainerBuilder $builder, $showHidden) + protected function findDefinitionsByTag(ContainerBuilder $builder, $showHidden): array { $definitions = []; $tags = $builder->findTags(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php index 7c8ba7628f10..a7f4f6954fc3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php @@ -198,10 +198,7 @@ private function writeData(array $data, array $options) $this->write(json_encode($data, $flags | JSON_PRETTY_PRINT)."\n"); } - /** - * @return array - */ - protected function getRouteData(Route $route) + protected function getRouteData(Route $route): array { $data = [ 'path' => $route->getPath(), diff --git a/src/Symfony/Bundle/FrameworkBundle/Routing/RedirectableCompiledUrlMatcher.php b/src/Symfony/Bundle/FrameworkBundle/Routing/RedirectableCompiledUrlMatcher.php index 2a6c6b843062..cb2c831d969f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Routing/RedirectableCompiledUrlMatcher.php +++ b/src/Symfony/Bundle/FrameworkBundle/Routing/RedirectableCompiledUrlMatcher.php @@ -24,7 +24,7 @@ class RedirectableCompiledUrlMatcher extends CompiledUrlMatcher implements Redir /** * {@inheritdoc} */ - public function redirect($path, $route, $scheme = null) + public function redirect($path, $route, $scheme = null): array { return [ '_controller' => 'Symfony\\Bundle\\FrameworkBundle\\Controller\\RedirectController::urlRedirectAction', diff --git a/src/Symfony/Bundle/FrameworkBundle/Test/TestContainer.php b/src/Symfony/Bundle/FrameworkBundle/Test/TestContainer.php index 5b9c1eb51c23..f0fcb38ee184 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Test/TestContainer.php +++ b/src/Symfony/Bundle/FrameworkBundle/Test/TestContainer.php @@ -12,6 +12,7 @@ namespace Symfony\Bundle\FrameworkBundle\Test; use Symfony\Component\DependencyInjection\Container; +use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\HttpKernel\KernelInterface; /** @@ -41,7 +42,7 @@ public function compile() /** * {@inheritdoc} */ - public function isCompiled() + public function isCompiled(): bool { return $this->getPublicContainer()->isCompiled(); } @@ -49,7 +50,7 @@ public function isCompiled() /** * {@inheritdoc} */ - public function getParameterBag() + public function getParameterBag(): ParameterBagInterface { return $this->getPublicContainer()->getParameterBag(); } @@ -65,7 +66,7 @@ public function getParameter($name) /** * {@inheritdoc} */ - public function hasParameter($name) + public function hasParameter($name): bool { return $this->getPublicContainer()->hasParameter($name); } @@ -89,7 +90,7 @@ public function set($id, $service) /** * {@inheritdoc} */ - public function has($id) + public function has($id): bool { return $this->getPublicContainer()->has($id) || $this->getPrivateContainer()->has($id); } @@ -105,7 +106,7 @@ public function get($id, $invalidBehavior = /* self::EXCEPTION_ON_INVALID_REFERE /** * {@inheritdoc} */ - public function initialized($id) + public function initialized($id): bool { return $this->getPublicContainer()->initialized($id); } @@ -121,7 +122,7 @@ public function reset() /** * {@inheritdoc} */ - public function getServiceIds() + public function getServiceIds(): array { return $this->getPublicContainer()->getServiceIds(); } @@ -129,7 +130,7 @@ public function getServiceIds() /** * {@inheritdoc} */ - public function getRemovedIds() + public function getRemovedIds(): array { return $this->getPublicContainer()->getRemovedIds(); } diff --git a/src/Symfony/Bundle/SecurityBundle/EventListener/VoteListener.php b/src/Symfony/Bundle/SecurityBundle/EventListener/VoteListener.php index 4d0dbdb75785..1b37d9237370 100644 --- a/src/Symfony/Bundle/SecurityBundle/EventListener/VoteListener.php +++ b/src/Symfony/Bundle/SecurityBundle/EventListener/VoteListener.php @@ -39,7 +39,7 @@ public function onVoterVote(VoteEvent $event) $this->traceableAccessDecisionManager->addVoterVote($event->getVoter(), $event->getAttributes(), $event->getVote()); } - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return ['debug.security.authorization.vote' => 'onVoterVote']; } diff --git a/src/Symfony/Bundle/WebProfilerBundle/Csp/ContentSecurityPolicyHandler.php b/src/Symfony/Bundle/WebProfilerBundle/Csp/ContentSecurityPolicyHandler.php index 2be25941b78b..0679d2bf6d04 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Csp/ContentSecurityPolicyHandler.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Csp/ContentSecurityPolicyHandler.php @@ -38,10 +38,8 @@ public function __construct(NonceGenerator $nonceGenerator) * - The request - In case HTML content is fetched via AJAX and inserted in DOM, it must use the same nonce as origin * - The response - A call to getNonces() has already been done previously. Same nonce are returned * - They are otherwise randomly generated - * - * @return array */ - public function getNonces(Request $request, Response $response) + public function getNonces(Request $request, Response $response): array { if ($request->headers->has('X-SymfonyProfiler-Script-Nonce') && $request->headers->has('X-SymfonyProfiler-Style-Nonce')) { return [ @@ -83,7 +81,7 @@ public function disableCsp() * * @return array Nonces used by the bundle in Content-Security-Policy header */ - public function updateResponseHeaders(Request $request, Response $response) + public function updateResponseHeaders(Request $request, Response $response): array { if ($this->cspDisabled) { $this->removeCspHeaders($response); diff --git a/src/Symfony/Component/Cache/Traits/PdoTrait.php b/src/Symfony/Component/Cache/Traits/PdoTrait.php index 53680fadd20b..273188ac291f 100644 --- a/src/Symfony/Component/Cache/Traits/PdoTrait.php +++ b/src/Symfony/Component/Cache/Traits/PdoTrait.php @@ -403,10 +403,7 @@ private function getConnection() return $this->conn; } - /** - * @return string - */ - private function getServerVersion() + private function getServerVersion(): string { if (null === $this->serverVersion) { $conn = $this->conn instanceof \PDO ? $this->conn : $this->conn->getWrappedConnection(); diff --git a/src/Symfony/Component/Console/Descriptor/ApplicationDescription.php b/src/Symfony/Component/Console/Descriptor/ApplicationDescription.php index 03bfcfcda440..dda38cb81213 100644 --- a/src/Symfony/Component/Console/Descriptor/ApplicationDescription.php +++ b/src/Symfony/Component/Console/Descriptor/ApplicationDescription.php @@ -50,10 +50,7 @@ public function __construct(Application $application, string $namespace = null, $this->showHidden = $showHidden; } - /** - * @return array - */ - public function getNamespaces() + public function getNamespaces(): array { if (null === $this->namespaces) { $this->inspectApplication(); @@ -65,7 +62,7 @@ public function getNamespaces() /** * @return Command[] */ - public function getCommands() + public function getCommands(): array { if (null === $this->commands) { $this->inspectApplication(); @@ -75,13 +72,9 @@ public function getCommands() } /** - * @param string $name - * - * @return Command - * * @throws CommandNotFoundException */ - public function getCommand($name) + public function getCommand(string $name): Command { if (!isset($this->commands[$name]) && !isset($this->aliases[$name])) { throw new CommandNotFoundException(sprintf('Command %s does not exist.', $name)); diff --git a/src/Symfony/Component/Console/Descriptor/XmlDescriptor.php b/src/Symfony/Component/Console/Descriptor/XmlDescriptor.php index 1a5d3cc31afe..3d5dce1d6aff 100644 --- a/src/Symfony/Component/Console/Descriptor/XmlDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/XmlDescriptor.php @@ -26,10 +26,7 @@ */ class XmlDescriptor extends Descriptor { - /** - * @return \DOMDocument - */ - public function getInputDefinitionDocument(InputDefinition $definition) + public function getInputDefinitionDocument(InputDefinition $definition): \DOMDocument { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($definitionXML = $dom->createElement('definition')); @@ -47,10 +44,7 @@ public function getInputDefinitionDocument(InputDefinition $definition) return $dom; } - /** - * @return \DOMDocument - */ - public function getCommandDocument(Command $command) + public function getCommandDocument(Command $command): \DOMDocument { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($commandXML = $dom->createElement('command')); @@ -80,12 +74,7 @@ public function getCommandDocument(Command $command) return $dom; } - /** - * @param string|null $namespace - * - * @return \DOMDocument - */ - public function getApplicationDocument(Application $application, $namespace = null) + public function getApplicationDocument(Application $application, string $namespace = null): \DOMDocument { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($rootXml = $dom->createElement('symfony')); diff --git a/src/Symfony/Component/Console/Formatter/OutputFormatter.php b/src/Symfony/Component/Console/Formatter/OutputFormatter.php index 83f16d773156..62cf1ca38b58 100644 --- a/src/Symfony/Component/Console/Formatter/OutputFormatter.php +++ b/src/Symfony/Component/Console/Formatter/OutputFormatter.php @@ -42,13 +42,9 @@ public static function escape($text) /** * Escapes trailing "\" in given text. * - * @param string $text Text to escape - * - * @return string Escaped text - * * @internal */ - public static function escapeTrailingBackslash($text) + public static function escapeTrailingBackslash(string $text): string { if ('\\' === substr($text, -1)) { $len = \strlen($text); @@ -166,7 +162,7 @@ public function formatAndWrap(string $message, int $width) if (!$open && !$tag) { // $this->styleStack->pop(); - } elseif (false === $style = $this->createStyleFromString($tag)) { + } elseif (null === $style = $this->createStyleFromString($tag)) { $output .= $this->applyCurrentStyle($text, $output, $width, $currentLineLength); } elseif ($open) { $this->styleStack->push($style); @@ -194,17 +190,15 @@ public function getStyleStack() /** * Tries to create new style instance from string. - * - * @return OutputFormatterStyle|false False if string is not format string */ - private function createStyleFromString(string $string) + private function createStyleFromString(string $string): ?OutputFormatterStyleInterface { if (isset($this->styles[$string])) { return $this->styles[$string]; } if (!preg_match_all('/([^=]+)=([^;]+)(;|$)/', $string, $matches, PREG_SET_ORDER)) { - return false; + return null; } $style = new OutputFormatterStyle(); @@ -225,7 +219,7 @@ private function createStyleFromString(string $string) $style->setOption($option); } } else { - return false; + return null; } } diff --git a/src/Symfony/Component/Console/Input/InputDefinition.php b/src/Symfony/Component/Console/Input/InputDefinition.php index 2189c4628226..75a975213fe6 100644 --- a/src/Symfony/Component/Console/Input/InputDefinition.php +++ b/src/Symfony/Component/Console/Input/InputDefinition.php @@ -333,15 +333,11 @@ public function getOptionDefaults() /** * Returns the InputOption name given a shortcut. * - * @param string $shortcut The shortcut - * - * @return string The InputOption name - * * @throws InvalidArgumentException When option given does not exist * * @internal */ - public function shortcutToName($shortcut) + public function shortcutToName(string $shortcut): string { if (!isset($this->shortcuts[$shortcut])) { throw new InvalidArgumentException(sprintf('The "-%s" option does not exist.', $shortcut)); diff --git a/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php b/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php index 86473b3a8f5d..440088822bdb 100644 --- a/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php +++ b/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php @@ -157,13 +157,9 @@ public function testInlineStyle() } /** - * @param string $tag - * @param string|null $expected - * @param string|null $input - * * @dataProvider provideInlineStyleOptionsCases */ - public function testInlineStyleOptions($tag, $expected = null, $input = null) + public function testInlineStyleOptions(string $tag, string $expected = null, string $input = null) { $styleString = substr($tag, 1, -1); $formatter = new OutputFormatter(true); @@ -171,7 +167,7 @@ public function testInlineStyleOptions($tag, $expected = null, $input = null) $method->setAccessible(true); $result = $method->invoke($formatter, $styleString); if (null === $expected) { - $this->assertFalse($result); + $this->assertNull($result); $expected = $tag.$input.''; $this->assertSame($expected, $formatter->format($expected)); } else { diff --git a/src/Symfony/Component/CssSelector/Node/ElementNode.php b/src/Symfony/Component/CssSelector/Node/ElementNode.php index f5ef8d707770..7949ed919836 100644 --- a/src/Symfony/Component/CssSelector/Node/ElementNode.php +++ b/src/Symfony/Component/CssSelector/Node/ElementNode.php @@ -32,18 +32,12 @@ public function __construct(string $namespace = null, string $element = null) $this->element = $element; } - /** - * @return string|null - */ - public function getNamespace() + public function getNamespace(): ?string { return $this->namespace; } - /** - * @return string|null - */ - public function getElement() + public function getElement(): ?string { return $this->element; } diff --git a/src/Symfony/Component/CssSelector/Node/FunctionNode.php b/src/Symfony/Component/CssSelector/Node/FunctionNode.php index b71f0658461e..d3e9b4fc7cbb 100644 --- a/src/Symfony/Component/CssSelector/Node/FunctionNode.php +++ b/src/Symfony/Component/CssSelector/Node/FunctionNode.php @@ -52,7 +52,7 @@ public function getName(): string /** * @return Token[] */ - public function getArguments() + public function getArguments(): array { return $this->arguments; } diff --git a/src/Symfony/Component/CssSelector/Node/NegationNode.php b/src/Symfony/Component/CssSelector/Node/NegationNode.php index 9d3e9bc7a6e0..afa47cf878c6 100644 --- a/src/Symfony/Component/CssSelector/Node/NegationNode.php +++ b/src/Symfony/Component/CssSelector/Node/NegationNode.php @@ -32,18 +32,12 @@ public function __construct(NodeInterface $selector, NodeInterface $subSelector) $this->subSelector = $subSelector; } - /** - * @return NodeInterface - */ - public function getSelector() + public function getSelector(): NodeInterface { return $this->selector; } - /** - * @return NodeInterface - */ - public function getSubSelector() + public function getSubSelector(): NodeInterface { return $this->subSelector; } diff --git a/src/Symfony/Component/CssSelector/Parser/TokenStream.php b/src/Symfony/Component/CssSelector/Parser/TokenStream.php index 001bfe1a7662..cc7755ff6ada 100644 --- a/src/Symfony/Component/CssSelector/Parser/TokenStream.php +++ b/src/Symfony/Component/CssSelector/Parser/TokenStream.php @@ -76,11 +76,9 @@ public function freeze() /** * Returns next token. * - * @return Token - * * @throws InternalErrorException If there is no more token */ - public function getNext() + public function getNext(): Token { if ($this->peeking) { $this->peeking = false; @@ -98,10 +96,8 @@ public function getNext() /** * Returns peeked token. - * - * @return Token */ - public function getPeek() + public function getPeek(): Token { if (!$this->peeking) { $this->peeked = $this->getNext(); @@ -116,7 +112,7 @@ public function getPeek() * * @return Token[] */ - public function getUsed() + public function getUsed(): array { return $this->used; } @@ -128,7 +124,7 @@ public function getUsed() * * @throws SyntaxErrorException If next token is not an identifier */ - public function getNextIdentifier() + public function getNextIdentifier(): string { $next = $this->getNext(); @@ -146,7 +142,7 @@ public function getNextIdentifier() * * @throws SyntaxErrorException If next token is not an identifier or a star delimiter */ - public function getNextIdentifierOrStar() + public function getNextIdentifierOrStar(): ?string { $next = $this->getNext(); diff --git a/src/Symfony/Component/CssSelector/Parser/Tokenizer/Tokenizer.php b/src/Symfony/Component/CssSelector/Parser/Tokenizer/Tokenizer.php index fc65bc68463f..e0dcc5bf1421 100644 --- a/src/Symfony/Component/CssSelector/Parser/Tokenizer/Tokenizer.php +++ b/src/Symfony/Component/CssSelector/Parser/Tokenizer/Tokenizer.php @@ -50,10 +50,8 @@ public function __construct() /** * Tokenize selector source code. - * - * @return TokenStream */ - public function tokenize(Reader $reader) + public function tokenize(Reader $reader): TokenStream { $stream = new TokenStream(); diff --git a/src/Symfony/Component/CssSelector/XPath/Extension/AbstractExtension.php b/src/Symfony/Component/CssSelector/XPath/Extension/AbstractExtension.php index 1dce1eddff2c..44e0035a7875 100644 --- a/src/Symfony/Component/CssSelector/XPath/Extension/AbstractExtension.php +++ b/src/Symfony/Component/CssSelector/XPath/Extension/AbstractExtension.php @@ -26,7 +26,7 @@ abstract class AbstractExtension implements ExtensionInterface /** * {@inheritdoc} */ - public function getNodeTranslators() + public function getNodeTranslators(): array { return []; } @@ -34,7 +34,7 @@ public function getNodeTranslators() /** * {@inheritdoc} */ - public function getCombinationTranslators() + public function getCombinationTranslators(): array { return []; } @@ -42,7 +42,7 @@ public function getCombinationTranslators() /** * {@inheritdoc} */ - public function getFunctionTranslators() + public function getFunctionTranslators(): array { return []; } @@ -50,7 +50,7 @@ public function getFunctionTranslators() /** * {@inheritdoc} */ - public function getPseudoClassTranslators() + public function getPseudoClassTranslators(): array { return []; } @@ -58,7 +58,7 @@ public function getPseudoClassTranslators() /** * {@inheritdoc} */ - public function getAttributeMatchingTranslators() + public function getAttributeMatchingTranslators(): array { return []; } diff --git a/src/Symfony/Component/CssSelector/XPath/Extension/AttributeMatchingExtension.php b/src/Symfony/Component/CssSelector/XPath/Extension/AttributeMatchingExtension.php index e636ea3deb58..a9879f1be807 100644 --- a/src/Symfony/Component/CssSelector/XPath/Extension/AttributeMatchingExtension.php +++ b/src/Symfony/Component/CssSelector/XPath/Extension/AttributeMatchingExtension.php @@ -29,7 +29,7 @@ class AttributeMatchingExtension extends AbstractExtension /** * {@inheritdoc} */ - public function getAttributeMatchingTranslators() + public function getAttributeMatchingTranslators(): array { return [ 'exists' => [$this, 'translateExists'], @@ -112,7 +112,7 @@ public function translateDifferent(XPathExpr $xpath, string $attribute, ?string /** * {@inheritdoc} */ - public function getName() + public function getName(): string { return 'attribute-matching'; } diff --git a/src/Symfony/Component/CssSelector/XPath/Extension/CombinationExtension.php b/src/Symfony/Component/CssSelector/XPath/Extension/CombinationExtension.php index 8034db8588ae..aee976e9493e 100644 --- a/src/Symfony/Component/CssSelector/XPath/Extension/CombinationExtension.php +++ b/src/Symfony/Component/CssSelector/XPath/Extension/CombinationExtension.php @@ -43,18 +43,12 @@ public function translateDescendant(XPathExpr $xpath, XPathExpr $combinedXpath): return $xpath->join('/descendant-or-self::*/', $combinedXpath); } - /** - * @return XPathExpr - */ - public function translateChild(XPathExpr $xpath, XPathExpr $combinedXpath) + public function translateChild(XPathExpr $xpath, XPathExpr $combinedXpath): XPathExpr { return $xpath->join('/', $combinedXpath); } - /** - * @return XPathExpr - */ - public function translateDirectAdjacent(XPathExpr $xpath, XPathExpr $combinedXpath) + public function translateDirectAdjacent(XPathExpr $xpath, XPathExpr $combinedXpath): XPathExpr { return $xpath ->join('/following-sibling::', $combinedXpath) @@ -62,10 +56,7 @@ public function translateDirectAdjacent(XPathExpr $xpath, XPathExpr $combinedXpa ->addCondition('position() = 1'); } - /** - * @return XPathExpr - */ - public function translateIndirectAdjacent(XPathExpr $xpath, XPathExpr $combinedXpath) + public function translateIndirectAdjacent(XPathExpr $xpath, XPathExpr $combinedXpath): XPathExpr { return $xpath->join('/following-sibling::', $combinedXpath); } @@ -73,7 +64,7 @@ public function translateIndirectAdjacent(XPathExpr $xpath, XPathExpr $combinedX /** * {@inheritdoc} */ - public function getName() + public function getName(): string { return 'combination'; } diff --git a/src/Symfony/Component/CssSelector/XPath/Extension/FunctionExtension.php b/src/Symfony/Component/CssSelector/XPath/Extension/FunctionExtension.php index 5d032df1d4ba..4b889de1ea72 100644 --- a/src/Symfony/Component/CssSelector/XPath/Extension/FunctionExtension.php +++ b/src/Symfony/Component/CssSelector/XPath/Extension/FunctionExtension.php @@ -33,7 +33,7 @@ class FunctionExtension extends AbstractExtension /** * {@inheritdoc} */ - public function getFunctionTranslators() + public function getFunctionTranslators(): array { return [ 'nth-child' => [$this, 'translateNthChild'], @@ -164,7 +164,7 @@ public function translateLang(XPathExpr $xpath, FunctionNode $function): XPathEx /** * {@inheritdoc} */ - public function getName() + public function getName(): string { return 'function'; } diff --git a/src/Symfony/Component/CssSelector/XPath/Extension/HtmlExtension.php b/src/Symfony/Component/CssSelector/XPath/Extension/HtmlExtension.php index 99c1166c0172..6edc085810d7 100644 --- a/src/Symfony/Component/CssSelector/XPath/Extension/HtmlExtension.php +++ b/src/Symfony/Component/CssSelector/XPath/Extension/HtmlExtension.php @@ -39,7 +39,7 @@ public function __construct(Translator $translator) /** * {@inheritdoc} */ - public function getPseudoClassTranslators() + public function getPseudoClassTranslators(): array { return [ 'checked' => [$this, 'translateChecked'], @@ -56,17 +56,14 @@ public function getPseudoClassTranslators() /** * {@inheritdoc} */ - public function getFunctionTranslators() + public function getFunctionTranslators(): array { return [ 'lang' => [$this, 'translateLang'], ]; } - /** - * @return XPathExpr - */ - public function translateChecked(XPathExpr $xpath) + public function translateChecked(XPathExpr $xpath): XPathExpr { return $xpath->addCondition( '(@checked ' @@ -75,18 +72,12 @@ public function translateChecked(XPathExpr $xpath) ); } - /** - * @return XPathExpr - */ - public function translateLink(XPathExpr $xpath) + public function translateLink(XPathExpr $xpath): XPathExpr { return $xpath->addCondition("@href and (name(.) = 'a' or name(.) = 'link' or name(.) = 'area')"); } - /** - * @return XPathExpr - */ - public function translateDisabled(XPathExpr $xpath) + public function translateDisabled(XPathExpr $xpath): XPathExpr { return $xpath->addCondition( '(' @@ -112,10 +103,7 @@ public function translateDisabled(XPathExpr $xpath) // todo: in the second half, add "and is not a descendant of that fieldset element's first legend element child, if any." } - /** - * @return XPathExpr - */ - public function translateEnabled(XPathExpr $xpath) + public function translateEnabled(XPathExpr $xpath): XPathExpr { return $xpath->addCondition( '(' @@ -149,11 +137,9 @@ public function translateEnabled(XPathExpr $xpath) } /** - * @return XPathExpr - * * @throws ExpressionErrorException */ - public function translateLang(XPathExpr $xpath, FunctionNode $function) + public function translateLang(XPathExpr $xpath, FunctionNode $function): XPathExpr { $arguments = $function->getArguments(); foreach ($arguments as $token) { @@ -171,34 +157,22 @@ public function translateLang(XPathExpr $xpath, FunctionNode $function) )); } - /** - * @return XPathExpr - */ - public function translateSelected(XPathExpr $xpath) + public function translateSelected(XPathExpr $xpath): XPathExpr { return $xpath->addCondition("(@selected and name(.) = 'option')"); } - /** - * @return XPathExpr - */ - public function translateInvalid(XPathExpr $xpath) + public function translateInvalid(XPathExpr $xpath): XPathExpr { return $xpath->addCondition('0'); } - /** - * @return XPathExpr - */ - public function translateHover(XPathExpr $xpath) + public function translateHover(XPathExpr $xpath): XPathExpr { return $xpath->addCondition('0'); } - /** - * @return XPathExpr - */ - public function translateVisited(XPathExpr $xpath) + public function translateVisited(XPathExpr $xpath): XPathExpr { return $xpath->addCondition('0'); } @@ -206,7 +180,7 @@ public function translateVisited(XPathExpr $xpath) /** * {@inheritdoc} */ - public function getName() + public function getName(): string { return 'html'; } diff --git a/src/Symfony/Component/CssSelector/XPath/Extension/NodeExtension.php b/src/Symfony/Component/CssSelector/XPath/Extension/NodeExtension.php index 4d86cb876b24..9978ed31426c 100644 --- a/src/Symfony/Component/CssSelector/XPath/Extension/NodeExtension.php +++ b/src/Symfony/Component/CssSelector/XPath/Extension/NodeExtension.php @@ -62,7 +62,7 @@ public function hasFlag(int $flag): bool /** * {@inheritdoc} */ - public function getNodeTranslators() + public function getNodeTranslators(): array { return [ 'Selector' => [$this, 'translateSelector'], @@ -185,7 +185,7 @@ public function translateElement(Node\ElementNode $node): XPathExpr /** * {@inheritdoc} */ - public function getName() + public function getName(): string { return 'node'; } diff --git a/src/Symfony/Component/CssSelector/XPath/Extension/PseudoClassExtension.php b/src/Symfony/Component/CssSelector/XPath/Extension/PseudoClassExtension.php index 27fe47f9a56f..20a58874795e 100644 --- a/src/Symfony/Component/CssSelector/XPath/Extension/PseudoClassExtension.php +++ b/src/Symfony/Component/CssSelector/XPath/Extension/PseudoClassExtension.php @@ -29,7 +29,7 @@ class PseudoClassExtension extends AbstractExtension /** * {@inheritdoc} */ - public function getPseudoClassTranslators() + public function getPseudoClassTranslators(): array { return [ 'root' => [$this, 'translateRoot'], @@ -43,18 +43,12 @@ public function getPseudoClassTranslators() ]; } - /** - * @return XPathExpr - */ - public function translateRoot(XPathExpr $xpath) + public function translateRoot(XPathExpr $xpath): XPathExpr { return $xpath->addCondition('not(parent::*)'); } - /** - * @return XPathExpr - */ - public function translateFirstChild(XPathExpr $xpath) + public function translateFirstChild(XPathExpr $xpath): XPathExpr { return $xpath ->addStarPrefix() @@ -62,10 +56,7 @@ public function translateFirstChild(XPathExpr $xpath) ->addCondition('position() = 1'); } - /** - * @return XPathExpr - */ - public function translateLastChild(XPathExpr $xpath) + public function translateLastChild(XPathExpr $xpath): XPathExpr { return $xpath ->addStarPrefix() @@ -74,11 +65,9 @@ public function translateLastChild(XPathExpr $xpath) } /** - * @return XPathExpr - * * @throws ExpressionErrorException */ - public function translateFirstOfType(XPathExpr $xpath) + public function translateFirstOfType(XPathExpr $xpath): XPathExpr { if ('*' === $xpath->getElement()) { throw new ExpressionErrorException('"*:first-of-type" is not implemented.'); @@ -90,11 +79,9 @@ public function translateFirstOfType(XPathExpr $xpath) } /** - * @return XPathExpr - * * @throws ExpressionErrorException */ - public function translateLastOfType(XPathExpr $xpath) + public function translateLastOfType(XPathExpr $xpath): XPathExpr { if ('*' === $xpath->getElement()) { throw new ExpressionErrorException('"*:last-of-type" is not implemented.'); @@ -105,10 +92,7 @@ public function translateLastOfType(XPathExpr $xpath) ->addCondition('position() = last()'); } - /** - * @return XPathExpr - */ - public function translateOnlyChild(XPathExpr $xpath) + public function translateOnlyChild(XPathExpr $xpath): XPathExpr { return $xpath ->addStarPrefix() @@ -117,11 +101,9 @@ public function translateOnlyChild(XPathExpr $xpath) } /** - * @return XPathExpr - * * @throws ExpressionErrorException */ - public function translateOnlyOfType(XPathExpr $xpath) + public function translateOnlyOfType(XPathExpr $xpath): XPathExpr { if ('*' === $xpath->getElement()) { throw new ExpressionErrorException('"*:only-of-type" is not implemented.'); @@ -130,10 +112,7 @@ public function translateOnlyOfType(XPathExpr $xpath) return $xpath->addCondition('last() = 1'); } - /** - * @return XPathExpr - */ - public function translateEmpty(XPathExpr $xpath) + public function translateEmpty(XPathExpr $xpath): XPathExpr { return $xpath->addCondition('not(*) and not(string-length())'); } @@ -141,7 +120,7 @@ public function translateEmpty(XPathExpr $xpath) /** * {@inheritdoc} */ - public function getName() + public function getName(): string { return 'pseudo-class'; } diff --git a/src/Symfony/Component/CssSelector/XPath/Translator.php b/src/Symfony/Component/CssSelector/XPath/Translator.php index b409a0ef48b8..d1b65187ecbd 100644 --- a/src/Symfony/Component/CssSelector/XPath/Translator.php +++ b/src/Symfony/Component/CssSelector/XPath/Translator.php @@ -215,7 +215,7 @@ public function addAttributeMatching(XPathExpr $xpath, string $operator, string /** * @return SelectorNode[] */ - private function parseSelectors(string $css) + private function parseSelectors(string $css): array { foreach ($this->shortcutParsers as $shortcut) { $tokens = $shortcut->parse($css); diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index 52cc5acbd99a..4de09c315bee 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -1496,11 +1496,9 @@ public function log(CompilerPassInterface $pass, string $message) /** * Gets removed binding ids. * - * @return array - * * @internal */ - public function getRemovedBindingIds() + public function getRemovedBindingIds(): array { return $this->removedBindingIds; } @@ -1508,11 +1506,9 @@ public function getRemovedBindingIds() /** * Removes bindings for a service. * - * @param string $id The service identifier - * * @internal */ - public function removeBindings($id) + public function removeBindings(string $id) { if ($this->hasDefinition($id)) { foreach ($this->getDefinition($id)->getBindings() as $key => $binding) { @@ -1527,11 +1523,9 @@ public function removeBindings($id) * * @param mixed $value An array of conditionals to return * - * @return array An array of Service conditionals - * * @internal */ - public static function getServiceConditionals($value) + public static function getServiceConditionals($value): array { $services = []; @@ -1551,11 +1545,9 @@ public static function getServiceConditionals($value) * * @param mixed $value An array of conditionals to return * - * @return array An array of uninitialized conditionals - * * @internal */ - public static function getInitializedConditionals($value) + public static function getInitializedConditionals($value): array { $services = []; diff --git a/src/Symfony/Component/DependencyInjection/LazyProxy/PhpDumper/NullDumper.php b/src/Symfony/Component/DependencyInjection/LazyProxy/PhpDumper/NullDumper.php index 57c644ca795c..ebc6a5dc2bb5 100644 --- a/src/Symfony/Component/DependencyInjection/LazyProxy/PhpDumper/NullDumper.php +++ b/src/Symfony/Component/DependencyInjection/LazyProxy/PhpDumper/NullDumper.php @@ -25,7 +25,7 @@ class NullDumper implements DumperInterface /** * {@inheritdoc} */ - public function isProxyCandidate(Definition $definition) + public function isProxyCandidate(Definition $definition): bool { return false; } @@ -33,7 +33,7 @@ public function isProxyCandidate(Definition $definition) /** * {@inheritdoc} */ - public function getProxyFactoryCode(Definition $definition, $id, $factoryCode = null) + public function getProxyFactoryCode(Definition $definition, $id, $factoryCode = null): string { return ''; } @@ -41,7 +41,7 @@ public function getProxyFactoryCode(Definition $definition, $id, $factoryCode = /** * {@inheritdoc} */ - public function getProxyCode(Definition $definition) + public function getProxyCode(Definition $definition): string { return ''; } diff --git a/src/Symfony/Component/DependencyInjection/LazyProxy/ProxyHelper.php b/src/Symfony/Component/DependencyInjection/LazyProxy/ProxyHelper.php index 2540e6b28804..0828b7029de0 100644 --- a/src/Symfony/Component/DependencyInjection/LazyProxy/ProxyHelper.php +++ b/src/Symfony/Component/DependencyInjection/LazyProxy/ProxyHelper.php @@ -21,7 +21,7 @@ class ProxyHelper /** * @return string|null The FQCN or builtin name of the type hint, or null when the type hint references an invalid self|parent context */ - public static function getTypeHint(\ReflectionFunctionAbstract $r, \ReflectionParameter $p = null, $noBuiltin = false) + public static function getTypeHint(\ReflectionFunctionAbstract $r, \ReflectionParameter $p = null, $noBuiltin = false): ?string { if ($p instanceof \ReflectionParameter) { $type = $p->getType(); diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/DefaultsConfigurator.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/DefaultsConfigurator.php index b527fd51da15..55c3b495d55f 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/DefaultsConfigurator.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/DefaultsConfigurator.php @@ -61,10 +61,8 @@ final public function tag(string $name, array $attributes = []) /** * Defines an instanceof-conditional to be applied to following service definitions. - * - * @return InstanceofConfigurator */ - final public function instanceof(string $fqcn) + final public function instanceof(string $fqcn): InstanceofConfigurator { return $this->parent->instanceof($fqcn); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/CustomExpressionLanguageFunctionTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/CustomExpressionLanguageFunctionTest.php index c75cc711286c..1b4963e4cf53 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/CustomExpressionLanguageFunctionTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/CustomExpressionLanguageFunctionTest.php @@ -19,7 +19,7 @@ public function testDump() ->setArguments([new Expression('custom_func("foobar")')]); $container->addExpressionLanguageProvider(new class() implements ExpressionFunctionProviderInterface { - public function getFunctions() + public function getFunctions(): array { return [ ExpressionFunction::fromPhp('strtolower', 'custom_func'), diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/RegisterServiceSubscribersPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/RegisterServiceSubscribersPassTest.php index e78d468d66d9..734c00c266ae 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/RegisterServiceSubscribersPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/RegisterServiceSubscribersPassTest.php @@ -196,7 +196,7 @@ public function testServiceSubscriberWithSemanticId() $container = new ContainerBuilder(); $subscriber = new class() implements ServiceSubscriberInterface { - public static function getSubscribedServices() + public static function getSubscribedServices(): array { return [ 'some.service' => 'stdClass', diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php index d9d2ff9ecaa1..4fcf1ced8da0 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php @@ -327,7 +327,7 @@ public function testReset() $c->set('bar', $bar = new class() implements ResetInterface { public $resetCounter = 0; - public function reset() + public function reset(): void { ++$this->resetCounter; } diff --git a/src/Symfony/Component/DomCrawler/FormFieldRegistry.php b/src/Symfony/Component/DomCrawler/FormFieldRegistry.php index 819671e8861d..8cb19c672043 100644 --- a/src/Symfony/Component/DomCrawler/FormFieldRegistry.php +++ b/src/Symfony/Component/DomCrawler/FormFieldRegistry.php @@ -48,10 +48,8 @@ public function add(FormField $field) /** * Removes a field and its children from the registry. - * - * @param string $name The fully qualified name of the base field */ - public function remove($name) + public function remove(string $name) { $segments = $this->getSegments($name); $target = &$this->fields; @@ -68,13 +66,11 @@ public function remove($name) /** * Returns the value of the field and its children. * - * @param string $name The fully qualified name of the field - * * @return mixed The value of the field * * @throws \InvalidArgumentException if the field does not exist */ - public function &get($name) + public function &get(string $name) { $segments = $this->getSegments($name); $target = &$this->fields; @@ -92,11 +88,9 @@ public function &get($name) /** * Tests whether the form has the given field. * - * @param string $name The fully qualified name of the field - * * @return bool Whether the form has the given field */ - public function has($name) + public function has(string $name): bool { try { $this->get($name); @@ -110,12 +104,11 @@ public function has($name) /** * Set the value of a field and its children. * - * @param string $name The fully qualified name of the field - * @param mixed $value The value + * @param mixed $value The value * * @throws \InvalidArgumentException if the field does not exist */ - public function set($name, $value) + public function set(string $name, $value) { $target = &$this->get($name); if ((!\is_array($value) && $target instanceof Field\FormField) || $target instanceof Field\ChoiceFormField) { @@ -135,7 +128,7 @@ public function set($name, $value) * * @return FormField[] The list of fields as [string] Fully qualified name => (mixed) value) */ - public function all() + public function all(): array { return $this->walk($this->fields, $this->base); } @@ -146,12 +139,11 @@ public function all() * This function is made private because it allows overriding the $base and * the $values properties without any type checking. * - * @param string $base The fully qualified name of the base field - * @param array $values The values of the fields + * @param array $values The values of the fields * * @return static */ - private static function create($base, array $values) + private static function create(string $base, array $values) { $registry = new static(); $registry->base = $base; diff --git a/src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php b/src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php index 3e6493eb83f0..ffded127ac54 100644 --- a/src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php +++ b/src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php @@ -139,7 +139,7 @@ public function addListener($eventName, $listener, $priority = 0) $this->listeners[] = [$eventName, $listener[1], $priority]; } - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { $events = []; diff --git a/src/Symfony/Component/ExpressionLanguage/TokenStream.php b/src/Symfony/Component/ExpressionLanguage/TokenStream.php index 919add6b9095..01277dc44552 100644 --- a/src/Symfony/Component/ExpressionLanguage/TokenStream.php +++ b/src/Symfony/Component/ExpressionLanguage/TokenStream.php @@ -83,10 +83,8 @@ public function isEOF() /** * @internal - * - * @return string */ - public function getExpression() + public function getExpression(): string { return $this->expression; } diff --git a/src/Symfony/Component/Form/ChoiceList/Factory/CachingFactoryDecorator.php b/src/Symfony/Component/Form/ChoiceList/Factory/CachingFactoryDecorator.php index 65d17afbdf0e..6fad79c09432 100644 --- a/src/Symfony/Component/Form/ChoiceList/Factory/CachingFactoryDecorator.php +++ b/src/Symfony/Component/Form/ChoiceList/Factory/CachingFactoryDecorator.php @@ -41,14 +41,13 @@ class CachingFactoryDecorator implements ChoiceListFactoryInterface, ResetInterf * Optionally, a namespace string can be passed. Calling this method will * the same values, but different namespaces, will return different hashes. * - * @param mixed $value The value to hash - * @param string $namespace Optional. The namespace + * @param mixed $value The value to hash * * @return string The SHA-256 hash * * @internal */ - public static function generateHash($value, $namespace = '') + public static function generateHash($value, string $namespace = ''): string { if (\is_object($value)) { $value = spl_object_hash($value); diff --git a/src/Symfony/Component/Form/Util/OptionsResolverWrapper.php b/src/Symfony/Component/Form/Util/OptionsResolverWrapper.php index a7c264759263..cd862d9eb98f 100644 --- a/src/Symfony/Component/Form/Util/OptionsResolverWrapper.php +++ b/src/Symfony/Component/Form/Util/OptionsResolverWrapper.php @@ -79,7 +79,7 @@ public function addAllowedTypes($option, $allowedTypes) return $this; } - public function resolve(array $options = []) + public function resolve(array $options = []): array { throw new AccessException('Resolve options is not supported.'); } diff --git a/src/Symfony/Component/HttpClient/Tests/CurlHttpClientTest.php b/src/Symfony/Component/HttpClient/Tests/CurlHttpClientTest.php index 2c27bb7b3d6e..1d1d7c10a5c9 100644 --- a/src/Symfony/Component/HttpClient/Tests/CurlHttpClientTest.php +++ b/src/Symfony/Component/HttpClient/Tests/CurlHttpClientTest.php @@ -41,7 +41,7 @@ public function testHttp2Push() $logger = new class() extends AbstractLogger { public $logs = []; - public function log($level, $message, array $context = []) + public function log($level, $message, array $context = []): void { $this->logs[] = $message; } diff --git a/src/Symfony/Component/HttpFoundation/Session/Session.php b/src/Symfony/Component/HttpFoundation/Session/Session.php index 365ef29cf0f8..0c7e9cc5ca4a 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Session.php +++ b/src/Symfony/Component/HttpFoundation/Session/Session.php @@ -147,11 +147,9 @@ public function getUsageIndex() } /** - * @return bool - * * @internal */ - public function isEmpty() + public function isEmpty(): bool { if ($this->isStarted()) { ++$this->usageIndex; diff --git a/src/Symfony/Component/HttpFoundation/Session/SessionBagProxy.php b/src/Symfony/Component/HttpFoundation/Session/SessionBagProxy.php index 2ea1cd5a5de7..09df1426efd3 100644 --- a/src/Symfony/Component/HttpFoundation/Session/SessionBagProxy.php +++ b/src/Symfony/Component/HttpFoundation/Session/SessionBagProxy.php @@ -29,20 +29,14 @@ public function __construct(SessionBagInterface $bag, array &$data, &$usageIndex $this->usageIndex = &$usageIndex; } - /** - * @return SessionBagInterface - */ - public function getBag() + public function getBag(): SessionBagInterface { ++$this->usageIndex; return $this->bag; } - /** - * @return bool - */ - public function isEmpty() + public function isEmpty(): bool { if (!isset($this->data[$this->bag->getStorageKey()])) { return true; @@ -55,7 +49,7 @@ public function isEmpty() /** * {@inheritdoc} */ - public function getName() + public function getName(): string { return $this->bag->getName(); } @@ -74,7 +68,7 @@ public function initialize(array &$array): void /** * {@inheritdoc} */ - public function getStorageKey() + public function getStorageKey(): string { return $this->bag->getStorageKey(); } diff --git a/src/Symfony/Component/HttpKernel/Bundle/Bundle.php b/src/Symfony/Component/HttpKernel/Bundle/Bundle.php index a769e96034fa..2ff356c9fffd 100644 --- a/src/Symfony/Component/HttpKernel/Bundle/Bundle.php +++ b/src/Symfony/Component/HttpKernel/Bundle/Bundle.php @@ -116,10 +116,8 @@ public function getPath() /** * Returns the bundle name (the class short name). - * - * @return string The Bundle name */ - final public function getName() + final public function getName(): string { if (null === $this->name) { $this->parseClassName(); diff --git a/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php b/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php index 57292e07f9ba..9d84f03d82da 100644 --- a/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php +++ b/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php @@ -115,7 +115,7 @@ public function warmUp($cacheDir) * * @return bool always false */ - public function isOptional() + public function isOptional(): bool { return false; } diff --git a/src/Symfony/Component/HttpKernel/EventListener/SessionListener.php b/src/Symfony/Component/HttpKernel/EventListener/SessionListener.php index 019ccee49f21..a53ade797cda 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/SessionListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/SessionListener.php @@ -12,6 +12,7 @@ namespace Symfony\Component\HttpKernel\EventListener; use Psr\Container\ContainerInterface; +use Symfony\Component\HttpFoundation\Session\SessionInterface; use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; /** @@ -32,7 +33,7 @@ public function __construct(ContainerInterface $container) $this->container = $container; } - protected function getSession() + protected function getSession(): ?SessionInterface { if (!$this->container->has('session')) { return null; diff --git a/src/Symfony/Component/HttpKernel/EventListener/TestSessionListener.php b/src/Symfony/Component/HttpKernel/EventListener/TestSessionListener.php index a0a52c2a7526..ff8b4aaa614d 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/TestSessionListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/TestSessionListener.php @@ -12,6 +12,7 @@ namespace Symfony\Component\HttpKernel\EventListener; use Psr\Container\ContainerInterface; +use Symfony\Component\HttpFoundation\Session\SessionInterface; /** * Sets the session in the request. @@ -30,7 +31,7 @@ public function __construct(ContainerInterface $container, array $sessionOptions parent::__construct($sessionOptions); } - protected function getSession() + protected function getSession(): ?SessionInterface { if (!$this->container->has('session')) { return null; diff --git a/src/Symfony/Component/HttpKernel/HttpClientKernel.php b/src/Symfony/Component/HttpKernel/HttpClientKernel.php index f60a84eabe25..4af107d1665e 100644 --- a/src/Symfony/Component/HttpKernel/HttpClientKernel.php +++ b/src/Symfony/Component/HttpKernel/HttpClientKernel.php @@ -56,7 +56,7 @@ public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQ $response = new Response($response->getContent(!$catch), $response->getStatusCode(), $response->getHeaders(!$catch)); $response->headers = new class($response->headers->all()) extends ResponseHeaderBag { - protected function computeCacheControlValue() + protected function computeCacheControlValue(): string { return $this->getCacheControlHeader(); // preserve the original value } diff --git a/src/Symfony/Component/HttpKernel/HttpKernel.php b/src/Symfony/Component/HttpKernel/HttpKernel.php index 33548c8d088d..7343f93d68e1 100644 --- a/src/Symfony/Component/HttpKernel/HttpKernel.php +++ b/src/Symfony/Component/HttpKernel/HttpKernel.php @@ -110,14 +110,10 @@ public function terminateWithException(\Exception $exception, Request $request = * * Exceptions are not caught. * - * @param int $type The type of the request (one of HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST) - * - * @return Response A Response instance - * * @throws \LogicException If one of the listener does not behave as expected * @throws NotFoundHttpException When controller cannot be found */ - private function handleRaw(Request $request, int $type = self::MASTER_REQUEST) + private function handleRaw(Request $request, int $type = self::MASTER_REQUEST): Response { $this->requestStack->push($request); @@ -174,8 +170,6 @@ private function handleRaw(Request $request, int $type = self::MASTER_REQUEST) /** * Filters a response object. * - * @param int $type The type of the request (one of HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST) - * * @throws \RuntimeException if the passed object is not a Response instance */ private function filterResponse(Response $response, Request $request, int $type): Response @@ -205,8 +199,6 @@ private function finishRequest(Request $request, int $type) /** * Handles an exception by trying to convert it to a Response. * - * @param int $type The type of the request (one of HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST) - * * @throws \Exception */ private function handleException(\Exception $e, Request $request, int $type): Response diff --git a/src/Symfony/Component/Intl/Data/Generator/AbstractDataGenerator.php b/src/Symfony/Component/Intl/Data/Generator/AbstractDataGenerator.php index 82f0e5e1fd1b..411b0a91c0a0 100644 --- a/src/Symfony/Component/Intl/Data/Generator/AbstractDataGenerator.php +++ b/src/Symfony/Component/Intl/Data/Generator/AbstractDataGenerator.php @@ -91,39 +91,17 @@ public function generateData(GeneratorConfig $config) } /** - * @param string $sourceDir - * * @return string[] */ - abstract protected function scanLocales(LocaleScanner $scanner, $sourceDir); + abstract protected function scanLocales(LocaleScanner $scanner, string $sourceDir): array; - /** - * @param string $sourceDir - * @param string $tempDir - */ - abstract protected function compileTemporaryBundles(BundleCompilerInterface $compiler, $sourceDir, $tempDir); + abstract protected function compileTemporaryBundles(BundleCompilerInterface $compiler, string $sourceDir, string $tempDir); abstract protected function preGenerate(); - /** - * @param string $tempDir - * @param string $displayLocale - * - * @return array|null - */ - abstract protected function generateDataForLocale(BundleEntryReaderInterface $reader, $tempDir, $displayLocale); + abstract protected function generateDataForLocale(BundleEntryReaderInterface $reader, string $tempDir, string $displayLocale): ?array; - /** - * @param string $tempDir - * - * @return array|null - */ - abstract protected function generateDataForRoot(BundleEntryReaderInterface $reader, $tempDir); + abstract protected function generateDataForRoot(BundleEntryReaderInterface $reader, string $tempDir): ?array; - /** - * @param string $tempDir - * - * @return array|null - */ - abstract protected function generateDataForMeta(BundleEntryReaderInterface $reader, $tempDir); + abstract protected function generateDataForMeta(BundleEntryReaderInterface $reader, string $tempDir): ?array; } diff --git a/src/Symfony/Component/Intl/Data/Generator/CurrencyDataGenerator.php b/src/Symfony/Component/Intl/Data/Generator/CurrencyDataGenerator.php index 99a3dec262c6..d52f77e5c3c3 100644 --- a/src/Symfony/Component/Intl/Data/Generator/CurrencyDataGenerator.php +++ b/src/Symfony/Component/Intl/Data/Generator/CurrencyDataGenerator.php @@ -51,7 +51,7 @@ class CurrencyDataGenerator extends AbstractDataGenerator /** * {@inheritdoc} */ - protected function scanLocales(LocaleScanner $scanner, $sourceDir) + protected function scanLocales(LocaleScanner $scanner, $sourceDir): array { return $scanner->scanLocales($sourceDir.'/curr'); } @@ -76,7 +76,7 @@ protected function preGenerate() /** * {@inheritdoc} */ - protected function generateDataForLocale(BundleEntryReaderInterface $reader, $tempDir, $displayLocale) + protected function generateDataForLocale(BundleEntryReaderInterface $reader, $tempDir, $displayLocale): ?array { $localeBundle = $reader->read($tempDir, $displayLocale); @@ -97,7 +97,7 @@ protected function generateDataForLocale(BundleEntryReaderInterface $reader, $te /** * {@inheritdoc} */ - protected function generateDataForRoot(BundleEntryReaderInterface $reader, $tempDir) + protected function generateDataForRoot(BundleEntryReaderInterface $reader, $tempDir): ?array { $rootBundle = $reader->read($tempDir, 'root'); @@ -110,7 +110,7 @@ protected function generateDataForRoot(BundleEntryReaderInterface $reader, $temp /** * {@inheritdoc} */ - protected function generateDataForMeta(BundleEntryReaderInterface $reader, $tempDir) + protected function generateDataForMeta(BundleEntryReaderInterface $reader, $tempDir): ?array { $rootBundle = $reader->read($tempDir, 'root'); $supplementalDataBundle = $reader->read($tempDir, 'supplementalData'); diff --git a/src/Symfony/Component/Intl/Data/Generator/GeneratorConfig.php b/src/Symfony/Component/Intl/Data/Generator/GeneratorConfig.php index 2ef2c80cbf8c..ddf7db3b70eb 100644 --- a/src/Symfony/Component/Intl/Data/Generator/GeneratorConfig.php +++ b/src/Symfony/Component/Intl/Data/Generator/GeneratorConfig.php @@ -38,10 +38,8 @@ public function __construct(string $sourceDir, string $icuVersion) /** * Adds a writer to be used during the data conversion. - * - * @param string $targetDir The output directory */ - public function addBundleWriter($targetDir, BundleWriterInterface $writer) + public function addBundleWriter(string $targetDir, BundleWriterInterface $writer) { $this->bundleWriters[$targetDir] = $writer; } @@ -51,7 +49,7 @@ public function addBundleWriter($targetDir, BundleWriterInterface $writer) * * @return BundleWriterInterface[] */ - public function getBundleWriters() + public function getBundleWriters(): array { return $this->bundleWriters; } @@ -62,7 +60,7 @@ public function getBundleWriters() * * @return string An absolute path to a directory */ - public function getSourceDir() + public function getSourceDir(): string { return $this->sourceDir; } @@ -72,7 +70,7 @@ public function getSourceDir() * * @return string The ICU version string */ - public function getIcuVersion() + public function getIcuVersion(): string { return $this->icuVersion; } diff --git a/src/Symfony/Component/Intl/Data/Generator/LanguageDataGenerator.php b/src/Symfony/Component/Intl/Data/Generator/LanguageDataGenerator.php index 307ba79d971f..88db0c17f37e 100644 --- a/src/Symfony/Component/Intl/Data/Generator/LanguageDataGenerator.php +++ b/src/Symfony/Component/Intl/Data/Generator/LanguageDataGenerator.php @@ -101,7 +101,7 @@ class LanguageDataGenerator extends AbstractDataGenerator /** * {@inheritdoc} */ - protected function scanLocales(LocaleScanner $scanner, $sourceDir) + protected function scanLocales(LocaleScanner $scanner, $sourceDir): array { return $scanner->scanLocales($sourceDir.'/lang'); } @@ -126,7 +126,7 @@ protected function preGenerate() /** * {@inheritdoc} */ - protected function generateDataForLocale(BundleEntryReaderInterface $reader, $tempDir, $displayLocale) + protected function generateDataForLocale(BundleEntryReaderInterface $reader, $tempDir, $displayLocale): ?array { $localeBundle = $reader->read($tempDir, $displayLocale); @@ -148,14 +148,14 @@ protected function generateDataForLocale(BundleEntryReaderInterface $reader, $te /** * {@inheritdoc} */ - protected function generateDataForRoot(BundleEntryReaderInterface $reader, $tempDir) + protected function generateDataForRoot(BundleEntryReaderInterface $reader, $tempDir): ?array { } /** * {@inheritdoc} */ - protected function generateDataForMeta(BundleEntryReaderInterface $reader, $tempDir) + protected function generateDataForMeta(BundleEntryReaderInterface $reader, $tempDir): ?array { $rootBundle = $reader->read($tempDir, 'root'); $metadataBundle = $reader->read($tempDir, 'metadata'); diff --git a/src/Symfony/Component/Intl/Data/Generator/LocaleDataGenerator.php b/src/Symfony/Component/Intl/Data/Generator/LocaleDataGenerator.php index c0a29a6b006b..f1ba7f1b5d1d 100644 --- a/src/Symfony/Component/Intl/Data/Generator/LocaleDataGenerator.php +++ b/src/Symfony/Component/Intl/Data/Generator/LocaleDataGenerator.php @@ -36,7 +36,7 @@ class LocaleDataGenerator extends AbstractDataGenerator /** * {@inheritdoc} */ - protected function scanLocales(LocaleScanner $scanner, $sourceDir) + protected function scanLocales(LocaleScanner $scanner, $sourceDir): array { $this->locales = $scanner->scanLocales($sourceDir.'/locales'); $this->localeAliases = $scanner->scanAliases($sourceDir.'/locales'); @@ -74,7 +74,7 @@ protected function preGenerate() /** * {@inheritdoc} */ - protected function generateDataForLocale(BundleEntryReaderInterface $reader, $tempDir, $displayLocale) + protected function generateDataForLocale(BundleEntryReaderInterface $reader, $tempDir, $displayLocale): ?array { // Don't generate aliases, as they are resolved during runtime // Unless an alias is needed as fallback for de-duplication purposes @@ -133,14 +133,14 @@ protected function generateDataForLocale(BundleEntryReaderInterface $reader, $te /** * {@inheritdoc} */ - protected function generateDataForRoot(BundleEntryReaderInterface $reader, $tempDir) + protected function generateDataForRoot(BundleEntryReaderInterface $reader, $tempDir): ?array { } /** * {@inheritdoc} */ - protected function generateDataForMeta(BundleEntryReaderInterface $reader, $tempDir) + protected function generateDataForMeta(BundleEntryReaderInterface $reader, $tempDir): ?array { return [ 'Locales' => $this->locales, diff --git a/src/Symfony/Component/Intl/Data/Generator/RegionDataGenerator.php b/src/Symfony/Component/Intl/Data/Generator/RegionDataGenerator.php index a8303b857b09..def6db4c52e1 100644 --- a/src/Symfony/Component/Intl/Data/Generator/RegionDataGenerator.php +++ b/src/Symfony/Component/Intl/Data/Generator/RegionDataGenerator.php @@ -84,7 +84,7 @@ public static function isValidCountryCode($region) /** * {@inheritdoc} */ - protected function scanLocales(LocaleScanner $scanner, $sourceDir) + protected function scanLocales(LocaleScanner $scanner, $sourceDir): array { return $scanner->scanLocales($sourceDir.'/region'); } @@ -109,7 +109,7 @@ protected function preGenerate() /** * {@inheritdoc} */ - protected function generateDataForLocale(BundleEntryReaderInterface $reader, $tempDir, $displayLocale) + protected function generateDataForLocale(BundleEntryReaderInterface $reader, $tempDir, $displayLocale): ?array { $localeBundle = $reader->read($tempDir, $displayLocale); @@ -131,14 +131,14 @@ protected function generateDataForLocale(BundleEntryReaderInterface $reader, $te /** * {@inheritdoc} */ - protected function generateDataForRoot(BundleEntryReaderInterface $reader, $tempDir) + protected function generateDataForRoot(BundleEntryReaderInterface $reader, $tempDir): ?array { } /** * {@inheritdoc} */ - protected function generateDataForMeta(BundleEntryReaderInterface $reader, $tempDir) + protected function generateDataForMeta(BundleEntryReaderInterface $reader, $tempDir): ?array { $rootBundle = $reader->read($tempDir, 'root'); $metadataBundle = $reader->read($tempDir, 'metadata'); diff --git a/src/Symfony/Component/Intl/Data/Generator/ScriptDataGenerator.php b/src/Symfony/Component/Intl/Data/Generator/ScriptDataGenerator.php index a5efe4557ea5..bbeaba87f2a6 100644 --- a/src/Symfony/Component/Intl/Data/Generator/ScriptDataGenerator.php +++ b/src/Symfony/Component/Intl/Data/Generator/ScriptDataGenerator.php @@ -38,7 +38,7 @@ class ScriptDataGenerator extends AbstractDataGenerator /** * {@inheritdoc} */ - protected function scanLocales(LocaleScanner $scanner, $sourceDir) + protected function scanLocales(LocaleScanner $scanner, $sourceDir): array { return $scanner->scanLocales($sourceDir.'/lang'); } @@ -62,7 +62,7 @@ protected function preGenerate() /** * {@inheritdoc} */ - protected function generateDataForLocale(BundleEntryReaderInterface $reader, $tempDir, $displayLocale) + protected function generateDataForLocale(BundleEntryReaderInterface $reader, $tempDir, $displayLocale): ?array { $localeBundle = $reader->read($tempDir, $displayLocale); @@ -84,14 +84,14 @@ protected function generateDataForLocale(BundleEntryReaderInterface $reader, $te /** * {@inheritdoc} */ - protected function generateDataForRoot(BundleEntryReaderInterface $reader, $tempDir) + protected function generateDataForRoot(BundleEntryReaderInterface $reader, $tempDir): ?array { } /** * {@inheritdoc} */ - protected function generateDataForMeta(BundleEntryReaderInterface $reader, $tempDir) + protected function generateDataForMeta(BundleEntryReaderInterface $reader, $tempDir): ?array { $rootBundle = $reader->read($tempDir, 'root'); diff --git a/src/Symfony/Component/Intl/Data/Generator/TimezoneDataGenerator.php b/src/Symfony/Component/Intl/Data/Generator/TimezoneDataGenerator.php index d30e8d4644b4..7bb0fb44deee 100644 --- a/src/Symfony/Component/Intl/Data/Generator/TimezoneDataGenerator.php +++ b/src/Symfony/Component/Intl/Data/Generator/TimezoneDataGenerator.php @@ -42,7 +42,7 @@ class TimezoneDataGenerator extends AbstractDataGenerator /** * {@inheritdoc} */ - protected function scanLocales(LocaleScanner $scanner, $sourceDir) + protected function scanLocales(LocaleScanner $scanner, $sourceDir): array { $this->localeAliases = $scanner->scanAliases($sourceDir.'/locales'); @@ -75,7 +75,7 @@ protected function preGenerate() /** * {@inheritdoc} */ - protected function generateDataForLocale(BundleEntryReaderInterface $reader, $tempDir, $displayLocale) + protected function generateDataForLocale(BundleEntryReaderInterface $reader, $tempDir, $displayLocale): ?array { if (!$this->zoneToCountryMapping) { $this->zoneToCountryMapping = self::generateZoneToCountryMapping($reader->read($tempDir, 'windowsZones')); @@ -126,7 +126,7 @@ protected function generateDataForLocale(BundleEntryReaderInterface $reader, $te /** * {@inheritdoc} */ - protected function generateDataForRoot(BundleEntryReaderInterface $reader, $tempDir) + protected function generateDataForRoot(BundleEntryReaderInterface $reader, $tempDir): ?array { $rootBundle = $reader->read($tempDir, 'root'); @@ -139,7 +139,7 @@ protected function generateDataForRoot(BundleEntryReaderInterface $reader, $temp /** * {@inheritdoc} */ - protected function generateDataForMeta(BundleEntryReaderInterface $reader, $tempDir) + protected function generateDataForMeta(BundleEntryReaderInterface $reader, $tempDir): ?array { $rootBundle = $reader->read($tempDir, 'root'); diff --git a/src/Symfony/Component/Intl/Data/Util/LocaleScanner.php b/src/Symfony/Component/Intl/Data/Util/LocaleScanner.php index 49aec06b1fdf..6d952a582494 100644 --- a/src/Symfony/Component/Intl/Data/Util/LocaleScanner.php +++ b/src/Symfony/Component/Intl/Data/Util/LocaleScanner.php @@ -33,14 +33,12 @@ class LocaleScanner /** * Returns all locales found in the given directory. * - * @param string $sourceDir The directory with ICU files - * * @return array An array of locales. The result also contains locales that * are in fact just aliases for other locales. Use * {@link scanAliases()} to determine which of the locales * are aliases */ - public function scanLocales($sourceDir) + public function scanLocales(string $sourceDir): array { $locales = glob($sourceDir.'/*.txt'); @@ -60,12 +58,10 @@ public function scanLocales($sourceDir) /** * Returns all locale aliases found in the given directory. * - * @param string $sourceDir The directory with ICU files - * * @return array An array with the locale aliases as keys and the aliased * locales as values */ - public function scanAliases($sourceDir) + public function scanAliases(string $sourceDir): array { $locales = $this->scanLocales($sourceDir); $aliases = []; diff --git a/src/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php b/src/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php index b637e174acbe..91eb73e6b3b0 100644 --- a/src/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php +++ b/src/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php @@ -74,7 +74,7 @@ public function __construct(string $pattern, string $timezone) * * @return string The formatted value */ - public function format(\DateTime $dateTime) + public function format(\DateTime $dateTime): string { $formatted = preg_replace_callback($this->regExp, function ($matches) use ($dateTime) { return $this->formatReplace($matches[0], $dateTime); @@ -120,7 +120,7 @@ private function formatReplace(string $dateChars, \DateTime $dateTime): string * * @throws \InvalidArgumentException When the value can not be matched with pattern */ - public function parse(\DateTime $dateTime, $value) + public function parse(\DateTime $dateTime, string $value) { $reverseMatchingRegExp = $this->getReverseMatchingRegExp($this->pattern); $reverseMatchingRegExp = '/^'.$reverseMatchingRegExp.'$/'; diff --git a/src/Symfony/Component/Intl/DateFormatter/DateFormat/TimezoneTransformer.php b/src/Symfony/Component/Intl/DateFormatter/DateFormat/TimezoneTransformer.php index 11284b34a2d6..1bcae1bd777f 100644 --- a/src/Symfony/Component/Intl/DateFormatter/DateFormat/TimezoneTransformer.php +++ b/src/Symfony/Component/Intl/DateFormatter/DateFormat/TimezoneTransformer.php @@ -97,7 +97,7 @@ public function extractDateOptions(string $matched, int $length): array * @throws NotImplementedException When the GMT time zone have minutes offset different than zero * @throws \InvalidArgumentException When the value can not be matched with pattern */ - public static function getEtcTimeZoneId($formattedTimeZone) + public static function getEtcTimeZoneId(string $formattedTimeZone): string { if (preg_match('/GMT(?P[+-])(?P\d{2}):?(?P\d{2})/', $formattedTimeZone, $matches)) { $hours = (int) $matches['hours']; diff --git a/src/Symfony/Component/Intl/Globals/IntlGlobals.php b/src/Symfony/Component/Intl/Globals/IntlGlobals.php index 246cf6afbac0..615107e6e400 100644 --- a/src/Symfony/Component/Intl/Globals/IntlGlobals.php +++ b/src/Symfony/Component/Intl/Globals/IntlGlobals.php @@ -58,10 +58,8 @@ abstract class IntlGlobals * Returns whether the error code indicates a failure. * * @param int $errorCode The error code returned by IntlGlobals::getErrorCode() - * - * @return bool */ - public static function isFailure($errorCode) + public static function isFailure(int $errorCode): bool { return isset(self::$errorCodes[$errorCode]) && $errorCode > self::U_ZERO_ERROR; @@ -83,10 +81,8 @@ public static function getErrorCode() * Returns the error message of the last operation. * * Returns "U_ZERO_ERROR" if no error occurred. - * - * @return string */ - public static function getErrorMessage() + public static function getErrorMessage(): string { return self::$errorMessage; } @@ -95,10 +91,8 @@ public static function getErrorMessage() * Returns the symbolic name for a given error code. * * @param int $code The error code returned by IntlGlobals::getErrorCode() - * - * @return string */ - public static function getErrorName($code) + public static function getErrorName(int $code): string { return self::$errorCodes[$code] ?? '[BOGUS UErrorCode]'; } @@ -111,7 +105,7 @@ public static function getErrorName($code) * * @throws \InvalidArgumentException If the code is not one of the error constants in this class */ - public static function setError($code, $message = '') + public static function setError(int $code, string $message = '') { if (!isset(self::$errorCodes[$code])) { throw new \InvalidArgumentException(sprintf('No such error code: "%s"', $code)); diff --git a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php index 5180736ce836..b84991e31b82 100644 --- a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php +++ b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php @@ -169,7 +169,7 @@ public function getResource($idx = 0) * * @internal */ - public function getResources() + public function getResources(): array { return $this->results; } diff --git a/src/Symfony/Component/Ldap/Security/LdapUser.php b/src/Symfony/Component/Ldap/Security/LdapUser.php index ce20f2fd5233..b461b9485b43 100644 --- a/src/Symfony/Component/Ldap/Security/LdapUser.php +++ b/src/Symfony/Component/Ldap/Security/LdapUser.php @@ -57,7 +57,7 @@ public function getRoles() /** * {@inheritdoc} */ - public function getPassword() + public function getPassword(): ?string { return $this->password; } @@ -65,14 +65,14 @@ public function getPassword() /** * {@inheritdoc} */ - public function getSalt() + public function getSalt(): ?string { } /** * {@inheritdoc} */ - public function getUsername() + public function getUsername(): string { return $this->username; } diff --git a/src/Symfony/Component/Lock/Store/SemaphoreStore.php b/src/Symfony/Component/Lock/Store/SemaphoreStore.php index d9fefeea7a5e..6e26aabb6b91 100644 --- a/src/Symfony/Component/Lock/Store/SemaphoreStore.php +++ b/src/Symfony/Component/Lock/Store/SemaphoreStore.php @@ -27,11 +27,9 @@ class SemaphoreStore implements StoreInterface, BlockingStoreInterface /** * Returns whether or not the store is supported. * - * @return bool - * * @internal */ - public static function isSupported() + public static function isSupported(): bool { return \extension_loaded('sysvsem'); } diff --git a/src/Symfony/Component/Messenger/MessageBus.php b/src/Symfony/Component/Messenger/MessageBus.php index d6e0219013b3..e860457bcbff 100644 --- a/src/Symfony/Component/Messenger/MessageBus.php +++ b/src/Symfony/Component/Messenger/MessageBus.php @@ -44,7 +44,7 @@ public function __construct(\Traversable $middlewareHandlers) $this->middlewareHandlers = $middlewareHandlers; } - public function getIterator() + public function getIterator(): \Traversable { if (null === $this->cachedIterator) { $this->cachedIterator = new \ArrayObject(iterator_to_array($this->middlewareHandlers, false)); diff --git a/src/Symfony/Component/Process/Pipes/AbstractPipes.php b/src/Symfony/Component/Process/Pipes/AbstractPipes.php index 9dd415d5c9a9..69b0b3bb50e2 100644 --- a/src/Symfony/Component/Process/Pipes/AbstractPipes.php +++ b/src/Symfony/Component/Process/Pipes/AbstractPipes.php @@ -54,10 +54,8 @@ public function close() /** * Returns true if a system call has been interrupted. - * - * @return bool */ - protected function hasSystemCallBeenInterrupted() + protected function hasSystemCallBeenInterrupted(): bool { $lastError = $this->lastError; $this->lastError = null; @@ -92,7 +90,7 @@ protected function unblock() * * @throws InvalidArgumentException When an input iterator yields a non supported value */ - protected function write() + protected function write(): ?array { if (!isset($this->pipes[0])) { return null; diff --git a/src/Symfony/Component/Process/Pipes/UnixPipes.php b/src/Symfony/Component/Process/Pipes/UnixPipes.php index 875ee6ab8e88..b9be0bc8f40d 100644 --- a/src/Symfony/Component/Process/Pipes/UnixPipes.php +++ b/src/Symfony/Component/Process/Pipes/UnixPipes.php @@ -43,7 +43,7 @@ public function __destruct() /** * {@inheritdoc} */ - public function getDescriptors() + public function getDescriptors(): array { if (!$this->haveReadSupport) { $nullstream = fopen('/dev/null', 'c'); @@ -81,7 +81,7 @@ public function getDescriptors() /** * {@inheritdoc} */ - public function getFiles() + public function getFiles(): array { return []; } @@ -89,7 +89,7 @@ public function getFiles() /** * {@inheritdoc} */ - public function readAndWrite($blocking, $close = false) + public function readAndWrite($blocking, $close = false): array { $this->unblock(); $w = $this->write(); @@ -138,7 +138,7 @@ public function readAndWrite($blocking, $close = false) /** * {@inheritdoc} */ - public function haveReadSupport() + public function haveReadSupport(): bool { return $this->haveReadSupport; } @@ -146,7 +146,7 @@ public function haveReadSupport() /** * {@inheritdoc} */ - public function areOpen() + public function areOpen(): bool { return (bool) $this->pipes; } diff --git a/src/Symfony/Component/Process/Pipes/WindowsPipes.php b/src/Symfony/Component/Process/Pipes/WindowsPipes.php index 0e38d7262b15..299bb3223dc7 100644 --- a/src/Symfony/Component/Process/Pipes/WindowsPipes.php +++ b/src/Symfony/Component/Process/Pipes/WindowsPipes.php @@ -93,7 +93,7 @@ public function __destruct() /** * {@inheritdoc} */ - public function getDescriptors() + public function getDescriptors(): array { if (!$this->haveReadSupport) { $nullstream = fopen('NUL', 'c'); @@ -118,7 +118,7 @@ public function getDescriptors() /** * {@inheritdoc} */ - public function getFiles() + public function getFiles(): array { return $this->files; } @@ -126,7 +126,7 @@ public function getFiles() /** * {@inheritdoc} */ - public function readAndWrite($blocking, $close = false) + public function readAndWrite($blocking, $close = false): array { $this->unblock(); $w = $this->write(); @@ -161,7 +161,7 @@ public function readAndWrite($blocking, $close = false) /** * {@inheritdoc} */ - public function haveReadSupport() + public function haveReadSupport(): bool { return $this->haveReadSupport; } @@ -169,7 +169,7 @@ public function haveReadSupport() /** * {@inheritdoc} */ - public function areOpen() + public function areOpen(): bool { return $this->pipes && $this->fileHandles; } diff --git a/src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php b/src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php index e442368bb666..e031a359ae2e 100644 --- a/src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php +++ b/src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php @@ -73,7 +73,7 @@ public function __construct(DocBlockFactoryInterface $docBlockFactory = null, ar /** * {@inheritdoc} */ - public function getShortDescription($class, $property, array $context = []) + public function getShortDescription($class, $property, array $context = []): ?string { /** @var $docBlock DocBlock */ list($docBlock) = $this->getDocBlock($class, $property); @@ -101,7 +101,7 @@ public function getShortDescription($class, $property, array $context = []) /** * {@inheritdoc} */ - public function getLongDescription($class, $property, array $context = []) + public function getLongDescription($class, $property, array $context = []): ?string { /** @var $docBlock DocBlock */ list($docBlock) = $this->getDocBlock($class, $property); @@ -117,7 +117,7 @@ public function getLongDescription($class, $property, array $context = []) /** * {@inheritdoc} */ - public function getTypes($class, $property, array $context = []) + public function getTypes($class, $property, array $context = []): ?array { /** @var $docBlock DocBlock */ list($docBlock, $source, $prefix) = $this->getDocBlock($class, $property); diff --git a/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php b/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php index c7a96d4bf996..fa8b7a85f918 100644 --- a/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php +++ b/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php @@ -75,7 +75,7 @@ public function __construct(array $mutatorPrefixes = null, array $accessorPrefix /** * {@inheritdoc} */ - public function getProperties($class, array $context = []) + public function getProperties($class, array $context = []): ?array { try { $reflectionClass = new \ReflectionClass($class); @@ -131,7 +131,7 @@ public function getProperties($class, array $context = []) /** * {@inheritdoc} */ - public function getTypes($class, $property, array $context = []) + public function getTypes($class, $property, array $context = []): ?array { if ($fromMutator = $this->extractFromMutator($class, $property)) { return $fromMutator; @@ -158,7 +158,7 @@ public function getTypes($class, $property, array $context = []) /** * {@inheritdoc} */ - public function isReadable($class, $property, array $context = []) + public function isReadable($class, $property, array $context = []): ?bool { if ($this->isAllowedProperty($class, $property)) { return true; @@ -172,7 +172,7 @@ public function isReadable($class, $property, array $context = []) /** * {@inheritdoc} */ - public function isWritable($class, $property, array $context = []) + public function isWritable($class, $property, array $context = []): ?bool { if ($this->isAllowedProperty($class, $property)) { return true; diff --git a/src/Symfony/Component/PropertyInfo/Extractor/SerializerExtractor.php b/src/Symfony/Component/PropertyInfo/Extractor/SerializerExtractor.php index 3a67704e5104..a950d46ce145 100644 --- a/src/Symfony/Component/PropertyInfo/Extractor/SerializerExtractor.php +++ b/src/Symfony/Component/PropertyInfo/Extractor/SerializerExtractor.php @@ -33,7 +33,7 @@ public function __construct(ClassMetadataFactoryInterface $classMetadataFactory) /** * {@inheritdoc} */ - public function getProperties($class, array $context = []) + public function getProperties($class, array $context = []): ?array { if (!isset($context['serializer_groups']) || !\is_array($context['serializer_groups'])) { return null; diff --git a/src/Symfony/Component/PropertyInfo/PropertyInfoCacheExtractor.php b/src/Symfony/Component/PropertyInfo/PropertyInfoCacheExtractor.php index 0eb9f63a5485..1dc52bea29f1 100644 --- a/src/Symfony/Component/PropertyInfo/PropertyInfoCacheExtractor.php +++ b/src/Symfony/Component/PropertyInfo/PropertyInfoCacheExtractor.php @@ -35,7 +35,7 @@ public function __construct(PropertyInfoExtractorInterface $propertyInfoExtracto /** * {@inheritdoc} */ - public function isReadable($class, $property, array $context = []) + public function isReadable($class, $property, array $context = []): ?bool { return $this->extract('isReadable', [$class, $property, $context]); } @@ -43,7 +43,7 @@ public function isReadable($class, $property, array $context = []) /** * {@inheritdoc} */ - public function isWritable($class, $property, array $context = []) + public function isWritable($class, $property, array $context = []): ?bool { return $this->extract('isWritable', [$class, $property, $context]); } @@ -51,7 +51,7 @@ public function isWritable($class, $property, array $context = []) /** * {@inheritdoc} */ - public function getShortDescription($class, $property, array $context = []) + public function getShortDescription($class, $property, array $context = []): ?string { return $this->extract('getShortDescription', [$class, $property, $context]); } @@ -59,7 +59,7 @@ public function getShortDescription($class, $property, array $context = []) /** * {@inheritdoc} */ - public function getLongDescription($class, $property, array $context = []) + public function getLongDescription($class, $property, array $context = []): ?string { return $this->extract('getLongDescription', [$class, $property, $context]); } @@ -67,7 +67,7 @@ public function getLongDescription($class, $property, array $context = []) /** * {@inheritdoc} */ - public function getProperties($class, array $context = []) + public function getProperties($class, array $context = []): ?array { return $this->extract('getProperties', [$class, $context]); } @@ -75,7 +75,7 @@ public function getProperties($class, array $context = []) /** * {@inheritdoc} */ - public function getTypes($class, $property, array $context = []) + public function getTypes($class, $property, array $context = []): ?array { return $this->extract('getTypes', [$class, $property, $context]); } diff --git a/src/Symfony/Component/PropertyInfo/PropertyInfoExtractor.php b/src/Symfony/Component/PropertyInfo/PropertyInfoExtractor.php index 154876561dc0..63955804368e 100644 --- a/src/Symfony/Component/PropertyInfo/PropertyInfoExtractor.php +++ b/src/Symfony/Component/PropertyInfo/PropertyInfoExtractor.php @@ -45,7 +45,7 @@ public function __construct(iterable $listExtractors = [], iterable $typeExtract /** * {@inheritdoc} */ - public function getProperties($class, array $context = []) + public function getProperties($class, array $context = []): ?array { return $this->extract($this->listExtractors, 'getProperties', [$class, $context]); } @@ -53,7 +53,7 @@ public function getProperties($class, array $context = []) /** * {@inheritdoc} */ - public function getShortDescription($class, $property, array $context = []) + public function getShortDescription($class, $property, array $context = []): ?string { return $this->extract($this->descriptionExtractors, 'getShortDescription', [$class, $property, $context]); } @@ -61,7 +61,7 @@ public function getShortDescription($class, $property, array $context = []) /** * {@inheritdoc} */ - public function getLongDescription($class, $property, array $context = []) + public function getLongDescription($class, $property, array $context = []): ?string { return $this->extract($this->descriptionExtractors, 'getLongDescription', [$class, $property, $context]); } @@ -69,7 +69,7 @@ public function getLongDescription($class, $property, array $context = []) /** * {@inheritdoc} */ - public function getTypes($class, $property, array $context = []) + public function getTypes($class, $property, array $context = []): ?array { return $this->extract($this->typeExtractors, 'getTypes', [$class, $property, $context]); } @@ -77,7 +77,7 @@ public function getTypes($class, $property, array $context = []) /** * {@inheritdoc} */ - public function isReadable($class, $property, array $context = []) + public function isReadable($class, $property, array $context = []): ?bool { return $this->extract($this->accessExtractors, 'isReadable', [$class, $property, $context]); } @@ -85,7 +85,7 @@ public function isReadable($class, $property, array $context = []) /** * {@inheritdoc} */ - public function isWritable($class, $property, array $context = []) + public function isWritable($class, $property, array $context = []): ?bool { return $this->extract($this->accessExtractors, 'isWritable', [$class, $property, $context]); } diff --git a/src/Symfony/Component/Routing/Loader/Configurator/CollectionConfigurator.php b/src/Symfony/Component/Routing/Loader/Configurator/CollectionConfigurator.php index d9be607d9b97..d1b10c4c9b19 100644 --- a/src/Symfony/Component/Routing/Loader/Configurator/CollectionConfigurator.php +++ b/src/Symfony/Component/Routing/Loader/Configurator/CollectionConfigurator.php @@ -47,10 +47,8 @@ public function __destruct() /** * Creates a sub-collection. - * - * @return self */ - final public function collection($name = '') + final public function collection($name = ''): self { return new self($this->collection, $this->name.$name, $this, $this->prefixes); } diff --git a/src/Symfony/Component/Routing/Loader/Configurator/RoutingConfigurator.php b/src/Symfony/Component/Routing/Loader/Configurator/RoutingConfigurator.php index a315cfb4ad07..f9c347e81a3f 100644 --- a/src/Symfony/Component/Routing/Loader/Configurator/RoutingConfigurator.php +++ b/src/Symfony/Component/Routing/Loader/Configurator/RoutingConfigurator.php @@ -33,10 +33,7 @@ public function __construct(RouteCollection $collection, PhpFileLoader $loader, $this->file = $file; } - /** - * @return ImportConfigurator - */ - final public function import($resource, $type = null, $ignoreErrors = false) + final public function import($resource, $type = null, $ignoreErrors = false): ImportConfigurator { $this->loader->setCurrentDir(\dirname($this->path)); $imported = $this->loader->import($resource, $type, $ignoreErrors, $this->file); @@ -52,10 +49,7 @@ final public function import($resource, $type = null, $ignoreErrors = false) return new ImportConfigurator($this->collection, $mergedCollection); } - /** - * @return CollectionConfigurator - */ - final public function collection($name = '') + final public function collection($name = ''): CollectionConfigurator { return new CollectionConfigurator($this->collection, $name); } diff --git a/src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php index 078e6c71aad6..441900775114 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php @@ -49,7 +49,7 @@ protected function setUp(): void { $reader = new AnnotationReader(); $this->loader = new class($reader) extends AnnotationClassLoader { - protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, $annot) + protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, $annot): void { } }; @@ -241,7 +241,7 @@ public function testInvokableClassMultipleRouteLoad() ->willReturn([]) ; $loader = new class($reader) extends AnnotationClassLoader { - protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, $annot) + protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, $annot): void { } }; @@ -323,7 +323,7 @@ public function testDefaultRouteName() ; $loader = new class($reader) extends AnnotationClassLoader { - protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, $annot) + protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, $annot): void { } }; diff --git a/src/Symfony/Component/Security/Core/Authentication/RememberMe/PersistentToken.php b/src/Symfony/Component/Security/Core/Authentication/RememberMe/PersistentToken.php index 7c12706e3c3c..1f0e485c50ef 100644 --- a/src/Symfony/Component/Security/Core/Authentication/RememberMe/PersistentToken.php +++ b/src/Symfony/Component/Security/Core/Authentication/RememberMe/PersistentToken.php @@ -49,7 +49,7 @@ public function __construct(string $class, string $username, string $series, str /** * {@inheritdoc} */ - public function getClass() + public function getClass(): string { return $this->class; } @@ -57,7 +57,7 @@ public function getClass() /** * {@inheritdoc} */ - public function getUsername() + public function getUsername(): string { return $this->username; } @@ -65,7 +65,7 @@ public function getUsername() /** * {@inheritdoc} */ - public function getSeries() + public function getSeries(): string { return $this->series; } @@ -73,7 +73,7 @@ public function getSeries() /** * {@inheritdoc} */ - public function getTokenValue() + public function getTokenValue(): string { return $this->tokenValue; } @@ -81,7 +81,7 @@ public function getTokenValue() /** * {@inheritdoc} */ - public function getLastUsed() + public function getLastUsed(): \DateTime { return $this->lastUsed; } diff --git a/src/Symfony/Component/Security/Core/Authorization/AuthorizationChecker.php b/src/Symfony/Component/Security/Core/Authorization/AuthorizationChecker.php index db3009574364..3200e991df5b 100644 --- a/src/Symfony/Component/Security/Core/Authorization/AuthorizationChecker.php +++ b/src/Symfony/Component/Security/Core/Authorization/AuthorizationChecker.php @@ -43,7 +43,7 @@ public function __construct(TokenStorageInterface $tokenStorage, AuthenticationM * * @throws AuthenticationCredentialsNotFoundException when the token storage has no authentication token */ - final public function isGranted($attributes, $subject = null) + final public function isGranted($attributes, $subject = null): bool { if (null === ($token = $this->tokenStorage->getToken())) { throw new AuthenticationCredentialsNotFoundException('The token storage contains no authentication token. One possible reason may be that there is no firewall configured for this URL.'); diff --git a/src/Symfony/Component/Security/Core/Authorization/TraceableAccessDecisionManager.php b/src/Symfony/Component/Security/Core/Authorization/TraceableAccessDecisionManager.php index 88ec27afd688..1115f9dddbf9 100644 --- a/src/Symfony/Component/Security/Core/Authorization/TraceableAccessDecisionManager.php +++ b/src/Symfony/Component/Security/Core/Authorization/TraceableAccessDecisionManager.php @@ -48,7 +48,7 @@ public function __construct(AccessDecisionManagerInterface $manager) /** * {@inheritdoc} */ - public function decide(TokenInterface $token, array $attributes, $object = null) + public function decide(TokenInterface $token, array $attributes, $object = null): bool { $currentDecisionLog = [ 'attributes' => $attributes, @@ -86,7 +86,7 @@ public function addVoterVote(VoterInterface $voter, array $attributes, int $vote /** * @return string */ - public function getStrategy() + public function getStrategy(): string { // The $strategy property is misleading because it stores the name of its // method (e.g. 'decideAffirmative') instead of the original strategy name @@ -97,7 +97,7 @@ public function getStrategy() /** * @return iterable|VoterInterface[] */ - public function getVoters() + public function getVoters(): iterable { return $this->voters; } @@ -105,7 +105,7 @@ public function getVoters() /** * @return array */ - public function getDecisionLog() + public function getDecisionLog(): array { return $this->decisionLog; } diff --git a/src/Symfony/Component/Security/Core/Security.php b/src/Symfony/Component/Security/Core/Security.php index f739a70d31c6..334fbd8d283a 100644 --- a/src/Symfony/Component/Security/Core/Security.php +++ b/src/Symfony/Component/Security/Core/Security.php @@ -61,19 +61,14 @@ public function getUser() * * @param mixed $attributes * @param mixed $subject - * - * @return bool */ - public function isGranted($attributes, $subject = null) + public function isGranted($attributes, $subject = null): bool { return $this->container->get('security.authorization_checker') ->isGranted($attributes, $subject); } - /** - * @return TokenInterface|null - */ - public function getToken() + public function getToken(): ?TokenInterface { return $this->container->get('security.token_storage')->getToken(); } diff --git a/src/Symfony/Component/Security/Core/User/MissingUserProvider.php b/src/Symfony/Component/Security/Core/User/MissingUserProvider.php index 9605cf3168ec..9cc8eb9ee23c 100644 --- a/src/Symfony/Component/Security/Core/User/MissingUserProvider.php +++ b/src/Symfony/Component/Security/Core/User/MissingUserProvider.php @@ -32,7 +32,7 @@ public function __construct(string $firewall) /** * {@inheritdoc} */ - public function loadUserByUsername($username) + public function loadUserByUsername($username): UserInterface { throw new \BadMethodCallException(); } @@ -40,7 +40,7 @@ public function loadUserByUsername($username) /** * {@inheritdoc} */ - public function refreshUser(UserInterface $user) + public function refreshUser(UserInterface $user): UserInterface { throw new \BadMethodCallException(); } @@ -48,7 +48,7 @@ public function refreshUser(UserInterface $user) /** * {@inheritdoc} */ - public function supportsClass($class) + public function supportsClass($class): bool { throw new \BadMethodCallException(); } diff --git a/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordJsonAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordJsonAuthenticationListener.php index 8606899a7ed7..5393fbef1047 100644 --- a/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordJsonAuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordJsonAuthenticationListener.php @@ -140,10 +140,7 @@ public function __invoke(RequestEvent $event) $event->setResponse($response); } - /** - * @return Response|null - */ - private function onSuccess(Request $request, TokenInterface $token) + private function onSuccess(Request $request, TokenInterface $token): ?Response { if (null !== $this->logger) { $this->logger->info('User has been authenticated successfully.', ['username' => $token->getUsername()]); diff --git a/src/Symfony/Component/Serializer/Encoder/ChainDecoder.php b/src/Symfony/Component/Serializer/Encoder/ChainDecoder.php index 0100a6282fa0..2a55d93a6066 100644 --- a/src/Symfony/Component/Serializer/Encoder/ChainDecoder.php +++ b/src/Symfony/Component/Serializer/Encoder/ChainDecoder.php @@ -43,7 +43,7 @@ final public function decode($data, $format, array $context = []) /** * {@inheritdoc} */ - public function supportsDecoding($format, array $context = []) + public function supportsDecoding($format, array $context = []): bool { try { $this->getDecoder($format, $context); diff --git a/src/Symfony/Component/Serializer/Encoder/ChainEncoder.php b/src/Symfony/Component/Serializer/Encoder/ChainEncoder.php index 7e8d4c8d1291..b13333e88aab 100644 --- a/src/Symfony/Component/Serializer/Encoder/ChainEncoder.php +++ b/src/Symfony/Component/Serializer/Encoder/ChainEncoder.php @@ -43,7 +43,7 @@ final public function encode($data, $format, array $context = []) /** * {@inheritdoc} */ - public function supportsEncoding($format, array $context = []) + public function supportsEncoding($format, array $context = []): bool { try { $this->getEncoder($format, $context); @@ -56,12 +56,8 @@ public function supportsEncoding($format, array $context = []) /** * Checks whether the normalization is needed for the given format. - * - * @param string $format - * - * @return bool */ - public function needsNormalization($format, array $context = []) + public function needsNormalization(string $format, array $context = []): bool { $encoder = $this->getEncoder($format, $context); diff --git a/src/Symfony/Component/Serializer/Normalizer/ArrayDenormalizer.php b/src/Symfony/Component/Serializer/Normalizer/ArrayDenormalizer.php index 01f15ab10055..d4ea8fd46505 100644 --- a/src/Symfony/Component/Serializer/Normalizer/ArrayDenormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/ArrayDenormalizer.php @@ -66,7 +66,7 @@ public function denormalize($data, $type, $format = null, array $context = []) /** * {@inheritdoc} */ - public function supportsDenormalization($data, $type, $format = null, array $context = []) + public function supportsDenormalization($data, $type, $format = null, array $context = []): bool { return '[]' === substr($type, -2) && $this->serializer->supportsDenormalization($data, substr($type, 0, -2), $format, $context); diff --git a/src/Symfony/Component/Serializer/Serializer.php b/src/Symfony/Component/Serializer/Serializer.php index dbd670e4e6a0..b0bf6a3ff683 100644 --- a/src/Symfony/Component/Serializer/Serializer.php +++ b/src/Symfony/Component/Serializer/Serializer.php @@ -115,7 +115,7 @@ public function __construct(array $normalizers = [], array $encoders = []) /** * {@inheritdoc} */ - final public function serialize($data, $format, array $context = []) + final public function serialize($data, $format, array $context = []): string { if (!$this->supportsEncoding($format, $context)) { throw new NotEncodableValueException(sprintf('Serialization for the format %s is not supported', $format)); diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php index 0b4c5f5e6d20..577db7086f1d 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php @@ -770,12 +770,12 @@ public function testExtractAttributesRespectsContext() public function testAdvancedNameConverter() { $nameConverter = new class() implements AdvancedNameConverterInterface { - public function normalize($propertyName, string $class = null, string $format = null, array $context = []) + public function normalize($propertyName, string $class = null, string $format = null, array $context = []): string { return sprintf('%s-%s-%s-%s', $propertyName, $class, $format, $context['foo']); } - public function denormalize($propertyName, string $class = null, string $format = null, array $context = []) + public function denormalize($propertyName, string $class = null, string $format = null, array $context = []): string { return sprintf('%s-%s-%s-%s', $propertyName, $class, $format, $context['foo']); } diff --git a/src/Symfony/Component/Translation/Command/XliffLintCommand.php b/src/Symfony/Component/Translation/Command/XliffLintCommand.php index b03da24cdba2..703106187653 100644 --- a/src/Symfony/Component/Translation/Command/XliffLintCommand.php +++ b/src/Symfony/Component/Translation/Command/XliffLintCommand.php @@ -223,10 +223,7 @@ private function getFiles(string $fileOrDirectory) } } - /** - * @return string|null - */ - private function getStdin() + private function getStdin(): ?string { if (0 !== ftell(STDIN)) { return null; diff --git a/src/Symfony/Component/Validator/Constraint.php b/src/Symfony/Component/Validator/Constraint.php index 349698eb1af5..569ccfa93d4b 100644 --- a/src/Symfony/Component/Validator/Constraint.php +++ b/src/Symfony/Component/Validator/Constraint.php @@ -286,11 +286,9 @@ public function getTargets() /** * Optimizes the serialized value to minimize storage space. * - * @return array The properties to serialize - * * @internal */ - public function __sleep() + public function __sleep(): array { // Initialize "groups" option if it is not set $this->groups; diff --git a/src/Symfony/Component/Validator/Constraints/DateValidator.php b/src/Symfony/Component/Validator/Constraints/DateValidator.php index 93b1f7d074e1..291159b24efd 100644 --- a/src/Symfony/Component/Validator/Constraints/DateValidator.php +++ b/src/Symfony/Component/Validator/Constraints/DateValidator.php @@ -26,15 +26,9 @@ class DateValidator extends ConstraintValidator /** * Checks whether a date is valid. * - * @param int $year The year - * @param int $month The month - * @param int $day The day - * - * @return bool Whether the date is valid - * * @internal */ - public static function checkDate($year, $month, $day) + public static function checkDate(int $year, int $month, int $day): bool { return checkdate($month, $day, $year); } diff --git a/src/Symfony/Component/Validator/Constraints/TimeValidator.php b/src/Symfony/Component/Validator/Constraints/TimeValidator.php index 799dbc3108e0..91247d9af7b1 100644 --- a/src/Symfony/Component/Validator/Constraints/TimeValidator.php +++ b/src/Symfony/Component/Validator/Constraints/TimeValidator.php @@ -26,15 +26,9 @@ class TimeValidator extends ConstraintValidator /** * Checks whether a time is valid. * - * @param int $hour The hour - * @param int $minute The minute - * @param int $second The second - * - * @return bool Whether the time is valid - * * @internal */ - public static function checkTime($hour, $minute, $second) + public static function checkTime(int $hour, int $minute, float $second): bool { return $hour >= 0 && $hour < 24 && $minute >= 0 && $minute < 60 && $second >= 0 && $second < 60; } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php index ee10a26f4f6f..8ad07d940cae 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php @@ -72,7 +72,7 @@ public function getValidValues() ['090909'], [90909], [new class() { - public function __toString() + public function __toString(): string { return '090909'; } @@ -116,7 +116,7 @@ public function getInvalidValues() ['abcd'], ['090foo'], [new class() { - public function __toString() + public function __toString(): string { return 'abcd'; } diff --git a/src/Symfony/Component/WebLink/EventListener/AddLinkHeaderListener.php b/src/Symfony/Component/WebLink/EventListener/AddLinkHeaderListener.php index d743f4664c30..3027529a8455 100644 --- a/src/Symfony/Component/WebLink/EventListener/AddLinkHeaderListener.php +++ b/src/Symfony/Component/WebLink/EventListener/AddLinkHeaderListener.php @@ -50,7 +50,7 @@ public function onKernelResponse(ResponseEvent $event) /** * {@inheritdoc} */ - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [KernelEvents::RESPONSE => 'onKernelResponse']; } diff --git a/src/Symfony/Component/Yaml/Command/LintCommand.php b/src/Symfony/Component/Yaml/Command/LintCommand.php index c0f3e1bfc444..285610e25c48 100644 --- a/src/Symfony/Component/Yaml/Command/LintCommand.php +++ b/src/Symfony/Component/Yaml/Command/LintCommand.php @@ -199,10 +199,7 @@ private function getFiles(string $fileOrDirectory) } } - /** - * @return string|null - */ - private function getStdin() + private function getStdin(): ?string { if (0 !== ftell(STDIN)) { return null; diff --git a/src/Symfony/Component/Yaml/Inline.php b/src/Symfony/Component/Yaml/Inline.php index 04e3e776bfb4..d2481c486971 100644 --- a/src/Symfony/Component/Yaml/Inline.php +++ b/src/Symfony/Component/Yaml/Inline.php @@ -34,12 +34,7 @@ class Inline private static $objectForMap = false; private static $constantSupport = false; - /** - * @param int $flags - * @param int|null $parsedLineNumber - * @param string|null $parsedFilename - */ - public static function initialize($flags, $parsedLineNumber = null, $parsedFilename = null) + public static function initialize(int $flags, int $parsedLineNumber = null, string $parsedFilename = null) { self::$exceptionOnInvalidType = (bool) (Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE & $flags); self::$objectSupport = (bool) (Yaml::PARSE_OBJECT & $flags);