From 4f806062d50604b0cb340eb6a9daa1ec67a91244 Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Sat, 22 Apr 2023 23:52:28 +0200 Subject: [PATCH] Add remaining missing return types to safe methods --- .github/expected-missing-return-types.diff | 61 ++----------------- .../Monolog/Handler/NotifierHandler.php | 2 +- .../Monolog/Handler/ServerLogHandler.php | 2 +- .../Bridge/Twig/Command/DebugCommand.php | 2 +- .../Bridge/Twig/Command/LintCommand.php | 8 +-- .../Twig/Extension/WorkflowExtension.php | 2 +- .../Command/ConfigDebugCommand.php | 2 +- .../Console/Descriptor/Descriptor.php | 4 +- .../Console/Descriptor/MarkdownDescriptor.php | 22 +++++-- .../Debug/TraceableListenerTrait.php | 4 +- .../Csp/ContentSecurityPolicyHandler.php | 2 +- src/Symfony/Component/Cache/LockRegistry.php | 5 +- .../Cache/Marshaller/DefaultMarshaller.php | 2 +- .../Cache/Traits/AbstractAdapterTrait.php | 2 +- .../Component/Cache/Traits/ContractsTrait.php | 2 +- .../Cache/Traits/FilesystemCommonTrait.php | 4 +- .../Console/Descriptor/Descriptor.php | 10 +-- .../Component/Console/Helper/ProgressBar.php | 2 +- .../RegisterAutoconfigureAttributesPass.php | 8 ++- .../Component/ErrorHandler/ErrorHandler.php | 6 +- .../Node/ConditionalNode.php | 2 +- .../ExpressionLanguage/Node/FunctionNode.php | 2 +- .../ExpressionLanguage/Node/UnaryNode.php | 2 +- .../HttpClient/Response/AsyncResponse.php | 3 + .../Response/CommonResponseTrait.php | 3 + .../Data/Generator/AbstractDataGenerator.php | 4 +- .../Util/ArrayAccessibleResourceBundle.php | 2 +- .../Intl/Data/Util/RecursiveArrayAccess.php | 2 +- .../Component/Mailer/Transport/Dsn.php | 2 +- .../Tests/Transport/ConnectionTest.php | 33 ++++------ .../Transport/DoctrineIntegrationTest.php | 3 +- .../DoctrineTransportFactoryTest.php | 1 + .../Transport/PostgreSqlConnectionTest.php | 6 ++ .../Bridge/Doctrine/Transport/Connection.php | 15 ++--- .../Command/AbstractFailedMessagesCommand.php | 2 +- .../Messenger/Handler/HandlerDescriptor.php | 2 +- .../Transport/Serialization/PhpSerializer.php | 2 +- src/Symfony/Component/Mime/Header/Headers.php | 2 +- .../Component/Notifier/Transport/Dsn.php | 4 +- src/Symfony/Component/Process/Process.php | 4 +- .../Component/RateLimiter/Policy/Window.php | 2 +- .../Component/Routing/CompiledRoute.php | 2 +- src/Symfony/Component/Routing/Route.php | 2 +- .../Authentication/Token/AbstractToken.php | 2 +- .../Authenticator/JsonLoginAuthenticator.php | 2 +- .../Security/Http/Event/LazyResponseEvent.php | 2 +- .../Security/Http/Firewall/AccessListener.php | 4 +- .../Http/Firewall/ContextListener.php | 4 +- .../Http/Firewall/ExceptionListener.php | 2 +- .../Component/Translation/Provider/Dsn.php | 4 +- src/Symfony/Component/Yaml/Parser.php | 4 +- .../Component/Yaml/Tag/TaggedValue.php | 2 +- 52 files changed, 125 insertions(+), 155 deletions(-) diff --git a/.github/expected-missing-return-types.diff b/.github/expected-missing-return-types.diff index 92a388e798b4c..372396a814603 100644 --- a/.github/expected-missing-return-types.diff +++ b/.github/expected-missing-return-types.diff @@ -386,7 +386,7 @@ index 8bfaa0a22c..745ba6aff3 100644 { $this->debug = $debug; diff --git a/src/Symfony/Bridge/Twig/Command/DebugCommand.php b/src/Symfony/Bridge/Twig/Command/DebugCommand.php -index fe581b5987..8109e7c68d 100644 +index 43e4d9c9f1..ea0116870b 100644 --- a/src/Symfony/Bridge/Twig/Command/DebugCommand.php +++ b/src/Symfony/Bridge/Twig/Command/DebugCommand.php @@ -63,5 +63,5 @@ class DebugCommand extends Command @@ -397,7 +397,7 @@ index fe581b5987..8109e7c68d 100644 { $this diff --git a/src/Symfony/Bridge/Twig/Command/LintCommand.php b/src/Symfony/Bridge/Twig/Command/LintCommand.php -index fa8effc12a..deced50a90 100644 +index e059740a13..e7d6fbdd05 100644 --- a/src/Symfony/Bridge/Twig/Command/LintCommand.php +++ b/src/Symfony/Bridge/Twig/Command/LintCommand.php @@ -52,5 +52,5 @@ class LintCommand extends Command @@ -1500,7 +1500,7 @@ index 00e912686b..58872ec2bc 100644 { if (!$container->hasDefinition('console.command.cache_pool_prune')) { diff --git a/src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php b/src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php -index 2ee96e9b37..f49ed24f68 100644 +index 200406a564..0bad73fe6a 100644 --- a/src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php +++ b/src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php @@ -81,5 +81,5 @@ trait FilesystemCommonTrait @@ -5038,28 +5038,10 @@ index 9e107401a2..7f92321a2b 100644 + protected function registerFunctions(): void { $this->addFunction(ExpressionFunction::fromPhp('constant')); -diff --git a/src/Symfony/Component/ExpressionLanguage/Node/ConditionalNode.php b/src/Symfony/Component/ExpressionLanguage/Node/ConditionalNode.php -index fec02abaae..7d02544275 100644 ---- a/src/Symfony/Component/ExpressionLanguage/Node/ConditionalNode.php -+++ b/src/Symfony/Component/ExpressionLanguage/Node/ConditionalNode.php -@@ -41,5 +41,5 @@ class ConditionalNode extends Node - } - -- public function evaluate(array $functions, array $values) -+ public function evaluate(array $functions, array $values): mixed - { - if ($this->nodes['expr1']->evaluate($functions, $values)) { diff --git a/src/Symfony/Component/ExpressionLanguage/Node/FunctionNode.php b/src/Symfony/Component/ExpressionLanguage/Node/FunctionNode.php -index d4ab3e0922..811fec7e2e 100644 +index 33323f388f..811fec7e2e 100644 --- a/src/Symfony/Component/ExpressionLanguage/Node/FunctionNode.php +++ b/src/Symfony/Component/ExpressionLanguage/Node/FunctionNode.php -@@ -41,5 +41,5 @@ class FunctionNode extends Node - } - -- public function evaluate(array $functions, array $values) -+ public function evaluate(array $functions, array $values): mixed - { - $arguments = [$values]; @@ -54,5 +54,5 @@ class FunctionNode extends Node * @return array */ @@ -5106,17 +5088,6 @@ index f6fff09b1e..4661f7d165 100644 + protected function isHash(array $value): bool { $expectedKey = 0; -diff --git a/src/Symfony/Component/ExpressionLanguage/Node/UnaryNode.php b/src/Symfony/Component/ExpressionLanguage/Node/UnaryNode.php -index 580ee13095..55e2121fcf 100644 ---- a/src/Symfony/Component/ExpressionLanguage/Node/UnaryNode.php -+++ b/src/Symfony/Component/ExpressionLanguage/Node/UnaryNode.php -@@ -46,5 +46,5 @@ class UnaryNode extends Node - } - -- public function evaluate(array $functions, array $values) -+ public function evaluate(array $functions, array $values): mixed - { - $value = $this->nodes['node']->evaluate($functions, $values); diff --git a/src/Symfony/Component/ExpressionLanguage/ParsedExpression.php b/src/Symfony/Component/ExpressionLanguage/ParsedExpression.php index 239624ec2c..3b497d5ccf 100644 --- a/src/Symfony/Component/ExpressionLanguage/ParsedExpression.php @@ -10730,7 +10701,7 @@ index cf41e0c507..61f7397734 100644 + public function createNewToken(PersistentTokenInterface $token): void; } diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php b/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php -index 4416cda616..0fcf4303e0 100644 +index 10cb8f776e..0da1b3330e 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php +++ b/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php @@ -57,5 +57,5 @@ abstract class AbstractToken implements TokenInterface, \Serializable @@ -11173,17 +11144,6 @@ index 91271d14a3..100c2fb549 100644 - public function start(Request $request, AuthenticationException $authException = null); + public function start(Request $request, AuthenticationException $authException = null): Response; } -diff --git a/src/Symfony/Component/Security/Http/Event/LazyResponseEvent.php b/src/Symfony/Component/Security/Http/Event/LazyResponseEvent.php -index 46a25eed07..b3e25f1af3 100644 ---- a/src/Symfony/Component/Security/Http/Event/LazyResponseEvent.php -+++ b/src/Symfony/Component/Security/Http/Event/LazyResponseEvent.php -@@ -32,5 +32,5 @@ final class LazyResponseEvent extends RequestEvent - } - -- public function setResponse(Response $response) -+ public function setResponse(Response $response): void - { - $this->stopPropagation(); diff --git a/src/Symfony/Component/Security/Http/Event/LoginFailureEvent.php b/src/Symfony/Component/Security/Http/Event/LoginFailureEvent.php index 3b7c5086f2..97fb99f0b5 100644 --- a/src/Symfony/Component/Security/Http/Event/LoginFailureEvent.php @@ -11238,17 +11198,6 @@ index fc56733efa..8538f5f821 100644 + protected function callListeners(RequestEvent $event, iterable $listeners): void { foreach ($listeners as $listener) { -diff --git a/src/Symfony/Component/Security/Http/Firewall/AccessListener.php b/src/Symfony/Component/Security/Http/Firewall/AccessListener.php -index ad343ef085..9a1a2563c4 100644 ---- a/src/Symfony/Component/Security/Http/Firewall/AccessListener.php -+++ b/src/Symfony/Component/Security/Http/Firewall/AccessListener.php -@@ -65,5 +65,5 @@ class AccessListener extends AbstractListener - * @throws AccessDeniedException - */ -- public function authenticate(RequestEvent $event) -+ public function authenticate(RequestEvent $event): void - { - $request = $event->getRequest(); diff --git a/src/Symfony/Component/Security/Http/Firewall/FirewallListenerInterface.php b/src/Symfony/Component/Security/Http/Firewall/FirewallListenerInterface.php index be200c0d12..69483f8f1d 100644 --- a/src/Symfony/Component/Security/Http/Firewall/FirewallListenerInterface.php diff --git a/src/Symfony/Bridge/Monolog/Handler/NotifierHandler.php b/src/Symfony/Bridge/Monolog/Handler/NotifierHandler.php index 8576706080d44..6aedc7c36e267 100644 --- a/src/Symfony/Bridge/Monolog/Handler/NotifierHandler.php +++ b/src/Symfony/Bridge/Monolog/Handler/NotifierHandler.php @@ -71,7 +71,7 @@ private function notify(array $records): void $this->notifier->send($notification, ...$this->notifier->getAdminRecipients()); } - private function getHighestRecord(array $records) + private function getHighestRecord(array $records): array { $highestRecord = null; foreach ($records as $record) { diff --git a/src/Symfony/Bridge/Monolog/Handler/ServerLogHandler.php b/src/Symfony/Bridge/Monolog/Handler/ServerLogHandler.php index 4ba90f7efbea3..4d566885c3e46 100644 --- a/src/Symfony/Bridge/Monolog/Handler/ServerLogHandler.php +++ b/src/Symfony/Bridge/Monolog/Handler/ServerLogHandler.php @@ -126,7 +126,7 @@ protected function getDefaultFormatter(): FormatterInterface return new VarDumperFormatter(); } - private static function nullErrorHandler() + private static function nullErrorHandler(): void { } diff --git a/src/Symfony/Bridge/Twig/Command/DebugCommand.php b/src/Symfony/Bridge/Twig/Command/DebugCommand.php index fe581b5987419..43e4d9c9f12c6 100644 --- a/src/Symfony/Bridge/Twig/Command/DebugCommand.php +++ b/src/Symfony/Bridge/Twig/Command/DebugCommand.php @@ -305,7 +305,7 @@ private function getLoaderPaths(string $name = null): array return $loaderPaths; } - private function getMetadata(string $type, mixed $entity) + private function getMetadata(string $type, mixed $entity): mixed { if ('globals' === $type) { return $entity; diff --git a/src/Symfony/Bridge/Twig/Command/LintCommand.php b/src/Symfony/Bridge/Twig/Command/LintCommand.php index fa8effc12a2e4..e059740a1375d 100644 --- a/src/Symfony/Bridge/Twig/Command/LintCommand.php +++ b/src/Symfony/Bridge/Twig/Command/LintCommand.php @@ -143,7 +143,7 @@ private function getFilesInfo(array $filenames): array return $filesInfo; } - protected function findFiles(string $filename) + protected function findFiles(string $filename): iterable { if (is_file($filename)) { return [$filename]; @@ -172,7 +172,7 @@ private function validate(string $template, string $file): array return ['template' => $template, 'file' => $file, 'valid' => true]; } - private function display(InputInterface $input, OutputInterface $output, SymfonyStyle $io, array $files) + private function display(InputInterface $input, OutputInterface $output, SymfonyStyle $io, array $files): int { return match ($this->format) { 'txt' => $this->displayTxt($output, $io, $files), @@ -205,7 +205,7 @@ private function displayTxt(OutputInterface $output, SymfonyStyle $io, array $fi return min($errors, 1); } - private function displayJson(OutputInterface $output, array $filesInfo) + private function displayJson(OutputInterface $output, array $filesInfo): int { $errors = 0; @@ -224,7 +224,7 @@ private function displayJson(OutputInterface $output, array $filesInfo) return min($errors, 1); } - private function renderException(SymfonyStyle $output, string $template, Error $exception, string $file = null, GithubActionReporter $githubReporter = null) + private function renderException(SymfonyStyle $output, string $template, Error $exception, string $file = null, GithubActionReporter $githubReporter = null): void { $line = $exception->getTemplateLine(); diff --git a/src/Symfony/Bridge/Twig/Extension/WorkflowExtension.php b/src/Symfony/Bridge/Twig/Extension/WorkflowExtension.php index 71f556aead03e..661a063f98e61 100644 --- a/src/Symfony/Bridge/Twig/Extension/WorkflowExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/WorkflowExtension.php @@ -99,7 +99,7 @@ public function getMarkedPlaces(object $subject, bool $placesNameOnly = true, st * Use a string (the place name) to get place metadata * Use a Transition instance to get transition metadata */ - public function getMetadata(object $subject, string $key, string|Transition $metadataSubject = null, string $name = null) + public function getMetadata(object $subject, string $key, string|Transition $metadataSubject = null, string $name = null): mixed { return $this ->workflowRegistry diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php index 8ddfc13af61f1..f3eab9d6085cc 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php @@ -237,7 +237,7 @@ private function getAvailableBundles(bool $alias): array return $availableBundles; } - private function getConfig(ExtensionInterface $extension, ContainerBuilder $container, bool $resolveEnvs = false) + private function getConfig(ExtensionInterface $extension, ContainerBuilder $container, bool $resolveEnvs = false): mixed { return $container->resolveEnvPlaceholders( $container->getParameterBag()->resolveValue( diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php index eb5aa54ed17ad..7dd2c72206853 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php @@ -120,9 +120,9 @@ abstract protected function describeContainerEnvVars(array $envs, array $options * Common options are: * * name: name of listened event */ - abstract protected function describeEventDispatcherListeners(EventDispatcherInterface $eventDispatcher, array $options = []); + abstract protected function describeEventDispatcherListeners(EventDispatcherInterface $eventDispatcher, array $options = []): void; - abstract protected function describeCallable(mixed $callable, array $options = []); + abstract protected function describeCallable(mixed $callable, array $options = []): void; protected function formatValue(mixed $value): string { diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php index 1424001c5e81b..4581e0e198b99 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php @@ -336,7 +336,7 @@ protected function describeEventDispatcherListeners(EventDispatcherInterface $ev } } - protected function describeCallable(mixed $callable, array $options = []) + protected function describeCallable(mixed $callable, array $options = []): void { $string = ''; @@ -359,7 +359,9 @@ protected function describeCallable(mixed $callable, array $options = []) } } - return $this->write($string."\n"); + $this->write($string."\n"); + + return; } if (\is_string($callable)) { @@ -375,7 +377,9 @@ protected function describeCallable(mixed $callable, array $options = []) $string .= "\n- Static: yes"; } - return $this->write($string."\n"); + $this->write($string."\n"); + + return; } if ($callable instanceof \Closure) { @@ -383,7 +387,9 @@ protected function describeCallable(mixed $callable, array $options = []) $r = new \ReflectionFunction($callable); if (str_contains($r->name, '{closure}')) { - return $this->write($string."\n"); + $this->write($string."\n"); + + return; } $string .= "\n".sprintf('- Name: `%s`', $r->name); @@ -394,14 +400,18 @@ protected function describeCallable(mixed $callable, array $options = []) } } - return $this->write($string."\n"); + $this->write($string."\n"); + + return; } if (method_exists($callable, '__invoke')) { $string .= "\n- Type: `object`"; $string .= "\n".sprintf('- Name: `%s`', $callable::class); - return $this->write($string."\n"); + $this->write($string."\n"); + + return; } throw new \InvalidArgumentException('Callable is not describable.'); diff --git a/src/Symfony/Bundle/SecurityBundle/Debug/TraceableListenerTrait.php b/src/Symfony/Bundle/SecurityBundle/Debug/TraceableListenerTrait.php index 357d2414d8bf2..0c4ff9e5cfb90 100644 --- a/src/Symfony/Bundle/SecurityBundle/Debug/TraceableListenerTrait.php +++ b/src/Symfony/Bundle/SecurityBundle/Debug/TraceableListenerTrait.php @@ -30,12 +30,12 @@ trait TraceableListenerTrait /** * Proxies all method calls to the original listener. */ - public function __call(string $method, array $arguments) + public function __call(string $method, array $arguments): mixed { return $this->listener->{$method}(...$arguments); } - public function getWrappedListener() + public function getWrappedListener(): mixed { return $this->listener; } diff --git a/src/Symfony/Bundle/WebProfilerBundle/Csp/ContentSecurityPolicyHandler.php b/src/Symfony/Bundle/WebProfilerBundle/Csp/ContentSecurityPolicyHandler.php index 7fe5018317081..4cc0f8db1efe0 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Csp/ContentSecurityPolicyHandler.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Csp/ContentSecurityPolicyHandler.php @@ -233,7 +233,7 @@ private function hasHashOrNonce(array $directives): bool return false; } - private function getDirectiveFallback(array $directiveSet, string $type) + private function getDirectiveFallback(array $directiveSet, string $type): ?array { if (\in_array($type, ['script-src-elem', 'style-src-elem'], true) || !isset($directiveSet['default-src'])) { // Let the browser fallback on it's own diff --git a/src/Symfony/Component/Cache/LockRegistry.php b/src/Symfony/Component/Cache/LockRegistry.php index 9339e6a2c5f0d..22d71839e3b57 100644 --- a/src/Symfony/Component/Cache/LockRegistry.php +++ b/src/Symfony/Component/Cache/LockRegistry.php @@ -83,7 +83,7 @@ public static function setFiles(array $files): array return $previousFiles; } - public static function compute(callable $callback, ItemInterface $item, bool &$save, CacheInterface $pool, \Closure $setMetadata = null, LoggerInterface $logger = null) + public static function compute(callable $callback, ItemInterface $item, bool &$save, CacheInterface $pool, \Closure $setMetadata = null, LoggerInterface $logger = null): mixed { if ('\\' === \DIRECTORY_SEPARATOR && null === self::$lockedFiles) { // disable locking on Windows by default @@ -146,6 +146,9 @@ public static function compute(callable $callback, ItemInterface $item, bool &$s return null; } + /** + * @return resource|false + */ private static function open(int $key) { if (null !== $h = self::$openedFiles[$key] ?? null) { diff --git a/src/Symfony/Component/Cache/Marshaller/DefaultMarshaller.php b/src/Symfony/Component/Cache/Marshaller/DefaultMarshaller.php index e11607b3daaf2..973b137ae3eee 100644 --- a/src/Symfony/Component/Cache/Marshaller/DefaultMarshaller.php +++ b/src/Symfony/Component/Cache/Marshaller/DefaultMarshaller.php @@ -91,7 +91,7 @@ public function unmarshall(string $value): mixed /** * @internal */ - public static function handleUnserializeCallback(string $class) + public static function handleUnserializeCallback(string $class): never { throw new \DomainException('Class not found: '.$class); } diff --git a/src/Symfony/Component/Cache/Traits/AbstractAdapterTrait.php b/src/Symfony/Component/Cache/Traits/AbstractAdapterTrait.php index 10f28054ec675..fb27c90714767 100644 --- a/src/Symfony/Component/Cache/Traits/AbstractAdapterTrait.php +++ b/src/Symfony/Component/Cache/Traits/AbstractAdapterTrait.php @@ -367,7 +367,7 @@ protected function getId(mixed $key): string /** * @internal */ - public static function handleUnserializeCallback(string $class) + public static function handleUnserializeCallback(string $class): never { throw new \DomainException('Class not found: '.$class); } diff --git a/src/Symfony/Component/Cache/Traits/ContractsTrait.php b/src/Symfony/Component/Cache/Traits/ContractsTrait.php index 60b7d2bf98b4e..476883a679e3a 100644 --- a/src/Symfony/Component/Cache/Traits/ContractsTrait.php +++ b/src/Symfony/Component/Cache/Traits/ContractsTrait.php @@ -59,7 +59,7 @@ public function setCallbackWrapper(?callable $callbackWrapper): callable return $previousWrapper; } - private function doGet(AdapterInterface $pool, string $key, callable $callback, ?float $beta, array &$metadata = null) + private function doGet(AdapterInterface $pool, string $key, callable $callback, ?float $beta, array &$metadata = null): mixed { if (0 > $beta ??= 1.0) { throw new InvalidArgumentException(sprintf('Argument "$beta" provided to "%s::get()" must be a positive number, %f given.', static::class, $beta)); diff --git a/src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php b/src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php index 2ee96e9b3702c..200406a5645db 100644 --- a/src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php +++ b/src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php @@ -23,7 +23,7 @@ trait FilesystemCommonTrait private string $directory; private string $tmpSuffix; - private function init(string $namespace, ?string $directory) + private function init(string $namespace, ?string $directory): void { if (!isset($directory[0])) { $directory = sys_get_temp_dir().\DIRECTORY_SEPARATOR.'symfony-cache'; @@ -161,7 +161,7 @@ private function scanHashDir(string $directory): \Generator /** * @internal */ - public static function throwError(int $type, string $message, string $file, int $line) + public static function throwError(int $type, string $message, string $file, int $line): never { throw new \ErrorException($message, 0, $type, $file, $line); } diff --git a/src/Symfony/Component/Console/Descriptor/Descriptor.php b/src/Symfony/Component/Console/Descriptor/Descriptor.php index 43a397d37a90a..7b2509c601fe0 100644 --- a/src/Symfony/Component/Console/Descriptor/Descriptor.php +++ b/src/Symfony/Component/Console/Descriptor/Descriptor.php @@ -50,25 +50,25 @@ protected function write(string $content, bool $decorated = false): void /** * Describes an InputArgument instance. */ - abstract protected function describeInputArgument(InputArgument $argument, array $options = []); + abstract protected function describeInputArgument(InputArgument $argument, array $options = []): void; /** * Describes an InputOption instance. */ - abstract protected function describeInputOption(InputOption $option, array $options = []); + abstract protected function describeInputOption(InputOption $option, array $options = []): void; /** * Describes an InputDefinition instance. */ - abstract protected function describeInputDefinition(InputDefinition $definition, array $options = []); + abstract protected function describeInputDefinition(InputDefinition $definition, array $options = []): void; /** * Describes a Command instance. */ - abstract protected function describeCommand(Command $command, array $options = []); + abstract protected function describeCommand(Command $command, array $options = []): void; /** * Describes an Application instance. */ - abstract protected function describeApplication(Application $application, array $options = []); + abstract protected function describeApplication(Application $application, array $options = []): void; } diff --git a/src/Symfony/Component/Console/Helper/ProgressBar.php b/src/Symfony/Component/Console/Helper/ProgressBar.php index a8d9f1683ecd5..19faea47c05b2 100644 --- a/src/Symfony/Component/Console/Helper/ProgressBar.php +++ b/src/Symfony/Component/Console/Helper/ProgressBar.php @@ -183,7 +183,7 @@ public function setMessage(string $message, string $name = 'message'): void $this->messages[$name] = $message; } - public function getMessage(string $name = 'message') + public function getMessage(string $name = 'message'): string { return $this->messages[$name]; } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/RegisterAutoconfigureAttributesPass.php b/src/Symfony/Component/DependencyInjection/Compiler/RegisterAutoconfigureAttributesPass.php index 576bb9376e6c6..b706a62471ba9 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/RegisterAutoconfigureAttributesPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/RegisterAutoconfigureAttributesPass.php @@ -47,10 +47,12 @@ public function processClass(ContainerBuilder $container, \ReflectionClass $clas } } - private static function registerForAutoconfiguration(ContainerBuilder $container, \ReflectionClass $class, \ReflectionAttribute $attribute) + private static function registerForAutoconfiguration(ContainerBuilder $container, \ReflectionClass $class, \ReflectionAttribute $attribute): void { if (self::$registerForAutoconfiguration) { - return (self::$registerForAutoconfiguration)($container, $class, $attribute); + (self::$registerForAutoconfiguration)($container, $class, $attribute); + + return; } $parseDefinitions = new \ReflectionMethod(YamlFileLoader::class, 'parseDefinitions'); @@ -79,6 +81,6 @@ private static function registerForAutoconfiguration(ContainerBuilder $container ); }; - return (self::$registerForAutoconfiguration)($container, $class, $attribute); + (self::$registerForAutoconfiguration)($container, $class, $attribute); } } diff --git a/src/Symfony/Component/ErrorHandler/ErrorHandler.php b/src/Symfony/Component/ErrorHandler/ErrorHandler.php index d372c632ac39d..bda939a828073 100644 --- a/src/Symfony/Component/ErrorHandler/ErrorHandler.php +++ b/src/Symfony/Component/ErrorHandler/ErrorHandler.php @@ -483,7 +483,7 @@ public function handleError(int $type, string $message, string $file, int $line) * * @internal */ - public function handleException(\Throwable $exception) + public function handleException(\Throwable $exception): void { $handlerException = null; @@ -534,7 +534,9 @@ public function handleException(\Throwable $exception) try { if (null !== $exceptionHandler) { - return $exceptionHandler($exception); + $exceptionHandler($exception); + + return; } $handlerException ??= $exception; } catch (\Throwable $handlerException) { diff --git a/src/Symfony/Component/ExpressionLanguage/Node/ConditionalNode.php b/src/Symfony/Component/ExpressionLanguage/Node/ConditionalNode.php index fec02abaaea47..7d02544275098 100644 --- a/src/Symfony/Component/ExpressionLanguage/Node/ConditionalNode.php +++ b/src/Symfony/Component/ExpressionLanguage/Node/ConditionalNode.php @@ -40,7 +40,7 @@ public function compile(Compiler $compiler): void ; } - public function evaluate(array $functions, array $values) + public function evaluate(array $functions, array $values): mixed { if ($this->nodes['expr1']->evaluate($functions, $values)) { return $this->nodes['expr2']->evaluate($functions, $values); diff --git a/src/Symfony/Component/ExpressionLanguage/Node/FunctionNode.php b/src/Symfony/Component/ExpressionLanguage/Node/FunctionNode.php index d4ab3e0922770..33323f388f045 100644 --- a/src/Symfony/Component/ExpressionLanguage/Node/FunctionNode.php +++ b/src/Symfony/Component/ExpressionLanguage/Node/FunctionNode.php @@ -40,7 +40,7 @@ public function compile(Compiler $compiler): void $compiler->raw($function['compiler'](...$arguments)); } - public function evaluate(array $functions, array $values) + public function evaluate(array $functions, array $values): mixed { $arguments = [$values]; foreach ($this->nodes['arguments']->nodes as $node) { diff --git a/src/Symfony/Component/ExpressionLanguage/Node/UnaryNode.php b/src/Symfony/Component/ExpressionLanguage/Node/UnaryNode.php index 580ee13095765..55e2121fcf798 100644 --- a/src/Symfony/Component/ExpressionLanguage/Node/UnaryNode.php +++ b/src/Symfony/Component/ExpressionLanguage/Node/UnaryNode.php @@ -45,7 +45,7 @@ public function compile(Compiler $compiler): void ; } - public function evaluate(array $functions, array $values) + public function evaluate(array $functions, array $values): mixed { $value = $this->nodes['node']->evaluate($functions, $values); diff --git a/src/Symfony/Component/HttpClient/Response/AsyncResponse.php b/src/Symfony/Component/HttpClient/Response/AsyncResponse.php index 8236623b2793f..66152e3d90c7e 100644 --- a/src/Symfony/Component/HttpClient/Response/AsyncResponse.php +++ b/src/Symfony/Component/HttpClient/Response/AsyncResponse.php @@ -123,6 +123,9 @@ public function getInfo(string $type = null): mixed return $this->info + $this->response->getInfo(); } + /** + * @return resource + */ public function toStream(bool $throw = true) { if ($throw) { diff --git a/src/Symfony/Component/HttpClient/Response/CommonResponseTrait.php b/src/Symfony/Component/HttpClient/Response/CommonResponseTrait.php index b4cf588a4177d..08a833dfecf9b 100644 --- a/src/Symfony/Component/HttpClient/Response/CommonResponseTrait.php +++ b/src/Symfony/Component/HttpClient/Response/CommonResponseTrait.php @@ -100,6 +100,9 @@ public function toArray(bool $throw = true): array return $content; } + /** + * @return resource + */ public function toStream(bool $throw = true) { if ($throw) { diff --git a/src/Symfony/Component/Intl/Data/Generator/AbstractDataGenerator.php b/src/Symfony/Component/Intl/Data/Generator/AbstractDataGenerator.php index 453954bebdc51..d37fb28ff66bd 100644 --- a/src/Symfony/Component/Intl/Data/Generator/AbstractDataGenerator.php +++ b/src/Symfony/Component/Intl/Data/Generator/AbstractDataGenerator.php @@ -95,9 +95,9 @@ public function generateData(GeneratorConfig $config): void */ abstract protected function scanLocales(LocaleScanner $scanner, string $sourceDir): array; - abstract protected function compileTemporaryBundles(BundleCompilerInterface $compiler, string $sourceDir, string $tempDir); + abstract protected function compileTemporaryBundles(BundleCompilerInterface $compiler, string $sourceDir, string $tempDir): void; - abstract protected function preGenerate(); + abstract protected function preGenerate(): void; abstract protected function generateDataForLocale(BundleEntryReaderInterface $reader, string $tempDir, string $displayLocale): ?array; diff --git a/src/Symfony/Component/Intl/Data/Util/ArrayAccessibleResourceBundle.php b/src/Symfony/Component/Intl/Data/Util/ArrayAccessibleResourceBundle.php index 04110a46f1890..bbc0b2ed9c84a 100644 --- a/src/Symfony/Component/Intl/Data/Util/ArrayAccessibleResourceBundle.php +++ b/src/Symfony/Component/Intl/Data/Util/ArrayAccessibleResourceBundle.php @@ -32,7 +32,7 @@ public function __construct(\ResourceBundle $bundleImpl) $this->bundleImpl = $bundleImpl; } - public function get(int|string $offset) + public function get(int|string $offset): mixed { $value = $this->bundleImpl->get($offset); diff --git a/src/Symfony/Component/Intl/Data/Util/RecursiveArrayAccess.php b/src/Symfony/Component/Intl/Data/Util/RecursiveArrayAccess.php index 665f63d1ad73c..e8f720faabfa6 100644 --- a/src/Symfony/Component/Intl/Data/Util/RecursiveArrayAccess.php +++ b/src/Symfony/Component/Intl/Data/Util/RecursiveArrayAccess.php @@ -20,7 +20,7 @@ */ class RecursiveArrayAccess { - public static function get(mixed $array, array $indices) + public static function get(mixed $array, array $indices): mixed { foreach ($indices as $index) { // Use array_key_exists() for arrays, isset() otherwise diff --git a/src/Symfony/Component/Mailer/Transport/Dsn.php b/src/Symfony/Component/Mailer/Transport/Dsn.php index abd0becbbe857..4c0fb48c3b389 100644 --- a/src/Symfony/Component/Mailer/Transport/Dsn.php +++ b/src/Symfony/Component/Mailer/Transport/Dsn.php @@ -82,7 +82,7 @@ public function getPort(int $default = null): ?int return $this->port ?? $default; } - public function getOption(string $key, mixed $default = null) + public function getOption(string $key, mixed $default = null): mixed { return $this->options[$key] ?? $default; } diff --git a/src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/ConnectionTest.php b/src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/ConnectionTest.php index 0d6e3af3656a4..6bacc7426c6bc 100644 --- a/src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/ConnectionTest.php +++ b/src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/ConnectionTest.php @@ -11,9 +11,7 @@ namespace Symfony\Component\Messenger\Bridge\Doctrine\Tests\Transport; -use Doctrine\DBAL\Abstraction\Result as AbstractionResult; use Doctrine\DBAL\Connection as DBALConnection; -use Doctrine\DBAL\Driver\Result as DriverResult; use Doctrine\DBAL\Driver\ResultStatement; use Doctrine\DBAL\Exception as DBALException; use Doctrine\DBAL\Platforms\AbstractPlatform; @@ -59,6 +57,9 @@ public function testGetAMessageWillChangeItsStatus() $driverConnection ->method('executeQuery') ->willReturn($stmt); + $driverConnection + ->method('executeStatement') + ->willReturn(1); $connection = new Connection([], $driverConnection); $doctrineEnvelope = $connection->get(); @@ -156,10 +157,10 @@ private function getQueryBuilderMock() private function getResultMock($expectedResult) { - $stmt = $this->createMock(class_exists(Result::class) ? Result::class : (interface_exists(AbstractionResult::class) ? AbstractionResult::class : Statement::class)); + $stmt = $this->createMock(class_exists(Result::class) ? Result::class : ResultStatement::class); $stmt->expects($this->once()) - ->method(interface_exists(AbstractionResult::class) || class_exists(Result::class) ? 'fetchAssociative' : 'fetch') + ->method(class_exists(Result::class) ? 'fetchAssociative' : 'fetch') ->willReturn($expectedResult); return $stmt; @@ -315,9 +316,9 @@ public function testFindAll() 'headers' => json_encode(['type' => DummyMessage::class]), ]; - $stmt = $this->createMock(class_exists(Result::class) ? Result::class : (interface_exists(AbstractionResult::class) ? AbstractionResult::class : Statement::class)); + $stmt = $this->createMock(class_exists(Result::class) ? Result::class : ResultStatement::class); $stmt->expects($this->once()) - ->method(interface_exists(AbstractionResult::class) || class_exists(Result::class) ? 'fetchAllAssociative' : 'fetchAll') + ->method(class_exists(Result::class) ? 'fetchAllAssociative' : 'fetchAll') ->willReturn([$message1, $message2]); $driverConnection @@ -360,13 +361,9 @@ public function testGeneratedSql(AbstractPlatform $platform, string $expectedSql $driverConnection->method('getDatabasePlatform')->willReturn($platform); $driverConnection->method('createQueryBuilder')->willReturnCallback(fn () => new QueryBuilder($driverConnection)); - if (interface_exists(DriverResult::class)) { - $result = $this->createMock(DriverResult::class); + if (class_exists(Result::class)) { + $result = $this->createMock(Result::class); $result->method('fetchAssociative')->willReturn(false); - - if (class_exists(Result::class)) { - $result = new Result($result, $driverConnection); - } } else { $result = $this->createMock(ResultStatement::class); $result->method('fetch')->willReturn(false); @@ -447,16 +444,12 @@ public function testFindAllSqlGenerated(AbstractPlatform $platform, string $expe return new QueryBuilder($driverConnection); }); - if (interface_exists(DriverResult::class)) { - $result = $this->createMock(DriverResult::class); - $result->method('fetchAssociative')->willReturn(false); - - if (class_exists(Result::class)) { - $result = new Result($result, $driverConnection); - } + if (class_exists(Result::class)) { + $result = $this->createMock(Result::class); + $result->method('fetchAllAssociative')->willReturn([]); } else { $result = $this->createMock(ResultStatement::class); - $result->method('fetch')->willReturn(false); + $result->method('fetchAll')->willReturn([]); } $driverConnection diff --git a/src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/DoctrineIntegrationTest.php b/src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/DoctrineIntegrationTest.php index 448aa16e6f5b1..5cd3b55787654 100644 --- a/src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/DoctrineIntegrationTest.php +++ b/src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/DoctrineIntegrationTest.php @@ -11,7 +11,6 @@ namespace Symfony\Component\Messenger\Bridge\Doctrine\Tests\Transport; -use Doctrine\DBAL\Driver\Result as DriverResult; use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\Result; use Doctrine\DBAL\Schema\AbstractSchemaManager; @@ -60,7 +59,7 @@ public function testSendWithDelay() ->setParameter('body', '{"message": "Hi i am delayed"}') ->execute(); - $available_at = new \DateTimeImmutable($stmt instanceof Result || $stmt instanceof DriverResult ? $stmt->fetchOne() : $stmt->fetchColumn()); + $available_at = new \DateTimeImmutable($stmt instanceof Result ? $stmt->fetchOne() : $stmt->fetchColumn()); $now = new \DateTimeImmutable('now + 60 seconds'); $this->assertGreaterThan($now, $available_at); diff --git a/src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/DoctrineTransportFactoryTest.php b/src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/DoctrineTransportFactoryTest.php index b81b95fd07ad9..6ef1734e6745b 100644 --- a/src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/DoctrineTransportFactoryTest.php +++ b/src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/DoctrineTransportFactoryTest.php @@ -72,6 +72,7 @@ public function testCreateTransportNotifyWithPostgreSQLPlatform() $schemaManager->method('createSchemaConfig')->willReturn($schemaConfig); $driverConnection->method('getSchemaManager')->willReturn($schemaManager); $driverConnection->method('getDatabasePlatform')->willReturn($platform); + $driverConnection->method('executeStatement')->willReturn(1); $registry = $this->createMock(ConnectionRegistry::class); $registry->expects($this->once()) diff --git a/src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/PostgreSqlConnectionTest.php b/src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/PostgreSqlConnectionTest.php index e8e00d97b3876..74357dc461e2a 100644 --- a/src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/PostgreSqlConnectionTest.php +++ b/src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/PostgreSqlConnectionTest.php @@ -31,6 +31,7 @@ public function testSerialize() $this->expectExceptionMessage('Cannot serialize '.PostgreSqlConnection::class); $driverConnection = $this->createMock(\Doctrine\DBAL\Connection::class); + $driverConnection->method('executeStatement')->willReturn(1); $connection = new PostgreSqlConnection([], $driverConnection); serialize($connection); @@ -42,6 +43,7 @@ public function testUnserialize() $this->expectExceptionMessage('Cannot unserialize '.PostgreSqlConnection::class); $driverConnection = $this->createMock(\Doctrine\DBAL\Connection::class); + $driverConnection->method('executeStatement')->willReturn(1); $connection = new PostgreSqlConnection([], $driverConnection); $connection->__wakeup(); @@ -50,6 +52,7 @@ public function testUnserialize() public function testListenOnConnection() { $driverConnection = $this->createMock(\Doctrine\DBAL\Connection::class); + $driverConnection->method('executeStatement')->willReturn(1); $driverConnection ->expects(self::any()) @@ -112,6 +115,7 @@ public function countNotifyCalls() public function testGetExtraSetupSql() { $driverConnection = $this->createMock(\Doctrine\DBAL\Connection::class); + $driverConnection->method('executeStatement')->willReturn(1); $connection = new PostgreSqlConnection(['table_name' => 'queue_table'], $driverConnection); $table = new Table('queue_table'); @@ -128,6 +132,7 @@ public function testGetExtraSetupSql() public function testTransformTableNameWithSchemaToValidProcedureName() { $driverConnection = $this->createMock(\Doctrine\DBAL\Connection::class); + $driverConnection->method('executeStatement')->willReturn(1); $connection = new PostgreSqlConnection(['table_name' => 'schema.queue_table'], $driverConnection); $table = new Table('schema.queue_table'); @@ -141,6 +146,7 @@ public function testTransformTableNameWithSchemaToValidProcedureName() public function testGetExtraSetupSqlWrongTable() { $driverConnection = $this->createMock(\Doctrine\DBAL\Connection::class); + $driverConnection->method('executeStatement')->willReturn(1); $connection = new PostgreSqlConnection(['table_name' => 'queue_table'], $driverConnection); $table = new Table('queue_table'); diff --git a/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/Connection.php b/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/Connection.php index be9fc6b11b686..98eb224841585 100644 --- a/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/Connection.php +++ b/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/Connection.php @@ -11,9 +11,10 @@ namespace Symfony\Component\Messenger\Bridge\Doctrine\Transport; +use Doctrine\DBAL\Abstraction\Result as AbstractionResult; use Doctrine\DBAL\Connection as DBALConnection; use Doctrine\DBAL\Driver\Exception as DriverException; -use Doctrine\DBAL\Driver\Result as DriverResult; +use Doctrine\DBAL\Driver\ResultStatement; use Doctrine\DBAL\Exception as DBALException; use Doctrine\DBAL\Exception\TableNotFoundException; use Doctrine\DBAL\LockMode; @@ -202,7 +203,7 @@ public function get(): ?array $query->getParameters(), $query->getParameterTypes() ); - $doctrineEnvelope = $stmt instanceof Result || $stmt instanceof DriverResult ? $stmt->fetchAssociative() : $stmt->fetch(); + $doctrineEnvelope = $stmt instanceof Result ? $stmt->fetchAssociative() : $stmt->fetch(); if (false === $doctrineEnvelope) { $this->driverConnection->commit(); @@ -287,7 +288,7 @@ public function getMessageCount(): int $stmt = $this->executeQuery($queryBuilder->getSQL(), $queryBuilder->getParameters(), $queryBuilder->getParameterTypes()); - return $stmt instanceof Result || $stmt instanceof DriverResult ? $stmt->fetchOne() : $stmt->fetchColumn(); + return $stmt instanceof Result ? $stmt->fetchOne() : $stmt->fetchColumn(); } public function findAll(int $limit = null): array @@ -299,7 +300,7 @@ public function findAll(int $limit = null): array } $stmt = $this->executeQuery($queryBuilder->getSQL(), $queryBuilder->getParameters(), $queryBuilder->getParameterTypes()); - $data = $stmt instanceof Result || $stmt instanceof DriverResult ? $stmt->fetchAllAssociative() : $stmt->fetchAll(); + $data = $stmt instanceof Result ? $stmt->fetchAllAssociative() : $stmt->fetchAll(); return array_map(fn ($doctrineEnvelope) => $this->decodeEnvelopeHeaders($doctrineEnvelope), $data); } @@ -310,7 +311,7 @@ public function find(mixed $id): ?array ->where('m.id = ? and m.queue_name = ?'); $stmt = $this->executeQuery($queryBuilder->getSQL(), [$id, $this->configuration['queue_name']]); - $data = $stmt instanceof Result || $stmt instanceof DriverResult ? $stmt->fetchAssociative() : $stmt->fetch(); + $data = $stmt instanceof Result ? $stmt->fetchAssociative() : $stmt->fetch(); return false === $data ? null : $this->decodeEnvelopeHeaders($data); } @@ -379,7 +380,7 @@ private function createQueryBuilder(string $alias = 'm'): QueryBuilder )); } - private function executeQuery(string $sql, array $parameters = [], array $types = []) + private function executeQuery(string $sql, array $parameters = [], array $types = []): Result|AbstractionResult|ResultStatement { try { $stmt = $this->driverConnection->executeQuery($sql, $parameters, $types); @@ -398,7 +399,7 @@ private function executeQuery(string $sql, array $parameters = [], array $types return $stmt; } - protected function executeStatement(string $sql, array $parameters = [], array $types = []) + protected function executeStatement(string $sql, array $parameters = [], array $types = []): int|string { try { if (method_exists($this->driverConnection, 'executeStatement')) { diff --git a/src/Symfony/Component/Messenger/Command/AbstractFailedMessagesCommand.php b/src/Symfony/Component/Messenger/Command/AbstractFailedMessagesCommand.php index 3bb31bab9efa6..28aedeb1255c5 100644 --- a/src/Symfony/Component/Messenger/Command/AbstractFailedMessagesCommand.php +++ b/src/Symfony/Component/Messenger/Command/AbstractFailedMessagesCommand.php @@ -208,7 +208,7 @@ protected function printWarningAvailableFailureTransports(SymfonyStyle $io, ?str } } - protected function interactiveChooseFailureTransport(SymfonyStyle $io) + protected function interactiveChooseFailureTransport(SymfonyStyle $io): string { $failedTransports = array_keys($this->failureTransports->getProvidedServices()); $question = new ChoiceQuestion('Select failed transport:', $failedTransports, 0); diff --git a/src/Symfony/Component/Messenger/Handler/HandlerDescriptor.php b/src/Symfony/Component/Messenger/Handler/HandlerDescriptor.php index 821754b37bb81..98d0bced59b4b 100644 --- a/src/Symfony/Component/Messenger/Handler/HandlerDescriptor.php +++ b/src/Symfony/Component/Messenger/Handler/HandlerDescriptor.php @@ -69,7 +69,7 @@ public function getBatchHandler(): ?BatchHandlerInterface return $this->batchHandler; } - public function getOption(string $option) + public function getOption(string $option): mixed { return $this->options[$option] ?? null; } diff --git a/src/Symfony/Component/Messenger/Transport/Serialization/PhpSerializer.php b/src/Symfony/Component/Messenger/Transport/Serialization/PhpSerializer.php index da08f21d3781c..b1cb42d7e3dba 100644 --- a/src/Symfony/Component/Messenger/Transport/Serialization/PhpSerializer.php +++ b/src/Symfony/Component/Messenger/Transport/Serialization/PhpSerializer.php @@ -112,7 +112,7 @@ private function safelyUnserialize(string $contents): Envelope /** * @internal */ - public static function handleUnserializeCallback(string $class) + public static function handleUnserializeCallback(string $class): never { throw new MessageDecodingFailedException(sprintf('Message class "%s" not found during decoding.', $class)); } diff --git a/src/Symfony/Component/Mime/Header/Headers.php b/src/Symfony/Component/Mime/Header/Headers.php index ef1c44a7fe6d3..57d730127ba09 100644 --- a/src/Symfony/Component/Mime/Header/Headers.php +++ b/src/Symfony/Component/Mime/Header/Headers.php @@ -264,7 +264,7 @@ public function toArray(): array return $arr; } - public function getHeaderBody(string $name) + public function getHeaderBody(string $name): mixed { return $this->has($name) ? $this->get($name)->getBody() : null; } diff --git a/src/Symfony/Component/Notifier/Transport/Dsn.php b/src/Symfony/Component/Notifier/Transport/Dsn.php index 3d38f1444c07f..fa37b6d338eb0 100644 --- a/src/Symfony/Component/Notifier/Transport/Dsn.php +++ b/src/Symfony/Component/Notifier/Transport/Dsn.php @@ -79,12 +79,12 @@ public function getPort(int $default = null): ?int return $this->port ?? $default; } - public function getOption(string $key, mixed $default = null) + public function getOption(string $key, mixed $default = null): mixed { return $this->options[$key] ?? $default; } - public function getRequiredOption(string $key) + public function getRequiredOption(string $key): mixed { if (!\array_key_exists($key, $this->options) || '' === trim($this->options[$key])) { throw new MissingRequiredOptionException($key); diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 7defb879f77a7..6a38e965aad37 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -912,7 +912,7 @@ public function stop(float $timeout = 10, int $signal = null): ?int * * @internal */ - public function addOutput(string $line) + public function addOutput(string $line): void { $this->lastOutputTime = microtime(true); @@ -926,7 +926,7 @@ public function addOutput(string $line) * * @internal */ - public function addErrorOutput(string $line) + public function addErrorOutput(string $line): void { $this->lastOutputTime = microtime(true); diff --git a/src/Symfony/Component/RateLimiter/Policy/Window.php b/src/Symfony/Component/RateLimiter/Policy/Window.php index 19f436ac1a16c..ec3e458787e5a 100644 --- a/src/Symfony/Component/RateLimiter/Policy/Window.php +++ b/src/Symfony/Component/RateLimiter/Policy/Window.php @@ -44,7 +44,7 @@ public function getExpirationTime(): ?int return $this->intervalInSeconds; } - public function add(int $hits = 1, float $now = null) + public function add(int $hits = 1, float $now = null): void { $now ??= microtime(true); if (($now - $this->timer) > $this->intervalInSeconds) { diff --git a/src/Symfony/Component/Routing/CompiledRoute.php b/src/Symfony/Component/Routing/CompiledRoute.php index 745120a6df65f..8664158db4e40 100644 --- a/src/Symfony/Component/Routing/CompiledRoute.php +++ b/src/Symfony/Component/Routing/CompiledRoute.php @@ -86,7 +86,7 @@ public function __unserialize(array $data): void /** * @internal */ - final public function unserialize(string $serialized) + final public function unserialize(string $serialized): void { $this->__unserialize(unserialize($serialized, ['allowed_classes' => false])); } diff --git a/src/Symfony/Component/Routing/Route.php b/src/Symfony/Component/Routing/Route.php index 900547e0acdf6..ac8d8bc6e9086 100644 --- a/src/Symfony/Component/Routing/Route.php +++ b/src/Symfony/Component/Routing/Route.php @@ -102,7 +102,7 @@ public function __unserialize(array $data): void /** * @internal */ - final public function unserialize(string $serialized) + final public function unserialize(string $serialized): void { $this->__unserialize(unserialize($serialized)); } diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php b/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php index 4416cda6168cd..10cb8f776e5ba 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php +++ b/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php @@ -172,7 +172,7 @@ final public function serialize(): string /** * @internal */ - final public function unserialize(string $serialized) + final public function unserialize(string $serialized): void { $this->__unserialize(unserialize($serialized)); } diff --git a/src/Symfony/Component/Security/Http/Authenticator/JsonLoginAuthenticator.php b/src/Symfony/Component/Security/Http/Authenticator/JsonLoginAuthenticator.php index 8f1dc60b12688..73b4dd434db69 100644 --- a/src/Symfony/Component/Security/Http/Authenticator/JsonLoginAuthenticator.php +++ b/src/Symfony/Component/Security/Http/Authenticator/JsonLoginAuthenticator.php @@ -137,7 +137,7 @@ public function isInteractive(): bool return true; } - public function setTranslator(TranslatorInterface $translator) + public function setTranslator(TranslatorInterface $translator): void { $this->translator = $translator; } diff --git a/src/Symfony/Component/Security/Http/Event/LazyResponseEvent.php b/src/Symfony/Component/Security/Http/Event/LazyResponseEvent.php index 46a25eed0725a..b9ea71c749210 100644 --- a/src/Symfony/Component/Security/Http/Event/LazyResponseEvent.php +++ b/src/Symfony/Component/Security/Http/Event/LazyResponseEvent.php @@ -31,7 +31,7 @@ public function __construct(parent $event) $this->event = $event; } - public function setResponse(Response $response) + public function setResponse(Response $response): never { $this->stopPropagation(); $this->event->stopPropagation(); diff --git a/src/Symfony/Component/Security/Http/Firewall/AccessListener.php b/src/Symfony/Component/Security/Http/Firewall/AccessListener.php index ad343ef085dad..9f4337975c58b 100644 --- a/src/Symfony/Component/Security/Http/Firewall/AccessListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/AccessListener.php @@ -60,11 +60,9 @@ public function supports(Request $request): ?bool /** * Handles access authorization. * - * @void - * * @throws AccessDeniedException */ - public function authenticate(RequestEvent $event) + public function authenticate(RequestEvent $event): void { $request = $event->getRequest(); diff --git a/src/Symfony/Component/Security/Http/Firewall/ContextListener.php b/src/Symfony/Component/Security/Http/Firewall/ContextListener.php index f9b36fb35a28a..baf8dff3fddbd 100644 --- a/src/Symfony/Component/Security/Http/Firewall/ContextListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/ContextListener.php @@ -251,7 +251,7 @@ protected function refreshUser(TokenInterface $token): ?TokenInterface throw new \RuntimeException(sprintf('There is no user provider for user "%s". Shouldn\'t the "supportsClass()" method of your user provider return true for this classname?', $userClass)); } - private function safelyUnserialize(string $serializedToken) + private function safelyUnserialize(string $serializedToken): mixed { $token = null; $prevUnserializeHandler = ini_set('unserialize_callback_func', __CLASS__.'::handleUnserializeCallback'); @@ -323,7 +323,7 @@ private static function hasUserChanged(UserInterface $originalUser, TokenInterfa /** * @internal */ - public static function handleUnserializeCallback(string $class) + public static function handleUnserializeCallback(string $class): never { throw new \ErrorException('Class not found: '.$class, 0x37313BC); } diff --git a/src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php b/src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php index 5d7545a5a7c69..81fa06173faa6 100644 --- a/src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php @@ -225,7 +225,7 @@ protected function setTargetPath(Request $request): void } } - private function throwUnauthorizedException(AuthenticationException $authException) + private function throwUnauthorizedException(AuthenticationException $authException): never { $this->logger?->notice(sprintf('No Authentication entry point configured, returning a %s HTTP response. Configure "entry_point" on the firewall "%s" if you want to modify the response.', Response::HTTP_UNAUTHORIZED, $this->firewallName)); diff --git a/src/Symfony/Component/Translation/Provider/Dsn.php b/src/Symfony/Component/Translation/Provider/Dsn.php index 77577b0f64df2..af75cb3ae6721 100644 --- a/src/Symfony/Component/Translation/Provider/Dsn.php +++ b/src/Symfony/Component/Translation/Provider/Dsn.php @@ -79,12 +79,12 @@ public function getPort(int $default = null): ?int return $this->port ?? $default; } - public function getOption(string $key, mixed $default = null) + public function getOption(string $key, mixed $default = null): mixed { return $this->options[$key] ?? $default; } - public function getRequiredOption(string $key) + public function getRequiredOption(string $key): mixed { if (!\array_key_exists($key, $this->options) || '' === trim($this->options[$key])) { throw new MissingRequiredOptionException($key); diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index f1cc47e7fbf67..ddfbcfd83a06f 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -99,7 +99,7 @@ public function parse(string $value, int $flags = 0): mixed return $data; } - private function doParse(string $value, int $flags) + private function doParse(string $value, int $flags): mixed { $this->currentLineNb = -1; $this->currentLine = ''; @@ -503,7 +503,7 @@ private function doParse(string $value, int $flags) return empty($data) ? null : $data; } - private function parseBlock(int $offset, string $yaml, int $flags) + private function parseBlock(int $offset, string $yaml, int $flags): mixed { $skippedLineNumbers = $this->skippedLineNumbers; diff --git a/src/Symfony/Component/Yaml/Tag/TaggedValue.php b/src/Symfony/Component/Yaml/Tag/TaggedValue.php index c7946c27ec4d0..3e09b93ee021f 100644 --- a/src/Symfony/Component/Yaml/Tag/TaggedValue.php +++ b/src/Symfony/Component/Yaml/Tag/TaggedValue.php @@ -31,7 +31,7 @@ public function getTag(): string return $this->tag; } - public function getValue() + public function getValue(): mixed { return $this->value; }