diff --git a/src/Symfony/Component/BrowserKit/AbstractBrowser.php b/src/Symfony/Component/BrowserKit/AbstractBrowser.php index 152050159b936..ffa8b2aa2f3aa 100644 --- a/src/Symfony/Component/BrowserKit/AbstractBrowser.php +++ b/src/Symfony/Component/BrowserKit/AbstractBrowser.php @@ -403,11 +403,9 @@ public function request(string $method, string $uri, array $parameters = [], arr /** * Makes a request in another process. * - * @return object - * * @throws \RuntimeException When processing returns exit code */ - protected function doRequestInProcess(object $request) + protected function doRequestInProcess(object $request): object { $deprecationsFile = tempnam(sys_get_temp_dir(), 'deprec'); putenv('SYMFONY_DEPRECATIONS_SERIALIZE='.$deprecationsFile); @@ -437,10 +435,8 @@ protected function doRequestInProcess(object $request) /** * Makes a request. - * - * @return object */ - abstract protected function doRequest(object $request); + abstract protected function doRequest(object $request): object; /** * Returns the script to execute when the request must be insulated. @@ -456,20 +452,16 @@ protected function getScript(object $request) /** * Filters the BrowserKit request to the origin one. - * - * @return object */ - protected function filterRequest(Request $request) + protected function filterRequest(Request $request): object { return $request; } /** * Filters the origin response to the BrowserKit one. - * - * @return Response */ - protected function filterResponse(object $response) + protected function filterResponse(object $response): Response { return $response; } diff --git a/src/Symfony/Component/Config/Definition/ConfigurationInterface.php b/src/Symfony/Component/Config/Definition/ConfigurationInterface.php index 7b5d443fe6bb6..97a325bb67a5d 100644 --- a/src/Symfony/Component/Config/Definition/ConfigurationInterface.php +++ b/src/Symfony/Component/Config/Definition/ConfigurationInterface.php @@ -22,8 +22,6 @@ interface ConfigurationInterface { /** * Generates the configuration tree builder. - * - * @return TreeBuilder */ - public function getConfigTreeBuilder(); + public function getConfigTreeBuilder(): TreeBuilder; } diff --git a/src/Symfony/Component/Config/FileLocator.php b/src/Symfony/Component/Config/FileLocator.php index 21122e52c92e2..206029e705180 100644 --- a/src/Symfony/Component/Config/FileLocator.php +++ b/src/Symfony/Component/Config/FileLocator.php @@ -33,7 +33,7 @@ public function __construct(string|array $paths = []) /** * {@inheritdoc} */ - public function locate(string $name, string $currentPath = null, bool $first = true) + public function locate(string $name, string $currentPath = null, bool $first = true): string|array { if ('' === $name) { throw new \InvalidArgumentException('An empty file name is not valid to be located.'); diff --git a/src/Symfony/Component/Config/FileLocatorInterface.php b/src/Symfony/Component/Config/FileLocatorInterface.php index e3ca1d49c4066..526d35048412e 100644 --- a/src/Symfony/Component/Config/FileLocatorInterface.php +++ b/src/Symfony/Component/Config/FileLocatorInterface.php @@ -30,5 +30,5 @@ interface FileLocatorInterface * @throws \InvalidArgumentException If $name is empty * @throws FileLocatorFileNotFoundException If a file is not found */ - public function locate(string $name, string $currentPath = null, bool $first = true); + public function locate(string $name, string $currentPath = null, bool $first = true): string|array; } diff --git a/src/Symfony/Component/Config/Loader/FileLoader.php b/src/Symfony/Component/Config/Loader/FileLoader.php index c479f75d341a2..fa97b054c7dfd 100644 --- a/src/Symfony/Component/Config/Loader/FileLoader.php +++ b/src/Symfony/Component/Config/Loader/FileLoader.php @@ -62,13 +62,11 @@ public function getLocator(): FileLocatorInterface * @param string|null $sourceResource The original resource importing the new resource * @param string|string[]|null $exclude Glob patterns to exclude from the import * - * @return mixed - * * @throws LoaderLoadException * @throws FileLoaderImportCircularReferenceException * @throws FileLocatorFileNotFoundException */ - public function import(mixed $resource, string $type = null, bool $ignoreErrors = false, string $sourceResource = null, string|array $exclude = null) + public function import(mixed $resource, string $type = null, bool $ignoreErrors = false, string $sourceResource = null, string|array $exclude = null): mixed { if (\is_string($resource) && \strlen($resource) !== ($i = strcspn($resource, '*?{[')) && !str_contains($resource, "\n")) { $excluded = []; diff --git a/src/Symfony/Component/Config/Loader/Loader.php b/src/Symfony/Component/Config/Loader/Loader.php index faa0f58369f13..d04e51045c34d 100644 --- a/src/Symfony/Component/Config/Loader/Loader.php +++ b/src/Symfony/Component/Config/Loader/Loader.php @@ -46,10 +46,8 @@ public function setResolver(LoaderResolverInterface $resolver) /** * Imports a resource. - * - * @return mixed */ - public function import(mixed $resource, string $type = null) + public function import(mixed $resource, string $type = null): mixed { return $this->resolve($resource, $type)->load($resource, $type); } diff --git a/src/Symfony/Component/Config/Loader/LoaderInterface.php b/src/Symfony/Component/Config/Loader/LoaderInterface.php index b94a4378f5304..8eb90ecf60d14 100644 --- a/src/Symfony/Component/Config/Loader/LoaderInterface.php +++ b/src/Symfony/Component/Config/Loader/LoaderInterface.php @@ -21,27 +21,21 @@ interface LoaderInterface /** * Loads a resource. * - * @return mixed - * * @throws \Exception If something went wrong */ - public function load(mixed $resource, string $type = null); + public function load(mixed $resource, string $type = null): mixed; /** * Returns whether this class supports the given resource. * * @param mixed $resource A resource - * - * @return bool */ - public function supports(mixed $resource, string $type = null); + public function supports(mixed $resource, string $type = null): bool; /** * Gets the loader resolver. - * - * @return LoaderResolverInterface */ - public function getResolver(); + public function getResolver(): LoaderResolverInterface; /** * Sets the loader resolver. diff --git a/src/Symfony/Component/Config/ResourceCheckerInterface.php b/src/Symfony/Component/Config/ResourceCheckerInterface.php index 6b1c6c5fbe6b4..13ae03f454dc7 100644 --- a/src/Symfony/Component/Config/ResourceCheckerInterface.php +++ b/src/Symfony/Component/Config/ResourceCheckerInterface.php @@ -29,17 +29,13 @@ interface ResourceCheckerInterface /** * Queries the ResourceChecker whether it can validate a given * resource or not. - * - * @return bool */ - public function supports(ResourceInterface $metadata); + public function supports(ResourceInterface $metadata): bool; /** * Validates the resource. * * @param int $timestamp The timestamp at which the cache associated with this resource was created - * - * @return bool */ - public function isFresh(ResourceInterface $resource, int $timestamp); + public function isFresh(ResourceInterface $resource, int $timestamp): bool; } diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index 801575e8f43c9..3d065da433029 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -213,7 +213,7 @@ public function run(InputInterface $input = null, OutputInterface $output = null * * @return int 0 if everything went fine, or an error code */ - public function doRun(InputInterface $input, OutputInterface $output) + public function doRun(InputInterface $input, OutputInterface $output): int { if (true === $input->hasParameterOption(['--version', '-V'], true)) { $output->writeln($this->getLongVersion()); @@ -420,10 +420,8 @@ public function setVersion(string $version) /** * Returns the long version of the application. - * - * @return string */ - public function getLongVersion() + public function getLongVersion(): string { if ('UNKNOWN' !== $this->getName()) { if ('UNKNOWN' !== $this->getVersion()) { @@ -463,10 +461,8 @@ public function addCommands(array $commands) * * If a command with the same name already exists, it will be overridden. * If the command is not enabled it will not be added. - * - * @return Command|null */ - public function add(Command $command) + public function add(Command $command): ?Command { $this->init(); @@ -499,11 +495,9 @@ public function add(Command $command) /** * Returns a registered command by name or alias. * - * @return Command - * * @throws CommandNotFoundException When given command name does not exist */ - public function get(string $name) + public function get(string $name): Command { $this->init(); @@ -606,11 +600,9 @@ public function findNamespace(string $namespace): string * Contrary to get, this command tries to find the best * match if you give it an abbreviation of a name or alias. * - * @return Command - * * @throws CommandNotFoundException When command name is incorrect or ambiguous */ - public function find(string $name) + public function find(string $name): Command { $this->init(); @@ -720,7 +712,7 @@ public function find(string $name) * * @return Command[] */ - public function all(string $namespace = null) + public function all(string $namespace = null): array { $this->init(); @@ -919,7 +911,7 @@ protected function configureIO(InputInterface $input, OutputInterface $output) * * @return int 0 if everything went fine, or an error code */ - protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output) + protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output): int { foreach ($command->getHelperSet() as $helper) { if ($helper instanceof InputAwareInterface) { diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index 761b31d0d2c3b..06538e3c69526 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -165,10 +165,8 @@ public function getApplication(): ?Application * * Override this to check for x or y and return false if the command can not * run properly under the current conditions. - * - * @return bool */ - public function isEnabled() + public function isEnabled(): bool { return true; } @@ -194,7 +192,7 @@ protected function configure() * * @see setCode() */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { throw new LogicException('You must override the execute() method in the concrete command class.'); } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php b/src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php index 1acec50de5c89..904e67a47b180 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php @@ -69,7 +69,7 @@ protected function inExpression(bool $reset = true): bool * * @return mixed */ - protected function processValue(mixed $value, bool $isRoot = false) + protected function processValue(mixed $value, bool $isRoot = false): mixed { if (\is_array($value)) { foreach ($value as $k => $v) { diff --git a/src/Symfony/Component/DependencyInjection/Container.php b/src/Symfony/Component/DependencyInjection/Container.php index 0532120adf80b..8993ede30f467 100644 --- a/src/Symfony/Component/DependencyInjection/Container.php +++ b/src/Symfony/Component/DependencyInjection/Container.php @@ -103,11 +103,9 @@ public function getParameterBag(): ParameterBagInterface /** * Gets a parameter. * - * @return array|bool|string|int|float|null - * * @throws InvalidArgumentException if the parameter is not defined */ - public function getParameter(string $name) + public function getParameter(string $name): array|bool|string|int|float|null { return $this->parameterBag->get($name); } diff --git a/src/Symfony/Component/DependencyInjection/ContainerInterface.php b/src/Symfony/Component/DependencyInjection/ContainerInterface.php index aa5d6b317eb2f..6ac31f1b2b31e 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerInterface.php +++ b/src/Symfony/Component/DependencyInjection/ContainerInterface.php @@ -48,11 +48,9 @@ public function has(string $id): bool; public function initialized(string $id): bool; /** - * @return array|bool|string|int|float|null - * * @throws InvalidArgumentException if the parameter is not defined */ - public function getParameter(string $name); + public function getParameter(string $name): array|bool|string|int|float|null; public function hasParameter(string $name): bool; diff --git a/src/Symfony/Component/DependencyInjection/Extension/ConfigurationExtensionInterface.php b/src/Symfony/Component/DependencyInjection/Extension/ConfigurationExtensionInterface.php index a42967f4da4b3..5d266c7abcd19 100644 --- a/src/Symfony/Component/DependencyInjection/Extension/ConfigurationExtensionInterface.php +++ b/src/Symfony/Component/DependencyInjection/Extension/ConfigurationExtensionInterface.php @@ -23,8 +23,6 @@ interface ConfigurationExtensionInterface { /** * Returns extension configuration. - * - * @return ConfigurationInterface|null */ - public function getConfiguration(array $config, ContainerBuilder $container); + public function getConfiguration(array $config, ContainerBuilder $container): ?ConfigurationInterface; } diff --git a/src/Symfony/Component/DependencyInjection/Extension/Extension.php b/src/Symfony/Component/DependencyInjection/Extension/Extension.php index d553203c438fa..1163f4b107bda 100644 --- a/src/Symfony/Component/DependencyInjection/Extension/Extension.php +++ b/src/Symfony/Component/DependencyInjection/Extension/Extension.php @@ -31,7 +31,7 @@ abstract class Extension implements ExtensionInterface, ConfigurationExtensionIn /** * {@inheritdoc} */ - public function getXsdValidationBasePath() + public function getXsdValidationBasePath(): string|false { return false; } @@ -39,7 +39,7 @@ public function getXsdValidationBasePath() /** * {@inheritdoc} */ - public function getNamespace() + public function getNamespace(): string { return 'http://example.org/schema/dic/'.$this->getAlias(); } @@ -76,7 +76,7 @@ public function getAlias(): string /** * {@inheritdoc} */ - public function getConfiguration(array $config, ContainerBuilder $container) + public function getConfiguration(array $config, ContainerBuilder $container): ?ConfigurationInterface { $class = static::class; diff --git a/src/Symfony/Component/DependencyInjection/Extension/ExtensionInterface.php b/src/Symfony/Component/DependencyInjection/Extension/ExtensionInterface.php index f2373ed5ea3dc..f7aed836b477f 100644 --- a/src/Symfony/Component/DependencyInjection/Extension/ExtensionInterface.php +++ b/src/Symfony/Component/DependencyInjection/Extension/ExtensionInterface.php @@ -29,24 +29,18 @@ public function load(array $configs, ContainerBuilder $container); /** * Returns the namespace to be used for this extension (XML namespace). - * - * @return string */ - public function getNamespace(); + public function getNamespace(): string; /** * Returns the base path for the XSD files. - * - * @return string|false */ - public function getXsdValidationBasePath(); + public function getXsdValidationBasePath(): string|false; /** * Returns the recommended alias to use in XML. * * This alias is also the mandatory prefix to use when using YAML. - * - * @return string */ - public function getAlias(); + public function getAlias(): string; } diff --git a/src/Symfony/Component/DependencyInjection/LazyProxy/Instantiator/InstantiatorInterface.php b/src/Symfony/Component/DependencyInjection/LazyProxy/Instantiator/InstantiatorInterface.php index a9d78115dd83c..14e1bd2188b6a 100644 --- a/src/Symfony/Component/DependencyInjection/LazyProxy/Instantiator/InstantiatorInterface.php +++ b/src/Symfony/Component/DependencyInjection/LazyProxy/Instantiator/InstantiatorInterface.php @@ -27,8 +27,6 @@ interface InstantiatorInterface * * @param string $id Identifier of the requested service * @param callable $realInstantiator Zero-argument callback that is capable of producing the real service instance - * - * @return object */ - public function instantiateProxy(ContainerInterface $container, Definition $definition, string $id, callable $realInstantiator); + public function instantiateProxy(ContainerInterface $container, Definition $definition, string $id, callable $realInstantiator): object; } diff --git a/src/Symfony/Component/EventDispatcher/EventSubscriberInterface.php b/src/Symfony/Component/EventDispatcher/EventSubscriberInterface.php index 2085e428e9152..ca0d6964e532d 100644 --- a/src/Symfony/Component/EventDispatcher/EventSubscriberInterface.php +++ b/src/Symfony/Component/EventDispatcher/EventSubscriberInterface.php @@ -45,5 +45,5 @@ interface EventSubscriberInterface * * @return array> */ - public static function getSubscribedEvents(); + public static function getSubscribedEvents(): array; } diff --git a/src/Symfony/Component/ExpressionLanguage/ExpressionFunctionProviderInterface.php b/src/Symfony/Component/ExpressionLanguage/ExpressionFunctionProviderInterface.php index 479aeef88030a..272954c082206 100644 --- a/src/Symfony/Component/ExpressionLanguage/ExpressionFunctionProviderInterface.php +++ b/src/Symfony/Component/ExpressionLanguage/ExpressionFunctionProviderInterface.php @@ -19,5 +19,5 @@ interface ExpressionFunctionProviderInterface /** * @return ExpressionFunction[] */ - public function getFunctions(); + public function getFunctions(): array; } diff --git a/src/Symfony/Component/Form/AbstractExtension.php b/src/Symfony/Component/Form/AbstractExtension.php index 7aff58e574c0a..1c786b52e10d7 100644 --- a/src/Symfony/Component/Form/AbstractExtension.php +++ b/src/Symfony/Component/Form/AbstractExtension.php @@ -113,7 +113,7 @@ public function getTypeGuesser(): ?FormTypeGuesserInterface * * @return FormTypeInterface[] */ - protected function loadTypes() + protected function loadTypes(): array { return []; } @@ -130,10 +130,8 @@ protected function loadTypeExtensions(): array /** * Registers the type guesser. - * - * @return FormTypeGuesserInterface|null */ - protected function loadTypeGuesser() + protected function loadTypeGuesser(): ?FormTypeGuesserInterface { return null; } diff --git a/src/Symfony/Component/Form/AbstractRendererEngine.php b/src/Symfony/Component/Form/AbstractRendererEngine.php index 054d0f7173ba8..d94b4e61f8213 100644 --- a/src/Symfony/Component/Form/AbstractRendererEngine.php +++ b/src/Symfony/Component/Form/AbstractRendererEngine.php @@ -131,10 +131,8 @@ public function getResourceHierarchyLevel(FormView $view, array $blockNameHierar * Loads the cache with the resource for a given block name. * * @see getResourceForBlock() - * - * @return bool */ - abstract protected function loadResourceForBlockName(string $cacheKey, FormView $view, string $blockName); + abstract protected function loadResourceForBlockName(string $cacheKey, FormView $view, string $blockName): bool; /** * Loads the cache with the resource for a specific level of a block hierarchy. diff --git a/src/Symfony/Component/Form/AbstractType.php b/src/Symfony/Component/Form/AbstractType.php index 3325b8bc27567..1cc22a1dab0bf 100644 --- a/src/Symfony/Component/Form/AbstractType.php +++ b/src/Symfony/Component/Form/AbstractType.php @@ -51,7 +51,7 @@ public function configureOptions(OptionsResolver $resolver) /** * {@inheritdoc} */ - public function getBlockPrefix() + public function getBlockPrefix(): string { return StringUtil::fqcnToBlockPrefix(static::class) ?: ''; } @@ -59,7 +59,7 @@ public function getBlockPrefix() /** * {@inheritdoc} */ - public function getParent() + public function getParent(): ?string { return FormType::class; } diff --git a/src/Symfony/Component/Form/DataTransformerInterface.php b/src/Symfony/Component/Form/DataTransformerInterface.php index 8495905e170b6..4b6d4ac53b86a 100644 --- a/src/Symfony/Component/Form/DataTransformerInterface.php +++ b/src/Symfony/Component/Form/DataTransformerInterface.php @@ -55,11 +55,9 @@ interface DataTransformerInterface * * @param mixed $value The value in the original representation * - * @return mixed - * * @throws TransformationFailedException when the transformation fails */ - public function transform(mixed $value); + public function transform(mixed $value): mixed; /** * Transforms a value from the transformed representation to its original @@ -84,9 +82,7 @@ public function transform(mixed $value); * * @param mixed $value The value in the transformed representation * - * @return mixed - * * @throws TransformationFailedException when the transformation fails */ - public function reverseTransform(mixed $value); + public function reverseTransform(mixed $value): mixed; } diff --git a/src/Symfony/Component/Form/FormRendererEngineInterface.php b/src/Symfony/Component/Form/FormRendererEngineInterface.php index aa249270a0688..fd813235b8a88 100644 --- a/src/Symfony/Component/Form/FormRendererEngineInterface.php +++ b/src/Symfony/Component/Form/FormRendererEngineInterface.php @@ -127,8 +127,6 @@ public function getResourceHierarchyLevel(FormView $view, array $blockNameHierar * @param FormView $view The view to render * @param mixed $resource The renderer resource * @param array $variables The variables to pass to the template - * - * @return string */ - public function renderBlock(FormView $view, mixed $resource, string $blockName, array $variables = []); + public function renderBlock(FormView $view, mixed $resource, string $blockName, array $variables = []): string; } diff --git a/src/Symfony/Component/Form/FormTypeGuesserInterface.php b/src/Symfony/Component/Form/FormTypeGuesserInterface.php index 61e2c5f80d45a..e895c0f085271 100644 --- a/src/Symfony/Component/Form/FormTypeGuesserInterface.php +++ b/src/Symfony/Component/Form/FormTypeGuesserInterface.php @@ -18,24 +18,18 @@ interface FormTypeGuesserInterface { /** * Returns a field guess for a property name of a class. - * - * @return Guess\TypeGuess|null */ - public function guessType(string $class, string $property); + public function guessType(string $class, string $property): ?Guess\TypeGuess; /** * Returns a guess whether a property of a class is required. - * - * @return Guess\ValueGuess|null */ - public function guessRequired(string $class, string $property); + public function guessRequired(string $class, string $property): ?Guess\ValueGuess; /** * Returns a guess about the field's maximum length. - * - * @return Guess\ValueGuess|null */ - public function guessMaxLength(string $class, string $property); + public function guessMaxLength(string $class, string $property): ?Guess\ValueGuess; /** * Returns a guess about the field's pattern. @@ -46,8 +40,6 @@ public function guessMaxLength(string $class, string $property); * You want a float greater than 5, 4.512313 is not valid but length(4.512314) > length(5) * * @see https://github.com/symfony/symfony/pull/3927 - * - * @return Guess\ValueGuess|null */ - public function guessPattern(string $class, string $property); + public function guessPattern(string $class, string $property): ?Guess\ValueGuess; } diff --git a/src/Symfony/Component/Form/FormTypeInterface.php b/src/Symfony/Component/Form/FormTypeInterface.php index 2b9066a511f42..614a25827c46c 100644 --- a/src/Symfony/Component/Form/FormTypeInterface.php +++ b/src/Symfony/Component/Form/FormTypeInterface.php @@ -73,15 +73,11 @@ public function configureOptions(OptionsResolver $resolver); * * The block prefix defaults to the underscored short class name with * the "Type" suffix removed (e.g. "UserProfileType" => "user_profile"). - * - * @return string */ - public function getBlockPrefix(); + public function getBlockPrefix(): string; /** * Returns the name of the parent type. - * - * @return string|null */ - public function getParent(); + public function getParent(): ?string; } diff --git a/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerInterface.php b/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerInterface.php index 1f1740b7e2d3c..d1c5101869e91 100644 --- a/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerInterface.php +++ b/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerInterface.php @@ -25,8 +25,6 @@ interface CacheWarmerInterface extends WarmableInterface * * A warmer should return true if the cache can be * generated incrementally and on-demand. - * - * @return bool */ - public function isOptional(); + public function isOptional(): bool; } diff --git a/src/Symfony/Component/HttpKernel/CacheWarmer/WarmableInterface.php b/src/Symfony/Component/HttpKernel/CacheWarmer/WarmableInterface.php index 2f442cb5368b4..d98909cfae307 100644 --- a/src/Symfony/Component/HttpKernel/CacheWarmer/WarmableInterface.php +++ b/src/Symfony/Component/HttpKernel/CacheWarmer/WarmableInterface.php @@ -23,5 +23,5 @@ interface WarmableInterface * * @return string[] A list of classes or files to preload on PHP 7.4+ */ - public function warmUp(string $cacheDir); + public function warmUp(string $cacheDir): array; } diff --git a/src/Symfony/Component/HttpKernel/DataCollector/DataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/DataCollector.php index 1c9b597872f3d..598faeee34518 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/DataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/DataCollector.php @@ -61,7 +61,7 @@ protected function cloneVar(mixed $var): Data /** * @return callable[] The casters to add to the cloner */ - protected function getCasters() + protected function getCasters(): array { $casters = [ '*' => function ($v, array $a, Stub $s, $isNested) { diff --git a/src/Symfony/Component/HttpKernel/DataCollector/DataCollectorInterface.php b/src/Symfony/Component/HttpKernel/DataCollector/DataCollectorInterface.php index 1cb865fd66036..0d67b8e463827 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/DataCollectorInterface.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/DataCollectorInterface.php @@ -29,8 +29,6 @@ public function collect(Request $request, Response $response, \Throwable $except /** * Returns the name of the collector. - * - * @return string */ - public function getName(); + public function getName(): string; } diff --git a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php index 7d107dc2c65bf..8aa0b679a4092 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php @@ -442,10 +442,8 @@ protected function fetch(Request $request, bool $catch = false): Response * * @param bool $catch Whether to catch exceptions or not * @param Response|null $entry A Response instance (the stale entry if present, null otherwise) - * - * @return Response */ - protected function forward(Request $request, bool $catch = false, Response $entry = null) + protected function forward(Request $request, bool $catch = false, Response $entry = null): Response { if ($this->surrogate) { $this->surrogate->addSurrogateCapability($request); diff --git a/src/Symfony/Component/HttpKernel/HttpKernelBrowser.php b/src/Symfony/Component/HttpKernel/HttpKernelBrowser.php index 1d277f2c155ad..14f920c09985e 100644 --- a/src/Symfony/Component/HttpKernel/HttpKernelBrowser.php +++ b/src/Symfony/Component/HttpKernel/HttpKernelBrowser.php @@ -57,10 +57,8 @@ public function catchExceptions(bool $catchExceptions) * {@inheritdoc} * * @param Request $request - * - * @return Response */ - protected function doRequest(object $request) + protected function doRequest(object $request): Response { $response = $this->kernel->handle($request, HttpKernelInterface::MAIN_REQUEST, $this->catchExceptions); @@ -75,10 +73,8 @@ protected function doRequest(object $request) * {@inheritdoc} * * @param Request $request - * - * @return string */ - protected function getScript(object $request) + protected function getScript(object $request): string { $kernel = var_export(serialize($this->kernel), true); $request = var_export(serialize($request), true); diff --git a/src/Symfony/Component/HttpKernel/Log/DebugLoggerInterface.php b/src/Symfony/Component/HttpKernel/Log/DebugLoggerInterface.php index 19ff0db181ef7..2c1b21aefd919 100644 --- a/src/Symfony/Component/HttpKernel/Log/DebugLoggerInterface.php +++ b/src/Symfony/Component/HttpKernel/Log/DebugLoggerInterface.php @@ -26,17 +26,13 @@ interface DebugLoggerInterface * A log is an array with the following mandatory keys: * timestamp, message, priority, and priorityName. * It can also have an optional context key containing an array. - * - * @return array */ - public function getLogs(Request $request = null); + public function getLogs(Request $request = null): array; /** * Returns the number of errors. - * - * @return int */ - public function countErrors(Request $request = null); + public function countErrors(Request $request = null): int; /** * Removes all log records. diff --git a/src/Symfony/Component/OptionsResolver/OptionsResolver.php b/src/Symfony/Component/OptionsResolver/OptionsResolver.php index b17c3ecbbcab1..8bb4cb5824bdb 100644 --- a/src/Symfony/Component/OptionsResolver/OptionsResolver.php +++ b/src/Symfony/Component/OptionsResolver/OptionsResolver.php @@ -483,7 +483,7 @@ public function isDeprecated(string $option): bool * @throws UndefinedOptionsException If the option is undefined * @throws AccessException If called from a lazy option or normalizer */ - public function setNormalizer(string $option, \Closure $normalizer) + public function setNormalizer(string $option, \Closure $normalizer): static { if ($this->locked) { throw new AccessException('Normalizers cannot be set from a lazy option or normalizer.'); @@ -567,7 +567,7 @@ public function addNormalizer(string $option, \Closure $normalizer, bool $forceP * @throws UndefinedOptionsException If the option is undefined * @throws AccessException If called from a lazy option or normalizer */ - public function setAllowedValues(string $option, mixed $allowedValues) + public function setAllowedValues(string $option, mixed $allowedValues): static { if ($this->locked) { throw new AccessException('Allowed values cannot be set from a lazy option or normalizer.'); @@ -607,7 +607,7 @@ public function setAllowedValues(string $option, mixed $allowedValues) * @throws UndefinedOptionsException If the option is undefined * @throws AccessException If called from a lazy option or normalizer */ - public function addAllowedValues(string $option, mixed $allowedValues) + public function addAllowedValues(string $option, mixed $allowedValues): static { if ($this->locked) { throw new AccessException('Allowed values cannot be added from a lazy option or normalizer.'); @@ -647,7 +647,7 @@ public function addAllowedValues(string $option, mixed $allowedValues) * @throws UndefinedOptionsException If the option is undefined * @throws AccessException If called from a lazy option or normalizer */ - public function setAllowedTypes(string $option, string|array $allowedTypes) + public function setAllowedTypes(string $option, string|array $allowedTypes): static { if ($this->locked) { throw new AccessException('Allowed types cannot be set from a lazy option or normalizer.'); @@ -681,7 +681,7 @@ public function setAllowedTypes(string $option, string|array $allowedTypes) * @throws UndefinedOptionsException If the option is undefined * @throws AccessException If called from a lazy option or normalizer */ - public function addAllowedTypes(string $option, string|array $allowedTypes) + public function addAllowedTypes(string $option, string|array $allowedTypes): static { if ($this->locked) { throw new AccessException('Allowed types cannot be added from a lazy option or normalizer.'); diff --git a/src/Symfony/Component/PropertyAccess/PropertyPathInterface.php b/src/Symfony/Component/PropertyAccess/PropertyPathInterface.php index 90eab97103e5e..a8f316d180742 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyPathInterface.php +++ b/src/Symfony/Component/PropertyAccess/PropertyPathInterface.php @@ -25,10 +25,8 @@ public function __toString(): string; /** * Returns the length of the property path, i.e. the number of elements. - * - * @return int */ - public function getLength(); + public function getLength(): int; /** * Returns the parent property path. @@ -37,48 +35,38 @@ public function getLength(); * this one except for the last one. * * If this property path only contains one item, null is returned. - * - * @return self|null */ - public function getParent(); + public function getParent(): ?self; /** * Returns the elements of the property path as array. - * - * @return array */ - public function getElements(); + public function getElements(): array; /** * Returns the element at the given index in the property path. * * @param int $index The index key * - * @return string - * * @throws Exception\OutOfBoundsException If the offset is invalid */ - public function getElement(int $index); + public function getElement(int $index): string; /** * Returns whether the element at the given index is a property. * * @param int $index The index in the property path * - * @return bool - * * @throws Exception\OutOfBoundsException If the offset is invalid */ - public function isProperty(int $index); + public function isProperty(int $index): bool; /** * Returns whether the element at the given index is an array index. * * @param int $index The index in the property path * - * @return bool - * * @throws Exception\OutOfBoundsException If the offset is invalid */ - public function isIndex(int $index); + public function isIndex(int $index): bool; } diff --git a/src/Symfony/Component/PropertyInfo/PropertyAccessExtractorInterface.php b/src/Symfony/Component/PropertyInfo/PropertyAccessExtractorInterface.php index f9ee787130c8e..290d81c945506 100644 --- a/src/Symfony/Component/PropertyInfo/PropertyAccessExtractorInterface.php +++ b/src/Symfony/Component/PropertyInfo/PropertyAccessExtractorInterface.php @@ -20,15 +20,11 @@ interface PropertyAccessExtractorInterface { /** * Is the property readable? - * - * @return bool|null */ - public function isReadable(string $class, string $property, array $context = []); + public function isReadable(string $class, string $property, array $context = []): ?bool; /** * Is the property writable? - * - * @return bool|null */ - public function isWritable(string $class, string $property, array $context = []); + public function isWritable(string $class, string $property, array $context = []): ?bool; } diff --git a/src/Symfony/Component/PropertyInfo/PropertyListExtractorInterface.php b/src/Symfony/Component/PropertyInfo/PropertyListExtractorInterface.php index 326e6cccb36af..ae7c6b612bd28 100644 --- a/src/Symfony/Component/PropertyInfo/PropertyListExtractorInterface.php +++ b/src/Symfony/Component/PropertyInfo/PropertyListExtractorInterface.php @@ -23,5 +23,5 @@ interface PropertyListExtractorInterface * * @return string[]|null */ - public function getProperties(string $class, array $context = []); + public function getProperties(string $class, array $context = []): ?array; } diff --git a/src/Symfony/Component/PropertyInfo/PropertyTypeExtractorInterface.php b/src/Symfony/Component/PropertyInfo/PropertyTypeExtractorInterface.php index 6da0bcb4c8a98..16e9765b1d5b9 100644 --- a/src/Symfony/Component/PropertyInfo/PropertyTypeExtractorInterface.php +++ b/src/Symfony/Component/PropertyInfo/PropertyTypeExtractorInterface.php @@ -23,5 +23,5 @@ interface PropertyTypeExtractorInterface * * @return Type[]|null */ - public function getTypes(string $class, string $property, array $context = []); + public function getTypes(string $class, string $property, array $context = []): ?array; } diff --git a/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php b/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php index d7f9d5bba1efb..ce463479200b1 100644 --- a/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php +++ b/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php @@ -256,10 +256,8 @@ public function getResolver(): LoaderResolverInterface /** * Gets the default route name for a class method. - * - * @return string */ - protected function getDefaultRouteName(\ReflectionClass $class, \ReflectionMethod $method) + protected function getDefaultRouteName(\ReflectionClass $class, \ReflectionMethod $method): string { $name = str_replace('\\', '_', $class->name).'_'.$method->name; $name = \function_exists('mb_strtolower') && preg_match('//u', $name) ? mb_strtolower($name, 'UTF-8') : strtolower($name); diff --git a/src/Symfony/Component/Routing/Router.php b/src/Symfony/Component/Routing/Router.php index 8436fe7bd6507..7b35b5e8724a8 100644 --- a/src/Symfony/Component/Routing/Router.php +++ b/src/Symfony/Component/Routing/Router.php @@ -180,7 +180,7 @@ public function getOption(string $key): mixed /** * {@inheritdoc} */ - public function getRouteCollection() + public function getRouteCollection(): RouteCollection { if (null === $this->collection) { $this->collection = $this->loader->load($this->resource, $this->options['resource_type']); diff --git a/src/Symfony/Component/Routing/RouterInterface.php b/src/Symfony/Component/Routing/RouterInterface.php index 6912f8a15b0a8..5800f85553531 100644 --- a/src/Symfony/Component/Routing/RouterInterface.php +++ b/src/Symfony/Component/Routing/RouterInterface.php @@ -28,8 +28,6 @@ interface RouterInterface extends UrlMatcherInterface, UrlGeneratorInterface * * WARNING: This method should never be used at runtime as it is SLOW. * You might use it in a cache warmer though. - * - * @return RouteCollection */ - public function getRouteCollection(); + public function getRouteCollection(): RouteCollection; } diff --git a/src/Symfony/Component/Security/Core/Authentication/RememberMe/TokenProviderInterface.php b/src/Symfony/Component/Security/Core/Authentication/RememberMe/TokenProviderInterface.php index eda4730004414..78b2f82947c1b 100644 --- a/src/Symfony/Component/Security/Core/Authentication/RememberMe/TokenProviderInterface.php +++ b/src/Symfony/Component/Security/Core/Authentication/RememberMe/TokenProviderInterface.php @@ -23,11 +23,9 @@ interface TokenProviderInterface /** * Loads the active token for the given series. * - * @return PersistentTokenInterface - * * @throws TokenNotFoundException if the token is not found */ - public function loadTokenBySeries(string $series); + public function loadTokenBySeries(string $series): PersistentTokenInterface; /** * Deletes all tokens belonging to series. diff --git a/src/Symfony/Component/Security/Core/Exception/AuthenticationException.php b/src/Symfony/Component/Security/Core/Exception/AuthenticationException.php index 606c812fad525..952a83c829cb9 100644 --- a/src/Symfony/Component/Security/Core/Exception/AuthenticationException.php +++ b/src/Symfony/Component/Security/Core/Exception/AuthenticationException.php @@ -76,10 +76,8 @@ public function __unserialize(array $data): void /** * Message key to be used by the translation component. - * - * @return string */ - public function getMessageKey() + public function getMessageKey(): string { return 'An authentication exception occurred.'; } diff --git a/src/Symfony/Component/Security/Core/User/UserProviderInterface.php b/src/Symfony/Component/Security/Core/User/UserProviderInterface.php index 33d489f6d7359..4ef7280871158 100644 --- a/src/Symfony/Component/Security/Core/User/UserProviderInterface.php +++ b/src/Symfony/Component/Security/Core/User/UserProviderInterface.php @@ -29,8 +29,6 @@ * * @see UserInterface * - * @method UserInterface loadUserByIdentifier(string $identifier) - * * @author Fabien Potencier */ interface UserProviderInterface @@ -43,19 +41,15 @@ interface UserProviderInterface * object can just be merged into some internal array of users / identity * map. * - * @return UserInterface - * * @throws UnsupportedUserException if the user is not supported * @throws UserNotFoundException if the user is not found */ - public function refreshUser(UserInterface $user); + public function refreshUser(UserInterface $user): UserInterface; /** * Whether this provider supports the given user class. - * - * @return bool */ - public function supportsClass(string $class); + public function supportsClass(string $class): bool; /** * Loads the user for the given user identifier (e.g. username or email). diff --git a/src/Symfony/Component/Security/Http/EntryPoint/AuthenticationEntryPointInterface.php b/src/Symfony/Component/Security/Http/EntryPoint/AuthenticationEntryPointInterface.php index 91271d14a3d98..d4c7acd826028 100644 --- a/src/Symfony/Component/Security/Http/EntryPoint/AuthenticationEntryPointInterface.php +++ b/src/Symfony/Component/Security/Http/EntryPoint/AuthenticationEntryPointInterface.php @@ -39,8 +39,6 @@ interface AuthenticationEntryPointInterface * - For an API token authentication system, you return a 401 response * * return new Response('Auth header required', 401); - * - * @return Response */ - 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/Firewall.php b/src/Symfony/Component/Security/Http/Firewall.php index 49b2b9a0d4eac..27ad80e8d03a1 100644 --- a/src/Symfony/Component/Security/Http/Firewall.php +++ b/src/Symfony/Component/Security/Http/Firewall.php @@ -99,7 +99,7 @@ public function onKernelFinishRequest(FinishRequestEvent $event) /** * {@inheritdoc} */ - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ KernelEvents::REQUEST => ['onKernelRequest', 8], diff --git a/src/Symfony/Component/Security/Http/FirewallMapInterface.php b/src/Symfony/Component/Security/Http/FirewallMapInterface.php index 6704940153b72..ee0f2ed470925 100644 --- a/src/Symfony/Component/Security/Http/FirewallMapInterface.php +++ b/src/Symfony/Component/Security/Http/FirewallMapInterface.php @@ -35,5 +35,5 @@ interface FirewallMapInterface * * @return array of the format [[AuthenticationListener], ExceptionListener, LogoutListener] */ - public function getListeners(Request $request); + public function getListeners(Request $request): array; } diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php index 73f2df3ecf954..960082227139b 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php @@ -74,29 +74,6 @@ public function getAuthenticationExceptionProvider() ]; } - /** - * This test should be removed in Symfony 7.0 when adding native return types to AuthenticationEntryPointInterface::start(). - * - * @group legacy - */ - public function testExceptionWhenEntryPointReturnsBadValue() - { - if ((new \ReflectionMethod(AuthenticationEntryPointInterface::class, 'start'))->hasReturnType()) { - $this->markTestSkipped('Native return type found'); - } - - $event = $this->createEvent(new AuthenticationException()); - - $entryPoint = $this->createMock(AuthenticationEntryPointInterface::class); - $entryPoint->expects($this->once())->method('start')->willReturn('NOT A RESPONSE'); - - $listener = $this->createExceptionListener(null, null, null, $entryPoint); - $listener->onKernelException($event); - // the exception has been replaced by our LogicException - $this->assertInstanceOf(\LogicException::class, $event->getThrowable()); - $this->assertStringEndsWith('start()" method must return a Response object ("string" returned).', $event->getThrowable()->getMessage()); - } - /** * @dataProvider getAccessDeniedExceptionProvider */ diff --git a/src/Symfony/Component/Translation/Extractor/AbstractFileExtractor.php b/src/Symfony/Component/Translation/Extractor/AbstractFileExtractor.php index 4c088b94f991e..a6198feb0caf6 100644 --- a/src/Symfony/Component/Translation/Extractor/AbstractFileExtractor.php +++ b/src/Symfony/Component/Translation/Extractor/AbstractFileExtractor.php @@ -55,13 +55,7 @@ protected function isFile(string $file): bool return true; } - /** - * @return bool - */ - abstract protected function canBeExtracted(string $file); + abstract protected function canBeExtracted(string $file): bool; - /** - * @return iterable - */ - abstract protected function extractFromDirectory(string|array $resource); + abstract protected function extractFromDirectory(string|array $resource): iterable; } diff --git a/src/Symfony/Component/Validator/Constraint.php b/src/Symfony/Component/Validator/Constraint.php index 012a483de2640..a0ca03355d44c 100644 --- a/src/Symfony/Component/Validator/Constraint.php +++ b/src/Symfony/Component/Validator/Constraint.php @@ -230,11 +230,9 @@ public function addImplicitGroupName(string $group) * * Override this method to define a default option. * - * @return string|null - * * @see __construct() */ - public function getDefaultOption() + public function getDefaultOption(): ?string { return null; } @@ -248,7 +246,7 @@ public function getDefaultOption() * * @see __construct() */ - public function getRequiredOptions() + public function getRequiredOptions(): array { return []; } @@ -259,10 +257,8 @@ public function getRequiredOptions() * By default, this is the fully qualified name of the constraint class * suffixed with "Validator". You can override this method to change that * behavior. - * - * @return string */ - public function validatedBy() + public function validatedBy(): string { return static::class.'Validator'; } @@ -276,7 +272,7 @@ public function validatedBy() * * @return string|string[] One or more constant values */ - public function getTargets() + public function getTargets(): string|array { return self::PROPERTY_CONSTRAINT; }