From 00f08e4b9d88a23ae162e3b8c58df9e56e577e34 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 12 Aug 2021 18:25:52 +0200 Subject: [PATCH] Add return types - batch 5/n --- .../Debug/TraceableEventDispatcher.php | 20 ++----- .../RegisterListenersPass.php | 4 +- .../EventDispatcher/EventDispatcher.php | 6 +- .../EventDispatcherInterface.php | 6 +- .../EventDispatcher/GenericEvent.php | 16 ++--- .../ImmutableEventDispatcher.php | 6 +- .../Component/ExpressionLanguage/Compiler.php | 10 ++-- .../ExpressionLanguage/ExpressionFunction.php | 19 ++---- .../ExpressionLanguage/ExpressionLanguage.php | 8 +-- .../Component/ExpressionLanguage/Lexer.php | 4 +- .../Component/ExpressionLanguage/Parser.php | 2 +- .../Component/ExpressionLanguage/Token.php | 4 +- .../ExpressionLanguage/TokenStream.php | 4 +- .../OptionsResolver/OptionsResolver.php | 34 +++++------ .../PropertyAccess/PropertyAccessor.php | 10 ++-- .../PropertyAccessorBuilder.php | 30 +++++----- .../PropertyAccessorInterface.php | 6 +- .../Component/PropertyAccess/PropertyPath.php | 12 ++-- .../PropertyAccess/PropertyPathBuilder.php | 4 +- .../PropertyAccess/PropertyPathIterator.php | 4 +- .../PropertyPathIteratorInterface.php | 8 +-- .../PropertyDescriptionExtractorInterface.php | 8 +-- .../Component/Routing/CompiledRoute.php | 16 ++--- .../Exception/MethodNotAllowedException.php | 2 +- .../Generator/CompiledUrlGenerator.php | 2 +- .../ConfigurableRequirementsInterface.php | 4 +- .../Dumper/CompiledUrlGeneratorDumper.php | 2 +- .../Generator/Dumper/GeneratorDumper.php | 2 +- .../Dumper/GeneratorDumperInterface.php | 6 +- .../Routing/Generator/UrlGenerator.php | 12 ++-- .../Generator/UrlGeneratorInterface.php | 2 +- .../Routing/Loader/AnnotationClassLoader.php | 6 +- .../Loader/AnnotationDirectoryLoader.php | 4 +- .../Routing/Loader/AnnotationFileLoader.php | 6 +- .../Routing/Loader/ClosureLoader.php | 4 +- .../Configurator/CollectionConfigurator.php | 2 +- .../Configurator/ImportConfigurator.php | 2 +- .../Routing/Loader/ContainerLoader.php | 4 +- .../Routing/Loader/DirectoryLoader.php | 4 +- .../Routing/Loader/GlobFileLoader.php | 4 +- .../Component/Routing/Loader/ObjectLoader.php | 4 +- .../Routing/Loader/PhpFileLoader.php | 4 +- .../Routing/Loader/XmlFileLoader.php | 6 +- .../Routing/Loader/YamlFileLoader.php | 4 +- .../Dumper/CompiledUrlMatcherDumper.php | 2 +- .../Routing/Matcher/Dumper/MatcherDumper.php | 2 +- .../Matcher/Dumper/MatcherDumperInterface.php | 4 +- .../Matcher/ExpressionLanguageProvider.php | 2 +- .../Matcher/RedirectableUrlMatcher.php | 2 +- .../RedirectableUrlMatcherInterface.php | 2 +- .../Matcher/RequestMatcherInterface.php | 2 +- .../Routing/Matcher/TraceableUrlMatcher.php | 2 +- .../Component/Routing/Matcher/UrlMatcher.php | 14 ++--- .../Routing/Matcher/UrlMatcherInterface.php | 2 +- .../Component/Routing/RequestContext.php | 44 +++++++------- .../Routing/RequestContextAwareInterface.php | 2 +- src/Symfony/Component/Routing/Route.php | 60 +++++++++---------- .../Component/Routing/RouteCollection.php | 6 +- .../Component/Routing/RouteCompiler.php | 2 +- .../Routing/RouteCompilerInterface.php | 2 +- src/Symfony/Component/Routing/Router.php | 18 +++--- .../Catalogue/AbstractOperation.php | 10 ++-- .../Catalogue/OperationInterface.php | 10 ++-- .../Translation/Command/XliffLintCommand.php | 2 +- .../TranslationDataCollector.php | 2 +- .../Translation/DataCollectorTranslator.php | 8 +-- .../TranslatorPathsPass.php | 2 +- .../Translation/Dumper/CsvFileDumper.php | 4 +- .../Translation/Dumper/FileDumper.php | 4 +- .../Translation/Dumper/IcuResFileDumper.php | 4 +- .../Translation/Dumper/IniFileDumper.php | 4 +- .../Translation/Dumper/JsonFileDumper.php | 4 +- .../Translation/Dumper/MoFileDumper.php | 4 +- .../Translation/Dumper/PhpFileDumper.php | 4 +- .../Translation/Dumper/PoFileDumper.php | 4 +- .../Translation/Dumper/QtFileDumper.php | 4 +- .../Translation/Dumper/XliffFileDumper.php | 4 +- .../Translation/Dumper/YamlFileDumper.php | 4 +- .../Extractor/AbstractFileExtractor.php | 4 +- .../Translation/Extractor/PhpExtractor.php | 6 +- .../Extractor/PhpStringTokenParser.php | 6 +- .../Formatter/MessageFormatter.php | 2 +- .../Formatter/MessageFormatterInterface.php | 2 +- .../Translation/Loader/ArrayLoader.php | 2 +- .../Translation/Loader/CsvFileLoader.php | 2 +- .../Translation/Loader/FileLoader.php | 5 +- .../Translation/Loader/IcuDatFileLoader.php | 2 +- .../Translation/Loader/IcuResFileLoader.php | 4 +- .../Translation/Loader/IniFileLoader.php | 2 +- .../Translation/Loader/JsonFileLoader.php | 2 +- .../Translation/Loader/LoaderInterface.php | 2 +- .../Translation/Loader/MoFileLoader.php | 2 +- .../Translation/Loader/PhpFileLoader.php | 2 +- .../Translation/Loader/PoFileLoader.php | 2 +- .../Translation/Loader/QtFileLoader.php | 2 +- .../Translation/Loader/XliffFileLoader.php | 2 +- .../Translation/Loader/YamlFileLoader.php | 2 +- .../Translation/LoggingTranslator.php | 4 +- .../Translation/MessageCatalogue.php | 16 ++--- .../Translation/MessageCatalogueInterface.php | 18 +++--- .../Translation/MetadataAwareInterface.php | 2 +- .../Component/Translation/Translator.php | 4 +- .../Translation/TranslatorBagInterface.php | 2 +- .../Translation/Util/ArrayConverter.php | 2 +- .../Translation/Writer/TranslationWriter.php | 2 +- 105 files changed, 313 insertions(+), 363 deletions(-) diff --git a/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php b/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php index edea60f866f98..0593fe99cc9d0 100644 --- a/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php +++ b/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php @@ -92,7 +92,7 @@ public function removeSubscriber(EventSubscriberInterface $subscriber) /** * {@inheritdoc} */ - public function getListeners(string $eventName = null) + public function getListeners(string $eventName = null): array { return $this->dispatcher->getListeners($eventName); } @@ -100,7 +100,7 @@ public function getListeners(string $eventName = null) /** * {@inheritdoc} */ - public function getListenerPriority(string $eventName, callable|array $listener) + public function getListenerPriority(string $eventName, callable|array $listener): ?int { // we might have wrapped listeners for the event (if called while dispatching) // in that case get the priority by wrapper @@ -118,7 +118,7 @@ public function getListenerPriority(string $eventName, callable|array $listener) /** * {@inheritdoc} */ - public function hasListeners(string $eventName = null) + public function hasListeners(string $eventName = null): bool { return $this->dispatcher->hasListeners($eventName); } @@ -163,10 +163,7 @@ public function dispatch(object $event, string $eventName = null): object return $event; } - /** - * @return array - */ - public function getCalledListeners(Request $request = null) + public function getCalledListeners(Request $request = null): array { if (null === $this->callStack) { return []; @@ -184,10 +181,7 @@ public function getCalledListeners(Request $request = null) return $called; } - /** - * @return array - */ - public function getNotCalledListeners(Request $request = null) + public function getNotCalledListeners(Request $request = null): array { try { $allListeners = $this->getListeners(); @@ -255,10 +249,8 @@ public function reset() * * @param string $method The method name * @param array $arguments The method arguments - * - * @return mixed */ - public function __call(string $method, array $arguments) + public function __call(string $method, array $arguments): mixed { return $this->dispatcher->{$method}(...$arguments); } diff --git a/src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php b/src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php index e57f65041f0cf..8dd589d52acb2 100644 --- a/src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php +++ b/src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php @@ -31,7 +31,7 @@ class RegisterListenersPass implements CompilerPassInterface /** * @return $this */ - public function setHotPathEvents(array $hotPathEvents) + public function setHotPathEvents(array $hotPathEvents): static { $this->hotPathEvents = array_flip($hotPathEvents); @@ -41,7 +41,7 @@ public function setHotPathEvents(array $hotPathEvents) /** * @return $this */ - public function setNoPreloadEvents(array $noPreloadEvents): self + public function setNoPreloadEvents(array $noPreloadEvents): static { $this->noPreloadEvents = array_flip($noPreloadEvents); diff --git a/src/Symfony/Component/EventDispatcher/EventDispatcher.php b/src/Symfony/Component/EventDispatcher/EventDispatcher.php index 021d668eaa004..33d91b7d28e3d 100644 --- a/src/Symfony/Component/EventDispatcher/EventDispatcher.php +++ b/src/Symfony/Component/EventDispatcher/EventDispatcher.php @@ -65,7 +65,7 @@ public function dispatch(object $event, string $eventName = null): object /** * {@inheritdoc} */ - public function getListeners(string $eventName = null) + public function getListeners(string $eventName = null): array { if (null !== $eventName) { if (empty($this->listeners[$eventName])) { @@ -91,7 +91,7 @@ public function getListeners(string $eventName = null) /** * {@inheritdoc} */ - public function getListenerPriority(string $eventName, callable|array $listener) + public function getListenerPriority(string $eventName, callable|array $listener): ?int { if (empty($this->listeners[$eventName])) { return null; @@ -120,7 +120,7 @@ public function getListenerPriority(string $eventName, callable|array $listener) /** * {@inheritdoc} */ - public function hasListeners(string $eventName = null) + public function hasListeners(string $eventName = null): bool { if (null !== $eventName) { return !empty($this->listeners[$eventName]); diff --git a/src/Symfony/Component/EventDispatcher/EventDispatcherInterface.php b/src/Symfony/Component/EventDispatcher/EventDispatcherInterface.php index 9251e02e67ea8..6de7750319b68 100644 --- a/src/Symfony/Component/EventDispatcher/EventDispatcherInterface.php +++ b/src/Symfony/Component/EventDispatcher/EventDispatcherInterface.php @@ -50,7 +50,7 @@ public function removeSubscriber(EventSubscriberInterface $subscriber); * * @return array The event listeners for the specified event, or all event listeners by event name */ - public function getListeners(string $eventName = null); + public function getListeners(string $eventName = null): array; /** * Gets the listener priority for a specific event. @@ -59,12 +59,12 @@ public function getListeners(string $eventName = null); * * @return int|null The event listener priority */ - public function getListenerPriority(string $eventName, callable $listener); + public function getListenerPriority(string $eventName, callable $listener): ?int; /** * Checks whether an event has any registered listeners. * * @return bool true if the specified event has any listeners, false otherwise */ - public function hasListeners(string $eventName = null); + public function hasListeners(string $eventName = null): bool; } diff --git a/src/Symfony/Component/EventDispatcher/GenericEvent.php b/src/Symfony/Component/EventDispatcher/GenericEvent.php index 1871eec8e6b3c..202a0f04aaded 100644 --- a/src/Symfony/Component/EventDispatcher/GenericEvent.php +++ b/src/Symfony/Component/EventDispatcher/GenericEvent.php @@ -42,7 +42,7 @@ public function __construct(mixed $subject = null, array $arguments = []) * * @return mixed The observer subject */ - public function getSubject() + public function getSubject(): mixed { return $this->subject; } @@ -54,7 +54,7 @@ public function getSubject() * * @throws \InvalidArgumentException if key is not found */ - public function getArgument(string $key) + public function getArgument(string $key): mixed { if ($this->hasArgument($key)) { return $this->arguments[$key]; @@ -68,7 +68,7 @@ public function getArgument(string $key) * * @return $this */ - public function setArgument(string $key, mixed $value) + public function setArgument(string $key, mixed $value): static { $this->arguments[$key] = $value; @@ -77,10 +77,8 @@ public function setArgument(string $key, mixed $value) /** * Getter for all arguments. - * - * @return array */ - public function getArguments() + public function getArguments(): array { return $this->arguments; } @@ -90,7 +88,7 @@ public function getArguments() * * @return $this */ - public function setArguments(array $args = []) + public function setArguments(array $args = []): static { $this->arguments = $args; @@ -99,10 +97,8 @@ public function setArguments(array $args = []) /** * Has argument. - * - * @return bool */ - public function hasArgument(string $key) + public function hasArgument(string $key): bool { return \array_key_exists($key, $this->arguments); } diff --git a/src/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php b/src/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php index 6bc8bfffaeb96..a54358284985e 100644 --- a/src/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php +++ b/src/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php @@ -68,7 +68,7 @@ public function removeSubscriber(EventSubscriberInterface $subscriber) /** * {@inheritdoc} */ - public function getListeners(string $eventName = null) + public function getListeners(string $eventName = null): array { return $this->dispatcher->getListeners($eventName); } @@ -76,7 +76,7 @@ public function getListeners(string $eventName = null) /** * {@inheritdoc} */ - public function getListenerPriority(string $eventName, callable|array $listener) + public function getListenerPriority(string $eventName, callable|array $listener): ?int { return $this->dispatcher->getListenerPriority($eventName, $listener); } @@ -84,7 +84,7 @@ public function getListenerPriority(string $eventName, callable|array $listener) /** * {@inheritdoc} */ - public function hasListeners(string $eventName = null) + public function hasListeners(string $eventName = null): bool { return $this->dispatcher->hasListeners($eventName); } diff --git a/src/Symfony/Component/ExpressionLanguage/Compiler.php b/src/Symfony/Component/ExpressionLanguage/Compiler.php index 11260fa33cb88..738836eaaf723 100644 --- a/src/Symfony/Component/ExpressionLanguage/Compiler.php +++ b/src/Symfony/Component/ExpressionLanguage/Compiler.php @@ -38,7 +38,7 @@ public function getFunction(string $name) * * @return string The PHP code */ - public function getSource() + public function getSource(): string { return $this->source; } @@ -55,7 +55,7 @@ public function reset() * * @return $this */ - public function compile(Node\Node $node) + public function compile(Node\Node $node): static { $node->compile($this); @@ -80,7 +80,7 @@ public function subcompile(Node\Node $node) * * @return $this */ - public function raw(string $string) + public function raw(string $string): static { $this->source .= $string; @@ -92,7 +92,7 @@ public function raw(string $string) * * @return $this */ - public function string(string $value) + public function string(string $value): static { $this->source .= sprintf('"%s"', addcslashes($value, "\0\t\"\$\\")); @@ -104,7 +104,7 @@ public function string(string $value) * * @return $this */ - public function repr(mixed $value) + public function repr(mixed $value): static { if (\is_int($value) || \is_float($value)) { if (false !== $locale = setlocale(\LC_NUMERIC, 0)) { diff --git a/src/Symfony/Component/ExpressionLanguage/ExpressionFunction.php b/src/Symfony/Component/ExpressionLanguage/ExpressionFunction.php index 7d4662cedfa68..6cf14a0b48ce1 100644 --- a/src/Symfony/Component/ExpressionLanguage/ExpressionFunction.php +++ b/src/Symfony/Component/ExpressionLanguage/ExpressionFunction.php @@ -46,26 +46,17 @@ public function __construct(string $name, callable $compiler, callable $evaluato $this->evaluator = $evaluator instanceof \Closure ? $evaluator : \Closure::fromCallable($evaluator); } - /** - * @return string - */ - public function getName() + public function getName(): string { return $this->name; } - /** - * @return \Closure - */ - public function getCompiler() + public function getCompiler(): \Closure { return $this->compiler; } - /** - * @return \Closure - */ - public function getEvaluator() + public function getEvaluator(): \Closure { return $this->evaluator; } @@ -75,13 +66,11 @@ public function getEvaluator() * * @param string|null $expressionFunctionName The expression function name (default: same than the PHP function name) * - * @return self - * * @throws \InvalidArgumentException if given PHP function name does not exist * @throws \InvalidArgumentException if given PHP function name is in namespace * and expression function name is not defined */ - public static function fromPhp(string $phpFunctionName, string $expressionFunctionName = null) + public static function fromPhp(string $phpFunctionName, string $expressionFunctionName = null): self { $phpFunctionName = ltrim($phpFunctionName, '\\'); if (!\function_exists($phpFunctionName)) { diff --git a/src/Symfony/Component/ExpressionLanguage/ExpressionLanguage.php b/src/Symfony/Component/ExpressionLanguage/ExpressionLanguage.php index e0bc7ed89e7cc..200b5b2bfbfc4 100644 --- a/src/Symfony/Component/ExpressionLanguage/ExpressionLanguage.php +++ b/src/Symfony/Component/ExpressionLanguage/ExpressionLanguage.php @@ -48,7 +48,7 @@ public function __construct(CacheItemPoolInterface $cache = null, array $provide * * @return string The compiled PHP source code */ - public function compile(Expression|string $expression, array $names = []) + public function compile(Expression|string $expression, array $names = []): string { return $this->getCompiler()->compile($this->parse($expression, $names)->getNodes())->getSource(); } @@ -58,17 +58,15 @@ public function compile(Expression|string $expression, array $names = []) * * @return mixed The result of the evaluation of the expression */ - public function evaluate(Expression|string $expression, array $values = []) + public function evaluate(Expression|string $expression, array $values = []): mixed { return $this->parse($expression, array_keys($values))->getNodes()->evaluate($this->functions, $values); } /** * Parses an expression. - * - * @return ParsedExpression */ - public function parse(Expression|string $expression, array $names) + public function parse(Expression|string $expression, array $names): ParsedExpression { if ($expression instanceof ParsedExpression) { return $expression; diff --git a/src/Symfony/Component/ExpressionLanguage/Lexer.php b/src/Symfony/Component/ExpressionLanguage/Lexer.php index a5e8fd40dfc17..2c69d344dd44e 100644 --- a/src/Symfony/Component/ExpressionLanguage/Lexer.php +++ b/src/Symfony/Component/ExpressionLanguage/Lexer.php @@ -21,11 +21,9 @@ class Lexer /** * Tokenizes an expression. * - * @return TokenStream - * * @throws SyntaxError */ - public function tokenize(string $expression) + public function tokenize(string $expression): TokenStream { $expression = str_replace(["\r", "\n", "\t", "\v", "\f"], ' ', $expression); $cursor = 0; diff --git a/src/Symfony/Component/ExpressionLanguage/Parser.php b/src/Symfony/Component/ExpressionLanguage/Parser.php index e5ae97719638f..37ca825692460 100644 --- a/src/Symfony/Component/ExpressionLanguage/Parser.php +++ b/src/Symfony/Component/ExpressionLanguage/Parser.php @@ -90,7 +90,7 @@ public function __construct(array $functions) * * @throws SyntaxError */ - public function parse(TokenStream $stream, array $names = []) + public function parse(TokenStream $stream, array $names = []): Node\Node { $this->lint = false; diff --git a/src/Symfony/Component/ExpressionLanguage/Token.php b/src/Symfony/Component/ExpressionLanguage/Token.php index 4a789c3c7f49b..40f5cda314763 100644 --- a/src/Symfony/Component/ExpressionLanguage/Token.php +++ b/src/Symfony/Component/ExpressionLanguage/Token.php @@ -50,10 +50,8 @@ public function __toString(): string /** * Tests the current token for a type and/or a value. - * - * @return bool */ - public function test(string $type, string $value = null) + public function test(string $type, string $value = null): bool { return $this->type === $type && (null === $value || $this->value == $value); } diff --git a/src/Symfony/Component/ExpressionLanguage/TokenStream.php b/src/Symfony/Component/ExpressionLanguage/TokenStream.php index a94da8de33389..bbd1d8ab95789 100644 --- a/src/Symfony/Component/ExpressionLanguage/TokenStream.php +++ b/src/Symfony/Component/ExpressionLanguage/TokenStream.php @@ -67,10 +67,8 @@ public function expect(string $type, string $value = null, string $message = nul /** * Checks if end of stream was reached. - * - * @return bool */ - public function isEOF() + public function isEOF(): bool { return Token::EOF_TYPE === $this->current->type; } diff --git a/src/Symfony/Component/OptionsResolver/OptionsResolver.php b/src/Symfony/Component/OptionsResolver/OptionsResolver.php index e0da5a685caed..d3e8800d86f88 100644 --- a/src/Symfony/Component/OptionsResolver/OptionsResolver.php +++ b/src/Symfony/Component/OptionsResolver/OptionsResolver.php @@ -191,7 +191,7 @@ class OptionsResolver implements Options * * @throws AccessException If called from a lazy option or normalizer */ - public function setDefault(string $option, mixed $value) + public function setDefault(string $option, mixed $value): static { // Setting is not possible once resolving starts, because then lazy // options could manipulate the state of the object, leading to @@ -262,7 +262,7 @@ public function setDefault(string $option, mixed $value) * * @throws AccessException If called from a lazy option or normalizer */ - public function setDefaults(array $defaults) + public function setDefaults(array $defaults): static { foreach ($defaults as $option => $value) { $this->setDefault($option, $value); @@ -279,7 +279,7 @@ public function setDefaults(array $defaults) * * @return bool Whether a default value is set */ - public function hasDefault(string $option) + public function hasDefault(string $option): bool { return \array_key_exists($option, $this->defaults); } @@ -293,7 +293,7 @@ public function hasDefault(string $option) * * @throws AccessException If called from a lazy option or normalizer */ - public function setRequired(string|array $optionNames) + public function setRequired(string|array $optionNames): static { if ($this->locked) { throw new AccessException('Options cannot be made required from a lazy option or normalizer.'); @@ -314,7 +314,7 @@ public function setRequired(string|array $optionNames) * * @return bool Whether the option is required */ - public function isRequired(string $option) + public function isRequired(string $option): bool { return isset($this->required[$option]); } @@ -326,7 +326,7 @@ public function isRequired(string $option) * * @see isRequired() */ - public function getRequiredOptions() + public function getRequiredOptions(): array { return array_keys($this->required); } @@ -340,7 +340,7 @@ public function getRequiredOptions() * * @return bool Whether the option is missing */ - public function isMissing(string $option) + public function isMissing(string $option): bool { return isset($this->required[$option]) && !\array_key_exists($option, $this->defaults); } @@ -352,7 +352,7 @@ public function isMissing(string $option) * * @see isMissing() */ - public function getMissingOptions() + public function getMissingOptions(): array { return array_keys(array_diff_key($this->required, $this->defaults)); } @@ -370,7 +370,7 @@ public function getMissingOptions() * * @throws AccessException If called from a lazy option or normalizer */ - public function setDefined(string|array $optionNames) + public function setDefined(string|array $optionNames): static { if ($this->locked) { throw new AccessException('Options cannot be defined from a lazy option or normalizer.'); @@ -391,7 +391,7 @@ public function setDefined(string|array $optionNames) * * @return bool Whether the option is defined */ - public function isDefined(string $option) + public function isDefined(string $option): bool { return isset($this->defined[$option]); } @@ -403,7 +403,7 @@ public function isDefined(string $option) * * @see isDefined() */ - public function getDefinedOptions() + public function getDefinedOptions(): array { return array_keys($this->defined); } @@ -534,7 +534,7 @@ public function setNormalizer(string $option, \Closure $normalizer) * @throws UndefinedOptionsException If the option is undefined * @throws AccessException If called from a lazy option or normalizer */ - public function addNormalizer(string $option, \Closure $normalizer, bool $forcePrepend = false): self + public function addNormalizer(string $option, \Closure $normalizer, bool $forcePrepend = false): static { if ($this->locked) { throw new AccessException('Normalizers cannot be set from a lazy option or normalizer.'); @@ -733,7 +733,7 @@ public function define(string $option): OptionConfigurator * @throws UndefinedOptionsException If the option is undefined * @throws AccessException If called from a lazy option or normalizer */ - public function setInfo(string $option, string $info): self + public function setInfo(string $option, string $info): static { if ($this->locked) { throw new AccessException('The Info message cannot be set from a lazy option or normalizer.'); @@ -767,7 +767,7 @@ public function getInfo(string $option): ?string * * @throws AccessException If called from a lazy option, a normalizer or a root definition */ - public function setPrototype(bool $prototype): self + public function setPrototype(bool $prototype): static { if ($this->locked) { throw new AccessException('The prototype property cannot be set from a lazy option or normalizer.'); @@ -798,7 +798,7 @@ public function isPrototype(): bool * * @throws AccessException If called from a lazy option or normalizer */ - public function remove(string|array $optionNames) + public function remove(string|array $optionNames): static { if ($this->locked) { throw new AccessException('Options cannot be removed from a lazy option or normalizer.'); @@ -819,7 +819,7 @@ public function remove(string|array $optionNames) * * @throws AccessException If called from a lazy option or normalizer */ - public function clear() + public function clear(): static { if ($this->locked) { throw new AccessException('Options cannot be cleared from a lazy option or normalizer.'); @@ -862,7 +862,7 @@ public function clear() * @throws NoSuchOptionException If a lazy option reads an unavailable option * @throws AccessException If called from a lazy option or normalizer */ - public function resolve(array $options = []) + public function resolve(array $options = []): array { if ($this->locked) { throw new AccessException('Options cannot be resolved from a lazy option or normalizer.'); diff --git a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php index 0e439b53f512c..18960b8f9acc3 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php +++ b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php @@ -105,7 +105,7 @@ public function __construct(int $magicMethods = self::MAGIC_GET | self::MAGIC_SE /** * {@inheritdoc} */ - public function getValue(object|array $objectOrArray, string|PropertyPathInterface $propertyPath) + public function getValue(object|array $objectOrArray, string|PropertyPathInterface $propertyPath): mixed { $zval = [ self::VALUE => $objectOrArray, @@ -219,7 +219,7 @@ private static function throwInvalidArgumentException(string $message, array $tr /** * {@inheritdoc} */ - public function isReadable(object|array $objectOrArray, string|PropertyPathInterface $propertyPath) + public function isReadable(object|array $objectOrArray, string|PropertyPathInterface $propertyPath): bool { if (!$propertyPath instanceof PropertyPathInterface) { $propertyPath = new PropertyPath($propertyPath); @@ -242,7 +242,7 @@ public function isReadable(object|array $objectOrArray, string|PropertyPathInter /** * {@inheritdoc} */ - public function isWritable(object|array $objectOrArray, string|PropertyPathInterface $propertyPath) + public function isWritable(object|array $objectOrArray, string|PropertyPathInterface $propertyPath): bool { $propertyPath = $this->getPropertyPath($propertyPath); @@ -651,11 +651,9 @@ private function getPropertyPath(string|PropertyPath $propertyPath): PropertyPat /** * Creates the APCu adapter if applicable. * - * @return AdapterInterface - * * @throws \LogicException When the Cache Component isn't available */ - public static function createCache(string $namespace, int $defaultLifetime, string $version, LoggerInterface $logger = null) + public static function createCache(string $namespace, int $defaultLifetime, string $version, LoggerInterface $logger = null): AdapterInterface { if (!class_exists(ApcuAdapter::class)) { throw new \LogicException(sprintf('The Symfony Cache component must be installed to use "%s()".', __METHOD__)); diff --git a/src/Symfony/Component/PropertyAccess/PropertyAccessorBuilder.php b/src/Symfony/Component/PropertyAccess/PropertyAccessorBuilder.php index 0e2acb24f950b..413f2c6339a6a 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyAccessorBuilder.php +++ b/src/Symfony/Component/PropertyAccess/PropertyAccessorBuilder.php @@ -67,7 +67,7 @@ public function disableMagicMethods(): self * * @return $this */ - public function enableMagicCall() + public function enableMagicCall(): static { $this->magicMethods |= PropertyAccessor::MAGIC_CALL; @@ -99,7 +99,7 @@ public function enableMagicSet(): self * * @return $this */ - public function disableMagicCall() + public function disableMagicCall(): static { $this->magicMethods &= ~PropertyAccessor::MAGIC_CALL; @@ -129,7 +129,7 @@ public function disableMagicSet(): self /** * @return bool whether the use of "__call" by the PropertyAccessor is enabled */ - public function isMagicCallEnabled() + public function isMagicCallEnabled(): bool { return (bool) ($this->magicMethods & PropertyAccessor::MAGIC_CALL); } @@ -158,7 +158,7 @@ public function isMagicSetEnabled(): bool * * @return $this */ - public function enableExceptionOnInvalidIndex() + public function enableExceptionOnInvalidIndex(): static { $this->throwExceptionOnInvalidIndex = true; @@ -172,7 +172,7 @@ public function enableExceptionOnInvalidIndex() * * @return $this */ - public function disableExceptionOnInvalidIndex() + public function disableExceptionOnInvalidIndex(): static { $this->throwExceptionOnInvalidIndex = false; @@ -182,7 +182,7 @@ public function disableExceptionOnInvalidIndex() /** * @return bool whether an exception is thrown or null is returned when reading a non-existing index */ - public function isExceptionOnInvalidIndexEnabled() + public function isExceptionOnInvalidIndexEnabled(): bool { return $this->throwExceptionOnInvalidIndex; } @@ -195,7 +195,7 @@ public function isExceptionOnInvalidIndexEnabled() * * @return $this */ - public function enableExceptionOnInvalidPropertyPath() + public function enableExceptionOnInvalidPropertyPath(): static { $this->throwExceptionOnInvalidPropertyPath = true; @@ -209,7 +209,7 @@ public function enableExceptionOnInvalidPropertyPath() * * @return $this */ - public function disableExceptionOnInvalidPropertyPath() + public function disableExceptionOnInvalidPropertyPath(): static { $this->throwExceptionOnInvalidPropertyPath = false; @@ -219,7 +219,7 @@ public function disableExceptionOnInvalidPropertyPath() /** * @return bool whether an exception is thrown or null is returned when reading a non-existing property */ - public function isExceptionOnInvalidPropertyPath() + public function isExceptionOnInvalidPropertyPath(): bool { return $this->throwExceptionOnInvalidPropertyPath; } @@ -229,7 +229,7 @@ public function isExceptionOnInvalidPropertyPath() * * @return PropertyAccessorBuilder The builder object */ - public function setCacheItemPool(CacheItemPoolInterface $cacheItemPool = null) + public function setCacheItemPool(CacheItemPoolInterface $cacheItemPool = null): self { $this->cacheItemPool = $cacheItemPool; @@ -238,10 +238,8 @@ public function setCacheItemPool(CacheItemPoolInterface $cacheItemPool = null) /** * Gets the used cache system. - * - * @return CacheItemPoolInterface|null */ - public function getCacheItemPool() + public function getCacheItemPool(): ?CacheItemPoolInterface { return $this->cacheItemPool; } @@ -249,7 +247,7 @@ public function getCacheItemPool() /** * @return $this */ - public function setReadInfoExtractor(?PropertyReadInfoExtractorInterface $readInfoExtractor) + public function setReadInfoExtractor(?PropertyReadInfoExtractorInterface $readInfoExtractor): static { $this->readInfoExtractor = $readInfoExtractor; @@ -264,7 +262,7 @@ public function getReadInfoExtractor(): ?PropertyReadInfoExtractorInterface /** * @return $this */ - public function setWriteInfoExtractor(?PropertyWriteInfoExtractorInterface $writeInfoExtractor) + public function setWriteInfoExtractor(?PropertyWriteInfoExtractorInterface $writeInfoExtractor): static { $this->writeInfoExtractor = $writeInfoExtractor; @@ -281,7 +279,7 @@ public function getWriteInfoExtractor(): ?PropertyWriteInfoExtractorInterface * * @return PropertyAccessorInterface The built PropertyAccessor */ - public function getPropertyAccessor() + public function getPropertyAccessor(): PropertyAccessorInterface { $throw = PropertyAccessor::DO_NOT_THROW; diff --git a/src/Symfony/Component/PropertyAccess/PropertyAccessorInterface.php b/src/Symfony/Component/PropertyAccess/PropertyAccessorInterface.php index aeba6a4a55748..8bc234861993a 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyAccessorInterface.php +++ b/src/Symfony/Component/PropertyAccess/PropertyAccessorInterface.php @@ -73,7 +73,7 @@ public function setValue(object|array &$objectOrArray, string|PropertyPathInterf * @throws Exception\UnexpectedTypeException If a value within the path is neither object * nor array */ - public function getValue(object|array $objectOrArray, string|PropertyPathInterface $propertyPath); + public function getValue(object|array $objectOrArray, string|PropertyPathInterface $propertyPath): mixed; /** * Returns whether a value can be written at a given property path. @@ -85,7 +85,7 @@ public function getValue(object|array $objectOrArray, string|PropertyPathInterfa * * @throws Exception\InvalidArgumentException If the property path is invalid */ - public function isWritable(object|array $objectOrArray, string|PropertyPathInterface $propertyPath); + public function isWritable(object|array $objectOrArray, string|PropertyPathInterface $propertyPath): bool; /** * Returns whether a property path can be read from an object graph. @@ -97,5 +97,5 @@ public function isWritable(object|array $objectOrArray, string|PropertyPathInter * * @throws Exception\InvalidArgumentException If the property path is invalid */ - public function isReadable(object|array $objectOrArray, string|PropertyPathInterface $propertyPath); + public function isReadable(object|array $objectOrArray, string|PropertyPathInterface $propertyPath): bool; } diff --git a/src/Symfony/Component/PropertyAccess/PropertyPath.php b/src/Symfony/Component/PropertyAccess/PropertyPath.php index 7feaaa4d573c0..d27a88503e424 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyPath.php +++ b/src/Symfony/Component/PropertyAccess/PropertyPath.php @@ -117,7 +117,7 @@ public function __toString(): string /** * {@inheritdoc} */ - public function getLength() + public function getLength(): int { return $this->length; } @@ -125,7 +125,7 @@ public function getLength() /** * {@inheritdoc} */ - public function getParent() + public function getParent(): ?PropertyPathInterface { if ($this->length <= 1) { return null; @@ -152,7 +152,7 @@ public function getIterator(): PropertyPathIteratorInterface /** * {@inheritdoc} */ - public function getElements() + public function getElements(): array { return $this->elements; } @@ -160,7 +160,7 @@ public function getElements() /** * {@inheritdoc} */ - public function getElement(int $index) + public function getElement(int $index): string { if (!isset($this->elements[$index])) { throw new OutOfBoundsException(sprintf('The index "%s" is not within the property path.', $index)); @@ -172,7 +172,7 @@ public function getElement(int $index) /** * {@inheritdoc} */ - public function isProperty(int $index) + public function isProperty(int $index): bool { if (!isset($this->isIndex[$index])) { throw new OutOfBoundsException(sprintf('The index "%s" is not within the property path.', $index)); @@ -184,7 +184,7 @@ public function isProperty(int $index) /** * {@inheritdoc} */ - public function isIndex(int $index) + public function isIndex(int $index): bool { if (!isset($this->isIndex[$index])) { throw new OutOfBoundsException(sprintf('The index "%s" is not within the property path.', $index)); diff --git a/src/Symfony/Component/PropertyAccess/PropertyPathBuilder.php b/src/Symfony/Component/PropertyAccess/PropertyPathBuilder.php index 3749b00739c2e..6675b92559935 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyPathBuilder.php +++ b/src/Symfony/Component/PropertyAccess/PropertyPathBuilder.php @@ -158,7 +158,7 @@ public function replaceByProperty(int $offset, string $name = null) * * @return int The path length */ - public function getLength() + public function getLength(): int { return \count($this->elements); } @@ -168,7 +168,7 @@ public function getLength() * * @return PropertyPathInterface|null The constructed property path */ - public function getPropertyPath() + public function getPropertyPath(): ?PropertyPathInterface { $pathAsString = $this->__toString(); diff --git a/src/Symfony/Component/PropertyAccess/PropertyPathIterator.php b/src/Symfony/Component/PropertyAccess/PropertyPathIterator.php index 3445db2cb0dc4..6b27c86b81c57 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyPathIterator.php +++ b/src/Symfony/Component/PropertyAccess/PropertyPathIterator.php @@ -31,7 +31,7 @@ public function __construct(PropertyPathInterface $path) /** * {@inheritdoc} */ - public function isIndex() + public function isIndex(): bool { return $this->path->isIndex($this->key()); } @@ -39,7 +39,7 @@ public function isIndex() /** * {@inheritdoc} */ - public function isProperty() + public function isProperty(): bool { return $this->path->isProperty($this->key()); } diff --git a/src/Symfony/Component/PropertyAccess/PropertyPathIteratorInterface.php b/src/Symfony/Component/PropertyAccess/PropertyPathIteratorInterface.php index 79b1bbfe828e4..8295e67fcbf15 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyPathIteratorInterface.php +++ b/src/Symfony/Component/PropertyAccess/PropertyPathIteratorInterface.php @@ -19,16 +19,12 @@ interface PropertyPathIteratorInterface extends \Iterator, \SeekableIterator /** * Returns whether the current element in the property path is an array * index. - * - * @return bool */ - public function isIndex(); + public function isIndex(): bool; /** * Returns whether the current element in the property path is a property * name. - * - * @return bool */ - public function isProperty(); + public function isProperty(): bool; } diff --git a/src/Symfony/Component/PropertyInfo/PropertyDescriptionExtractorInterface.php b/src/Symfony/Component/PropertyInfo/PropertyDescriptionExtractorInterface.php index f376537537062..a779d159cd757 100644 --- a/src/Symfony/Component/PropertyInfo/PropertyDescriptionExtractorInterface.php +++ b/src/Symfony/Component/PropertyInfo/PropertyDescriptionExtractorInterface.php @@ -20,15 +20,11 @@ interface PropertyDescriptionExtractorInterface { /** * Gets the short description of the property. - * - * @return string|null */ - public function getShortDescription(string $class, string $property, array $context = []); + public function getShortDescription(string $class, string $property, array $context = []): ?string; /** * Gets the long description of the property. - * - * @return string|null */ - public function getLongDescription(string $class, string $property, array $context = []); + public function getLongDescription(string $class, string $property, array $context = []): ?string; } diff --git a/src/Symfony/Component/Routing/CompiledRoute.php b/src/Symfony/Component/Routing/CompiledRoute.php index d0d11b31b4b14..6ed65fbee4b1f 100644 --- a/src/Symfony/Component/Routing/CompiledRoute.php +++ b/src/Symfony/Component/Routing/CompiledRoute.php @@ -96,7 +96,7 @@ final public function unserialize(string $serialized) * * @return string The static prefix */ - public function getStaticPrefix() + public function getStaticPrefix(): string { return $this->staticPrefix; } @@ -106,7 +106,7 @@ public function getStaticPrefix() * * @return string The regex */ - public function getRegex() + public function getRegex(): string { return $this->regex; } @@ -116,7 +116,7 @@ public function getRegex() * * @return string|null The host regex or null */ - public function getHostRegex() + public function getHostRegex(): ?string { return $this->hostRegex; } @@ -126,7 +126,7 @@ public function getHostRegex() * * @return array The tokens */ - public function getTokens() + public function getTokens(): array { return $this->tokens; } @@ -136,7 +136,7 @@ public function getTokens() * * @return array The tokens */ - public function getHostTokens() + public function getHostTokens(): array { return $this->hostTokens; } @@ -146,7 +146,7 @@ public function getHostTokens() * * @return array The variables */ - public function getVariables() + public function getVariables(): array { return $this->variables; } @@ -156,7 +156,7 @@ public function getVariables() * * @return array The variables */ - public function getPathVariables() + public function getPathVariables(): array { return $this->pathVariables; } @@ -166,7 +166,7 @@ public function getPathVariables() * * @return array The variables */ - public function getHostVariables() + public function getHostVariables(): array { return $this->hostVariables; } diff --git a/src/Symfony/Component/Routing/Exception/MethodNotAllowedException.php b/src/Symfony/Component/Routing/Exception/MethodNotAllowedException.php index 2810ac76b3584..0e4381bb6d997 100644 --- a/src/Symfony/Component/Routing/Exception/MethodNotAllowedException.php +++ b/src/Symfony/Component/Routing/Exception/MethodNotAllowedException.php @@ -37,7 +37,7 @@ public function __construct(array $allowedMethods, string $message = '', int $co * * @return string[] */ - public function getAllowedMethods() + public function getAllowedMethods(): array { return $this->allowedMethods; } diff --git a/src/Symfony/Component/Routing/Generator/CompiledUrlGenerator.php b/src/Symfony/Component/Routing/Generator/CompiledUrlGenerator.php index 90ce5b2906880..fdd80ecf16e14 100644 --- a/src/Symfony/Component/Routing/Generator/CompiledUrlGenerator.php +++ b/src/Symfony/Component/Routing/Generator/CompiledUrlGenerator.php @@ -31,7 +31,7 @@ public function __construct(array $compiledRoutes, RequestContext $context, Logg $this->defaultLocale = $defaultLocale; } - public function generate(string $name, array $parameters = [], int $referenceType = self::ABSOLUTE_PATH) + public function generate(string $name, array $parameters = [], int $referenceType = self::ABSOLUTE_PATH): string { $locale = $parameters['_locale'] ?? $this->context->getParameter('_locale') diff --git a/src/Symfony/Component/Routing/Generator/ConfigurableRequirementsInterface.php b/src/Symfony/Component/Routing/Generator/ConfigurableRequirementsInterface.php index 568f7f775300a..2c99c913a3022 100644 --- a/src/Symfony/Component/Routing/Generator/ConfigurableRequirementsInterface.php +++ b/src/Symfony/Component/Routing/Generator/ConfigurableRequirementsInterface.php @@ -46,8 +46,6 @@ public function setStrictRequirements(?bool $enabled); /** * Returns whether to throw an exception on incorrect parameters. * Null means the requirements check is deactivated completely. - * - * @return bool|null */ - public function isStrictRequirements(); + public function isStrictRequirements(): ?bool; } diff --git a/src/Symfony/Component/Routing/Generator/Dumper/CompiledUrlGeneratorDumper.php b/src/Symfony/Component/Routing/Generator/Dumper/CompiledUrlGeneratorDumper.php index e90a40a26f0fc..025972e6e54c6 100644 --- a/src/Symfony/Component/Routing/Generator/Dumper/CompiledUrlGeneratorDumper.php +++ b/src/Symfony/Component/Routing/Generator/Dumper/CompiledUrlGeneratorDumper.php @@ -44,7 +44,7 @@ public function getCompiledRoutes(): array /** * {@inheritdoc} */ - public function dump(array $options = []) + public function dump(array $options = []): string { return <<routes; } diff --git a/src/Symfony/Component/Routing/Generator/Dumper/GeneratorDumperInterface.php b/src/Symfony/Component/Routing/Generator/Dumper/GeneratorDumperInterface.php index 1fb96a23ec727..750f96e2620e1 100644 --- a/src/Symfony/Component/Routing/Generator/Dumper/GeneratorDumperInterface.php +++ b/src/Symfony/Component/Routing/Generator/Dumper/GeneratorDumperInterface.php @@ -26,12 +26,10 @@ interface GeneratorDumperInterface * * @return string Executable code */ - public function dump(array $options = []); + public function dump(array $options = []): string; /** * Gets the routes to dump. - * - * @return RouteCollection */ - public function getRoutes(); + public function getRoutes(): RouteCollection; } diff --git a/src/Symfony/Component/Routing/Generator/UrlGenerator.php b/src/Symfony/Component/Routing/Generator/UrlGenerator.php index 8fd2550a49e9e..eab3c1e210daa 100644 --- a/src/Symfony/Component/Routing/Generator/UrlGenerator.php +++ b/src/Symfony/Component/Routing/Generator/UrlGenerator.php @@ -101,7 +101,7 @@ public function setContext(RequestContext $context) /** * {@inheritdoc} */ - public function getContext() + public function getContext(): RequestContext { return $this->context; } @@ -117,7 +117,7 @@ public function setStrictRequirements(?bool $enabled) /** * {@inheritdoc} */ - public function isStrictRequirements() + public function isStrictRequirements(): ?bool { return $this->strictRequirements; } @@ -125,7 +125,7 @@ public function isStrictRequirements() /** * {@inheritdoc} */ - public function generate(string $name, array $parameters = [], int $referenceType = self::ABSOLUTE_PATH) + public function generate(string $name, array $parameters = [], int $referenceType = self::ABSOLUTE_PATH): string { $route = null; $locale = $parameters['_locale'] @@ -165,10 +165,8 @@ public function generate(string $name, array $parameters = [], int $referenceTyp * @throws MissingMandatoryParametersException When some parameters are missing that are mandatory for the route * @throws InvalidParameterException When a parameter value for a placeholder is not correct because * it does not match the requirement - * - * @return string */ - protected function doGenerate(array $variables, array $defaults, array $requirements, array $tokens, array $parameters, string $name, int $referenceType, array $hostTokens, array $requiredSchemes = []) + protected function doGenerate(array $variables, array $defaults, array $requirements, array $tokens, array $parameters, string $name, int $referenceType, array $hostTokens, array $requiredSchemes = []): string { $variables = array_flip($variables); $mergedParams = array_replace($defaults, $this->context->getParameters(), $parameters); @@ -334,7 +332,7 @@ protected function doGenerate(array $variables, array $defaults, array $requirem * * @return string The relative target path */ - public static function getRelativePath(string $basePath, string $targetPath) + public static function getRelativePath(string $basePath, string $targetPath): string { if ($basePath === $targetPath) { return ''; diff --git a/src/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php b/src/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php index c641e81511241..2409e1270e7cb 100644 --- a/src/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php +++ b/src/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php @@ -78,5 +78,5 @@ interface UrlGeneratorInterface extends RequestContextAwareInterface * @throws InvalidParameterException When a parameter value for a placeholder is not correct because * it does not match the requirement */ - public function generate(string $name, array $parameters = [], int $referenceType = self::ABSOLUTE_PATH); + public function generate(string $name, array $parameters = [], int $referenceType = self::ABSOLUTE_PATH): string; } diff --git a/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php b/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php index 932c31890d438..efa597e5dc3ab 100644 --- a/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php +++ b/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php @@ -106,7 +106,7 @@ public function setRouteAnnotationClass(string $class) * * @throws \InvalidArgumentException When route can't be parsed */ - public function load(mixed $class, string $type = null) + public function load(mixed $class, string $type = null): RouteCollection { if (!class_exists($class)) { throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class)); @@ -237,7 +237,7 @@ protected function addRoute(RouteCollection $collection, object $annot, array $g /** * {@inheritdoc} */ - public function supports(mixed $resource, string $type = null) + public function supports(mixed $resource, string $type = null): bool { return \is_string($resource) && preg_match('/^(?:\\\\?[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)+$/', $resource) && (!$type || 'annotation' === $type); } @@ -252,7 +252,7 @@ public function setResolver(LoaderResolverInterface $resolver) /** * {@inheritdoc} */ - public function getResolver() + public function getResolver(): LoaderResolverInterface { } diff --git a/src/Symfony/Component/Routing/Loader/AnnotationDirectoryLoader.php b/src/Symfony/Component/Routing/Loader/AnnotationDirectoryLoader.php index fab194634b91d..6468c3989d7fa 100644 --- a/src/Symfony/Component/Routing/Loader/AnnotationDirectoryLoader.php +++ b/src/Symfony/Component/Routing/Loader/AnnotationDirectoryLoader.php @@ -27,7 +27,7 @@ class AnnotationDirectoryLoader extends AnnotationFileLoader * * @throws \InvalidArgumentException When the directory does not exist or its routes cannot be parsed */ - public function load(mixed $path, string $type = null) + public function load(mixed $path, string $type = null): RouteCollection { if (!is_dir($dir = $this->locator->locate($path))) { return parent::supports($path, $type) ? parent::load($path, $type) : new RouteCollection(); @@ -69,7 +69,7 @@ function (\SplFileInfo $current) { /** * {@inheritdoc} */ - public function supports(mixed $resource, string $type = null) + public function supports(mixed $resource, string $type = null): bool { if ('annotation' === $type) { return true; diff --git a/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php b/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php index f0af0630b79f1..8dfacc123b96f 100644 --- a/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php @@ -44,7 +44,7 @@ public function __construct(FileLocatorInterface $locator, AnnotationClassLoader * * @throws \InvalidArgumentException When the file does not exist or its routes cannot be parsed */ - public function load(mixed $file, string $type = null) + public function load(mixed $file, string $type = null): ?RouteCollection { $path = $this->locator->locate($file); @@ -67,7 +67,7 @@ public function load(mixed $file, string $type = null) /** * {@inheritdoc} */ - public function supports(mixed $resource, string $type = null) + public function supports(mixed $resource, string $type = null): bool { return \is_string($resource) && 'php' === pathinfo($resource, \PATHINFO_EXTENSION) && (!$type || 'annotation' === $type); } @@ -77,7 +77,7 @@ public function supports(mixed $resource, string $type = null) * * @return string|false Full class name if found, false otherwise */ - protected function findClass(string $file) + protected function findClass(string $file): string|false { $class = false; $namespace = false; diff --git a/src/Symfony/Component/Routing/Loader/ClosureLoader.php b/src/Symfony/Component/Routing/Loader/ClosureLoader.php index ce0a691f57cce..6923fbbec78a9 100644 --- a/src/Symfony/Component/Routing/Loader/ClosureLoader.php +++ b/src/Symfony/Component/Routing/Loader/ClosureLoader.php @@ -28,7 +28,7 @@ class ClosureLoader extends Loader * * @return RouteCollection */ - public function load(mixed $closure, string $type = null) + public function load(mixed $closure, string $type = null): RouteCollection { return $closure($this->env); } @@ -36,7 +36,7 @@ public function load(mixed $closure, string $type = null) /** * {@inheritdoc} */ - public function supports(mixed $resource, string $type = null) + public function supports(mixed $resource, string $type = null): bool { return $resource instanceof \Closure && (!$type || 'closure' === $type); } diff --git a/src/Symfony/Component/Routing/Loader/Configurator/CollectionConfigurator.php b/src/Symfony/Component/Routing/Loader/Configurator/CollectionConfigurator.php index 713e4337a0426..bd433cd8f66f6 100644 --- a/src/Symfony/Component/Routing/Loader/Configurator/CollectionConfigurator.php +++ b/src/Symfony/Component/Routing/Loader/Configurator/CollectionConfigurator.php @@ -41,7 +41,7 @@ public function __construct(RouteCollection $parent, string $name, self $parentC /** * @return array */ - public function __sleep() + public function __sleep(): array { throw new \BadMethodCallException('Cannot serialize '.__CLASS__); } diff --git a/src/Symfony/Component/Routing/Loader/Configurator/ImportConfigurator.php b/src/Symfony/Component/Routing/Loader/Configurator/ImportConfigurator.php index 664a0d4fadf7f..c846cfc578d89 100644 --- a/src/Symfony/Component/Routing/Loader/Configurator/ImportConfigurator.php +++ b/src/Symfony/Component/Routing/Loader/Configurator/ImportConfigurator.php @@ -33,7 +33,7 @@ public function __construct(RouteCollection $parent, RouteCollection $route) /** * @return array */ - public function __sleep() + public function __sleep(): array { throw new \BadMethodCallException('Cannot serialize '.__CLASS__); } diff --git a/src/Symfony/Component/Routing/Loader/ContainerLoader.php b/src/Symfony/Component/Routing/Loader/ContainerLoader.php index 2f2511f4e75f8..2476ec1e2f878 100644 --- a/src/Symfony/Component/Routing/Loader/ContainerLoader.php +++ b/src/Symfony/Component/Routing/Loader/ContainerLoader.php @@ -31,7 +31,7 @@ public function __construct(ContainerInterface $container, string $env = null) /** * {@inheritdoc} */ - public function supports(mixed $resource, string $type = null) + public function supports(mixed $resource, string $type = null): bool { return 'service' === $type && \is_string($resource); } @@ -39,7 +39,7 @@ public function supports(mixed $resource, string $type = null) /** * {@inheritdoc} */ - protected function getObject(string $id) + protected function getObject(string $id): object { return $this->container->get($id); } diff --git a/src/Symfony/Component/Routing/Loader/DirectoryLoader.php b/src/Symfony/Component/Routing/Loader/DirectoryLoader.php index 78a0d1a78a3aa..4ccbb7b8891aa 100644 --- a/src/Symfony/Component/Routing/Loader/DirectoryLoader.php +++ b/src/Symfony/Component/Routing/Loader/DirectoryLoader.php @@ -20,7 +20,7 @@ class DirectoryLoader extends FileLoader /** * {@inheritdoc} */ - public function load(mixed $file, string $type = null) + public function load(mixed $file, string $type = null): mixed { $path = $this->locator->locate($file); @@ -49,7 +49,7 @@ public function load(mixed $file, string $type = null) /** * {@inheritdoc} */ - public function supports(mixed $resource, string $type = null) + public function supports(mixed $resource, string $type = null): bool { // only when type is forced to directory, not to conflict with AnnotationLoader diff --git a/src/Symfony/Component/Routing/Loader/GlobFileLoader.php b/src/Symfony/Component/Routing/Loader/GlobFileLoader.php index 8bc36030be947..3cf49ccff7e1e 100644 --- a/src/Symfony/Component/Routing/Loader/GlobFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/GlobFileLoader.php @@ -24,7 +24,7 @@ class GlobFileLoader extends FileLoader /** * {@inheritdoc} */ - public function load(mixed $resource, string $type = null) + public function load(mixed $resource, string $type = null): mixed { $collection = new RouteCollection(); @@ -40,7 +40,7 @@ public function load(mixed $resource, string $type = null) /** * {@inheritdoc} */ - public function supports(mixed $resource, string $type = null) + public function supports(mixed $resource, string $type = null): bool { return 'glob' === $type; } diff --git a/src/Symfony/Component/Routing/Loader/ObjectLoader.php b/src/Symfony/Component/Routing/Loader/ObjectLoader.php index 3ac3e5f076ef8..3166922888302 100644 --- a/src/Symfony/Component/Routing/Loader/ObjectLoader.php +++ b/src/Symfony/Component/Routing/Loader/ObjectLoader.php @@ -30,14 +30,14 @@ abstract class ObjectLoader extends Loader * * @return object */ - abstract protected function getObject(string $id); + abstract protected function getObject(string $id): object; /** * Calls the object method that will load the routes. * * @return RouteCollection */ - public function load(mixed $resource, string $type = null) + public function load(mixed $resource, string $type = null): RouteCollection { if (!preg_match('/^[^\:]+(?:::(?:[^\:]+))?$/', $resource)) { throw new \InvalidArgumentException(sprintf('Invalid resource "%s" passed to the %s route loader: use the format "object_id::method" or "object_id" if your object class has an "__invoke" method.', $resource, \is_string($type) ? '"'.$type.'"' : 'object')); diff --git a/src/Symfony/Component/Routing/Loader/PhpFileLoader.php b/src/Symfony/Component/Routing/Loader/PhpFileLoader.php index 5fada100afebe..cc7ff84cda391 100644 --- a/src/Symfony/Component/Routing/Loader/PhpFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/PhpFileLoader.php @@ -32,7 +32,7 @@ class PhpFileLoader extends FileLoader * * @return RouteCollection */ - public function load(mixed $file, string $type = null) + public function load(mixed $file, string $type = null): RouteCollection { $path = $this->locator->locate($file); $this->setCurrentDir(\dirname($path)); @@ -59,7 +59,7 @@ public function load(mixed $file, string $type = null) /** * {@inheritdoc} */ - public function supports(mixed $resource, string $type = null) + public function supports(mixed $resource, string $type = null): bool { return \is_string($resource) && 'php' === pathinfo($resource, \PATHINFO_EXTENSION) && (!$type || 'php' === $type); } diff --git a/src/Symfony/Component/Routing/Loader/XmlFileLoader.php b/src/Symfony/Component/Routing/Loader/XmlFileLoader.php index b1b028c40103e..4d5f9bb28df48 100644 --- a/src/Symfony/Component/Routing/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/XmlFileLoader.php @@ -40,7 +40,7 @@ class XmlFileLoader extends FileLoader * @throws \InvalidArgumentException when the file cannot be loaded or when the XML cannot be * parsed because it does not validate against the scheme */ - public function load(mixed $file, string $type = null) + public function load(mixed $file, string $type = null): RouteCollection { $path = $this->locator->locate($file); @@ -97,7 +97,7 @@ protected function parseNode(RouteCollection $collection, \DOMElement $node, str /** * {@inheritdoc} */ - public function supports(mixed $resource, string $type = null) + public function supports(mixed $resource, string $type = null): bool { return \is_string($resource) && 'xml' === pathinfo($resource, \PATHINFO_EXTENSION) && (!$type || 'xml' === $type); } @@ -220,7 +220,7 @@ protected function parseImport(RouteCollection $collection, \DOMElement $node, s * or when the XML structure is not as expected by the scheme - * see validate() */ - protected function loadFile(string $file) + protected function loadFile(string $file): \DOMDocument { return XmlUtils::loadFile($file, __DIR__.static::SCHEME_PATH); } diff --git a/src/Symfony/Component/Routing/Loader/YamlFileLoader.php b/src/Symfony/Component/Routing/Loader/YamlFileLoader.php index 3f65c0714ed31..d418077702abb 100644 --- a/src/Symfony/Component/Routing/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/YamlFileLoader.php @@ -43,7 +43,7 @@ class YamlFileLoader extends FileLoader * * @throws \InvalidArgumentException When a route can't be parsed because YAML is invalid */ - public function load(mixed $file, string $type = null) + public function load(mixed $file, string $type = null): RouteCollection { $path = $this->locator->locate($file); @@ -112,7 +112,7 @@ public function load(mixed $file, string $type = null) /** * {@inheritdoc} */ - public function supports(mixed $resource, string $type = null) + public function supports(mixed $resource, string $type = null): bool { return \is_string($resource) && \in_array(pathinfo($resource, \PATHINFO_EXTENSION), ['yml', 'yaml'], true) && (!$type || 'yaml' === $type); } diff --git a/src/Symfony/Component/Routing/Matcher/Dumper/CompiledUrlMatcherDumper.php b/src/Symfony/Component/Routing/Matcher/Dumper/CompiledUrlMatcherDumper.php index a3535cdda4a4d..28fe2e8353e7d 100644 --- a/src/Symfony/Component/Routing/Matcher/Dumper/CompiledUrlMatcherDumper.php +++ b/src/Symfony/Component/Routing/Matcher/Dumper/CompiledUrlMatcherDumper.php @@ -37,7 +37,7 @@ class CompiledUrlMatcherDumper extends MatcherDumper /** * {@inheritdoc} */ - public function dump(array $options = []) + public function dump(array $options = []): string { return <<routes; } diff --git a/src/Symfony/Component/Routing/Matcher/Dumper/MatcherDumperInterface.php b/src/Symfony/Component/Routing/Matcher/Dumper/MatcherDumperInterface.php index 1e22e1cdab18d..c8438c5ab4a7e 100644 --- a/src/Symfony/Component/Routing/Matcher/Dumper/MatcherDumperInterface.php +++ b/src/Symfony/Component/Routing/Matcher/Dumper/MatcherDumperInterface.php @@ -26,12 +26,12 @@ interface MatcherDumperInterface * * @return string Executable code */ - public function dump(array $options = []); + public function dump(array $options = []): string; /** * Gets the routes to dump. * * @return RouteCollection */ - public function getRoutes(); + public function getRoutes(): RouteCollection; } diff --git a/src/Symfony/Component/Routing/Matcher/ExpressionLanguageProvider.php b/src/Symfony/Component/Routing/Matcher/ExpressionLanguageProvider.php index 96bb7babf2076..c9703d236fd27 100644 --- a/src/Symfony/Component/Routing/Matcher/ExpressionLanguageProvider.php +++ b/src/Symfony/Component/Routing/Matcher/ExpressionLanguageProvider.php @@ -32,7 +32,7 @@ public function __construct(ServiceProviderInterface $functions) /** * {@inheritdoc} */ - public function getFunctions() + public function getFunctions(): array { $functions = []; diff --git a/src/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php b/src/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php index 3cd7c81a6cb1d..439c69eeb3a86 100644 --- a/src/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php +++ b/src/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php @@ -22,7 +22,7 @@ abstract class RedirectableUrlMatcher extends UrlMatcher implements Redirectable /** * {@inheritdoc} */ - public function match(string $pathinfo) + public function match(string $pathinfo): array { try { return parent::match($pathinfo); diff --git a/src/Symfony/Component/Routing/Matcher/RedirectableUrlMatcherInterface.php b/src/Symfony/Component/Routing/Matcher/RedirectableUrlMatcherInterface.php index 144945d96796c..7bbcc6973fb02 100644 --- a/src/Symfony/Component/Routing/Matcher/RedirectableUrlMatcherInterface.php +++ b/src/Symfony/Component/Routing/Matcher/RedirectableUrlMatcherInterface.php @@ -27,5 +27,5 @@ interface RedirectableUrlMatcherInterface * * @return array An array of parameters */ - public function redirect(string $path, string $route, string $scheme = null); + public function redirect(string $path, string $route, string $scheme = null): array; } diff --git a/src/Symfony/Component/Routing/Matcher/RequestMatcherInterface.php b/src/Symfony/Component/Routing/Matcher/RequestMatcherInterface.php index 0c193ff2d1f06..c08dbb69b45c4 100644 --- a/src/Symfony/Component/Routing/Matcher/RequestMatcherInterface.php +++ b/src/Symfony/Component/Routing/Matcher/RequestMatcherInterface.php @@ -35,5 +35,5 @@ interface RequestMatcherInterface * @throws ResourceNotFoundException If no matching resource could be found * @throws MethodNotAllowedException If a matching resource was found but the request method is not allowed */ - public function matchRequest(Request $request); + public function matchRequest(Request $request): array; } diff --git a/src/Symfony/Component/Routing/Matcher/TraceableUrlMatcher.php b/src/Symfony/Component/Routing/Matcher/TraceableUrlMatcher.php index 9e8c4c42df044..af6678c3f0680 100644 --- a/src/Symfony/Component/Routing/Matcher/TraceableUrlMatcher.php +++ b/src/Symfony/Component/Routing/Matcher/TraceableUrlMatcher.php @@ -50,7 +50,7 @@ public function getTracesForRequest(Request $request) return $traces; } - protected function matchCollection(string $pathinfo, RouteCollection $routes) + protected function matchCollection(string $pathinfo, RouteCollection $routes): array { // HEAD and GET are equivalent as per RFC if ('HEAD' === $method = $this->context->getMethod()) { diff --git a/src/Symfony/Component/Routing/Matcher/UrlMatcher.php b/src/Symfony/Component/Routing/Matcher/UrlMatcher.php index ef9c34a506b3a..7e7c016c51bef 100644 --- a/src/Symfony/Component/Routing/Matcher/UrlMatcher.php +++ b/src/Symfony/Component/Routing/Matcher/UrlMatcher.php @@ -73,7 +73,7 @@ public function setContext(RequestContext $context) /** * {@inheritdoc} */ - public function getContext() + public function getContext(): RequestContext { return $this->context; } @@ -81,7 +81,7 @@ public function getContext() /** * {@inheritdoc} */ - public function match(string $pathinfo) + public function match(string $pathinfo): array { $this->allow = $this->allowSchemes = []; @@ -99,7 +99,7 @@ public function match(string $pathinfo) /** * {@inheritdoc} */ - public function matchRequest(Request $request) + public function matchRequest(Request $request): array { $this->request = $request; @@ -126,7 +126,7 @@ public function addExpressionLanguageProvider(ExpressionFunctionProviderInterfac * @throws ResourceNotFoundException If the resource could not be found * @throws MethodNotAllowedException If the resource was found but the request method is not allowed */ - protected function matchCollection(string $pathinfo, RouteCollection $routes) + protected function matchCollection(string $pathinfo, RouteCollection $routes): array { // HEAD and GET are equivalent as per RFC if ('HEAD' === $method = $this->context->getMethod()) { @@ -207,7 +207,7 @@ protected function matchCollection(string $pathinfo, RouteCollection $routes) * * @return array An array of parameters */ - protected function getAttributes(Route $route, string $name, array $attributes) + protected function getAttributes(Route $route, string $name, array $attributes): array { $defaults = $route->getDefaults(); if (isset($defaults['_canonical_route'])) { @@ -224,7 +224,7 @@ protected function getAttributes(Route $route, string $name, array $attributes) * * @return array The first element represents the status, the second contains additional information */ - protected function handleRouteRequirements(string $pathinfo, string $name, Route $route) + protected function handleRouteRequirements(string $pathinfo, string $name, Route $route): array { // expression condition if ($route->getCondition() && !$this->getExpressionLanguage()->evaluate($route->getCondition(), ['context' => $this->context, 'request' => $this->request ?: $this->createRequest($pathinfo)])) { @@ -239,7 +239,7 @@ protected function handleRouteRequirements(string $pathinfo, string $name, Route * * @return array Merged default parameters */ - protected function mergeDefaults(array $params, array $defaults) + protected function mergeDefaults(array $params, array $defaults): array { foreach ($params as $key => $value) { if (!\is_int($key) && null !== $value) { diff --git a/src/Symfony/Component/Routing/Matcher/UrlMatcherInterface.php b/src/Symfony/Component/Routing/Matcher/UrlMatcherInterface.php index 24f23e381fa50..3a33dc9772e64 100644 --- a/src/Symfony/Component/Routing/Matcher/UrlMatcherInterface.php +++ b/src/Symfony/Component/Routing/Matcher/UrlMatcherInterface.php @@ -37,5 +37,5 @@ interface UrlMatcherInterface extends RequestContextAwareInterface * @throws ResourceNotFoundException If the resource could not be found * @throws MethodNotAllowedException If the resource was found but the request method is not allowed */ - public function match(string $pathinfo); + public function match(string $pathinfo): array; } diff --git a/src/Symfony/Component/Routing/RequestContext.php b/src/Symfony/Component/Routing/RequestContext.php index 60767904c0b89..a4ff4754629de 100644 --- a/src/Symfony/Component/Routing/RequestContext.php +++ b/src/Symfony/Component/Routing/RequestContext.php @@ -67,7 +67,7 @@ public static function fromUri(string $uri, string $host = 'localhost', string $ * * @return $this */ - public function fromRequest(Request $request) + public function fromRequest(Request $request): static { $this->setBaseUrl($request->getBaseUrl()); $this->setPathInfo($request->getPathInfo()); @@ -86,7 +86,7 @@ public function fromRequest(Request $request) * * @return string The base URL */ - public function getBaseUrl() + public function getBaseUrl(): string { return $this->baseUrl; } @@ -96,7 +96,7 @@ public function getBaseUrl() * * @return $this */ - public function setBaseUrl(string $baseUrl) + public function setBaseUrl(string $baseUrl): static { $this->baseUrl = $baseUrl; @@ -108,7 +108,7 @@ public function setBaseUrl(string $baseUrl) * * @return string The path info */ - public function getPathInfo() + public function getPathInfo(): string { return $this->pathInfo; } @@ -118,7 +118,7 @@ public function getPathInfo() * * @return $this */ - public function setPathInfo(string $pathInfo) + public function setPathInfo(string $pathInfo): static { $this->pathInfo = $pathInfo; @@ -132,7 +132,7 @@ public function setPathInfo(string $pathInfo) * * @return string The HTTP method */ - public function getMethod() + public function getMethod(): string { return $this->method; } @@ -142,7 +142,7 @@ public function getMethod() * * @return $this */ - public function setMethod(string $method) + public function setMethod(string $method): static { $this->method = strtoupper($method); @@ -156,7 +156,7 @@ public function setMethod(string $method) * * @return string The HTTP host */ - public function getHost() + public function getHost(): string { return $this->host; } @@ -166,7 +166,7 @@ public function getHost() * * @return $this */ - public function setHost(string $host) + public function setHost(string $host): static { $this->host = strtolower($host); @@ -178,7 +178,7 @@ public function setHost(string $host) * * @return string The HTTP scheme */ - public function getScheme() + public function getScheme(): string { return $this->scheme; } @@ -188,7 +188,7 @@ public function getScheme() * * @return $this */ - public function setScheme(string $scheme) + public function setScheme(string $scheme): static { $this->scheme = strtolower($scheme); @@ -200,7 +200,7 @@ public function setScheme(string $scheme) * * @return int The HTTP port */ - public function getHttpPort() + public function getHttpPort(): int { return $this->httpPort; } @@ -210,7 +210,7 @@ public function getHttpPort() * * @return $this */ - public function setHttpPort(int $httpPort) + public function setHttpPort(int $httpPort): static { $this->httpPort = $httpPort; @@ -222,7 +222,7 @@ public function setHttpPort(int $httpPort) * * @return int The HTTPS port */ - public function getHttpsPort() + public function getHttpsPort(): int { return $this->httpsPort; } @@ -232,7 +232,7 @@ public function getHttpsPort() * * @return $this */ - public function setHttpsPort(int $httpsPort) + public function setHttpsPort(int $httpsPort): static { $this->httpsPort = $httpsPort; @@ -244,7 +244,7 @@ public function setHttpsPort(int $httpsPort) * * @return string The query string without the "?" */ - public function getQueryString() + public function getQueryString(): string { return $this->queryString; } @@ -254,7 +254,7 @@ public function getQueryString() * * @return $this */ - public function setQueryString(?string $queryString) + public function setQueryString(?string $queryString): static { // string cast to be fault-tolerant, accepting null $this->queryString = (string) $queryString; @@ -267,7 +267,7 @@ public function setQueryString(?string $queryString) * * @return array The parameters */ - public function getParameters() + public function getParameters(): array { return $this->parameters; } @@ -279,7 +279,7 @@ public function getParameters() * * @return $this */ - public function setParameters(array $parameters) + public function setParameters(array $parameters): static { $this->parameters = $parameters; @@ -291,7 +291,7 @@ public function setParameters(array $parameters) * * @return mixed The parameter value or null if nonexistent */ - public function getParameter(string $name) + public function getParameter(string $name): mixed { return $this->parameters[$name] ?? null; } @@ -301,7 +301,7 @@ public function getParameter(string $name) * * @return bool True if the parameter value is set, false otherwise */ - public function hasParameter(string $name) + public function hasParameter(string $name): bool { return \array_key_exists($name, $this->parameters); } @@ -311,7 +311,7 @@ public function hasParameter(string $name) * * @return $this */ - public function setParameter(string $name, mixed $parameter) + public function setParameter(string $name, mixed $parameter): static { $this->parameters[$name] = $parameter; diff --git a/src/Symfony/Component/Routing/RequestContextAwareInterface.php b/src/Symfony/Component/Routing/RequestContextAwareInterface.php index df5b9fcd4712e..c401d52e2b979 100644 --- a/src/Symfony/Component/Routing/RequestContextAwareInterface.php +++ b/src/Symfony/Component/Routing/RequestContextAwareInterface.php @@ -23,5 +23,5 @@ public function setContext(RequestContext $context); * * @return RequestContext The context */ - public function getContext(); + public function getContext(): RequestContext; } diff --git a/src/Symfony/Component/Routing/Route.php b/src/Symfony/Component/Routing/Route.php index fe79369f39fc4..e5bd01aa1fee5 100644 --- a/src/Symfony/Component/Routing/Route.php +++ b/src/Symfony/Component/Routing/Route.php @@ -114,7 +114,7 @@ final public function unserialize(string $serialized) /** * @return string The path pattern */ - public function getPath() + public function getPath(): string { return $this->path; } @@ -122,7 +122,7 @@ public function getPath() /** * @return $this */ - public function setPath(string $pattern) + public function setPath(string $pattern): static { $pattern = $this->extractInlineDefaultsAndRequirements($pattern); @@ -137,7 +137,7 @@ public function setPath(string $pattern) /** * @return string The host pattern */ - public function getHost() + public function getHost(): string { return $this->host; } @@ -145,7 +145,7 @@ public function getHost() /** * @return $this */ - public function setHost(?string $pattern) + public function setHost(?string $pattern): static { $this->host = $this->extractInlineDefaultsAndRequirements((string) $pattern); $this->compiled = null; @@ -159,7 +159,7 @@ public function setHost(?string $pattern) * * @return string[] The schemes */ - public function getSchemes() + public function getSchemes(): array { return $this->schemes; } @@ -172,7 +172,7 @@ public function getSchemes() * * @return $this */ - public function setSchemes(string|array $schemes) + public function setSchemes(string|array $schemes): static { $this->schemes = array_map('strtolower', (array) $schemes); $this->compiled = null; @@ -185,7 +185,7 @@ public function setSchemes(string|array $schemes) * * @return bool true if the scheme requirement exists, otherwise false */ - public function hasScheme(string $scheme) + public function hasScheme(string $scheme): bool { return \in_array(strtolower($scheme), $this->schemes, true); } @@ -196,7 +196,7 @@ public function hasScheme(string $scheme) * * @return string[] The methods */ - public function getMethods() + public function getMethods(): array { return $this->methods; } @@ -209,7 +209,7 @@ public function getMethods() * * @return $this */ - public function setMethods(string|array $methods) + public function setMethods(string|array $methods): static { $this->methods = array_map('strtoupper', (array) $methods); $this->compiled = null; @@ -220,7 +220,7 @@ public function setMethods(string|array $methods) /** * @return array The options */ - public function getOptions() + public function getOptions(): array { return $this->options; } @@ -228,7 +228,7 @@ public function getOptions() /** * @return $this */ - public function setOptions(array $options) + public function setOptions(array $options): static { $this->options = [ 'compiler_class' => 'Symfony\\Component\\Routing\\RouteCompiler', @@ -240,7 +240,7 @@ public function setOptions(array $options) /** * @return $this */ - public function addOptions(array $options) + public function addOptions(array $options): static { foreach ($options as $name => $option) { $this->options[$name] = $option; @@ -255,7 +255,7 @@ public function addOptions(array $options) * * @return $this */ - public function setOption(string $name, mixed $value) + public function setOption(string $name, mixed $value): static { $this->options[$name] = $value; $this->compiled = null; @@ -266,7 +266,7 @@ public function setOption(string $name, mixed $value) /** * @return mixed The option value or null when not given */ - public function getOption(string $name) + public function getOption(string $name): mixed { return $this->options[$name] ?? null; } @@ -274,7 +274,7 @@ public function getOption(string $name) /** * @return bool true if the option is set, false otherwise */ - public function hasOption(string $name) + public function hasOption(string $name): bool { return \array_key_exists($name, $this->options); } @@ -282,7 +282,7 @@ public function hasOption(string $name) /** * @return array The defaults */ - public function getDefaults() + public function getDefaults(): array { return $this->defaults; } @@ -290,7 +290,7 @@ public function getDefaults() /** * @return $this */ - public function setDefaults(array $defaults) + public function setDefaults(array $defaults): static { $this->defaults = []; @@ -300,7 +300,7 @@ public function setDefaults(array $defaults) /** * @return $this */ - public function addDefaults(array $defaults) + public function addDefaults(array $defaults): static { if (isset($defaults['_locale']) && $this->isLocalized()) { unset($defaults['_locale']); @@ -317,7 +317,7 @@ public function addDefaults(array $defaults) /** * @return mixed The default value or null when not given */ - public function getDefault(string $name) + public function getDefault(string $name): mixed { return $this->defaults[$name] ?? null; } @@ -325,7 +325,7 @@ public function getDefault(string $name) /** * @return bool true if the default value is set, false otherwise */ - public function hasDefault(string $name) + public function hasDefault(string $name): bool { return \array_key_exists($name, $this->defaults); } @@ -333,7 +333,7 @@ public function hasDefault(string $name) /** * @return $this */ - public function setDefault(string $name, mixed $default) + public function setDefault(string $name, mixed $default): static { if ('_locale' === $name && $this->isLocalized()) { return $this; @@ -348,7 +348,7 @@ public function setDefault(string $name, mixed $default) /** * @return array The requirements */ - public function getRequirements() + public function getRequirements(): array { return $this->requirements; } @@ -356,7 +356,7 @@ public function getRequirements() /** * @return $this */ - public function setRequirements(array $requirements) + public function setRequirements(array $requirements): static { $this->requirements = []; @@ -366,7 +366,7 @@ public function setRequirements(array $requirements) /** * @return $this */ - public function addRequirements(array $requirements) + public function addRequirements(array $requirements): static { if (isset($requirements['_locale']) && $this->isLocalized()) { unset($requirements['_locale']); @@ -383,7 +383,7 @@ public function addRequirements(array $requirements) /** * @return string|null The regex or null when not given */ - public function getRequirement(string $key) + public function getRequirement(string $key): ?string { return $this->requirements[$key] ?? null; } @@ -391,7 +391,7 @@ public function getRequirement(string $key) /** * @return bool true if a requirement is specified, false otherwise */ - public function hasRequirement(string $key) + public function hasRequirement(string $key): bool { return \array_key_exists($key, $this->requirements); } @@ -399,7 +399,7 @@ public function hasRequirement(string $key) /** * @return $this */ - public function setRequirement(string $key, string $regex) + public function setRequirement(string $key, string $regex): static { if ('_locale' === $key && $this->isLocalized()) { return $this; @@ -414,7 +414,7 @@ public function setRequirement(string $key, string $regex) /** * @return string The condition */ - public function getCondition() + public function getCondition(): string { return $this->condition; } @@ -422,7 +422,7 @@ public function getCondition() /** * @return $this */ - public function setCondition(?string $condition) + public function setCondition(?string $condition): static { $this->condition = (string) $condition; $this->compiled = null; @@ -440,7 +440,7 @@ public function setCondition(?string $condition) * * @see RouteCompiler which is responsible for the compilation process */ - public function compile() + public function compile(): CompiledRoute { if (null !== $this->compiled) { return $this->compiled; diff --git a/src/Symfony/Component/Routing/RouteCollection.php b/src/Symfony/Component/Routing/RouteCollection.php index c3e99cc65775a..d0dc201084221 100644 --- a/src/Symfony/Component/Routing/RouteCollection.php +++ b/src/Symfony/Component/Routing/RouteCollection.php @@ -85,7 +85,7 @@ public function add(string $name, Route $route, int $priority = 0) * * @return Route[] An array of routes */ - public function all() + public function all(): array { if ($this->priorities) { $priorities = $this->priorities; @@ -103,7 +103,7 @@ public function all() * * @return Route|null */ - public function get(string $name) + public function get(string $name): ?Route { return $this->routes[$name] ?? null; } @@ -277,7 +277,7 @@ public function setMethods(string|array $methods) * * @return ResourceInterface[] An array of resources */ - public function getResources() + public function getResources(): array { return array_values($this->resources); } diff --git a/src/Symfony/Component/Routing/RouteCompiler.php b/src/Symfony/Component/Routing/RouteCompiler.php index 938cec479e3cc..d279a043c8bd4 100644 --- a/src/Symfony/Component/Routing/RouteCompiler.php +++ b/src/Symfony/Component/Routing/RouteCompiler.php @@ -47,7 +47,7 @@ class RouteCompiler implements RouteCompilerInterface * @throws \DomainException if a variable name starts with a digit or if it is too long to be successfully used as * a PCRE subpattern */ - public static function compile(Route $route) + public static function compile(Route $route): CompiledRoute { $hostVariables = []; $variables = []; diff --git a/src/Symfony/Component/Routing/RouteCompilerInterface.php b/src/Symfony/Component/Routing/RouteCompilerInterface.php index 9bae33a91430e..4df5410f60390 100644 --- a/src/Symfony/Component/Routing/RouteCompilerInterface.php +++ b/src/Symfony/Component/Routing/RouteCompilerInterface.php @@ -26,5 +26,5 @@ interface RouteCompilerInterface * @throws \LogicException If the Route cannot be compiled because the * path or host pattern is invalid */ - public static function compile(Route $route); + public static function compile(Route $route): CompiledRoute; } diff --git a/src/Symfony/Component/Routing/Router.php b/src/Symfony/Component/Routing/Router.php index f455860b362f8..fe5e3d80656c0 100644 --- a/src/Symfony/Component/Routing/Router.php +++ b/src/Symfony/Component/Routing/Router.php @@ -170,7 +170,7 @@ public function setOption(string $key, mixed $value) * * @throws \InvalidArgumentException */ - public function getOption(string $key) + public function getOption(string $key): mixed { if (!\array_key_exists($key, $this->options)) { throw new \InvalidArgumentException(sprintf('The Router does not support the "%s" option.', $key)); @@ -209,7 +209,7 @@ public function setContext(RequestContext $context) /** * {@inheritdoc} */ - public function getContext() + public function getContext(): RequestContext { return $this->context; } @@ -225,7 +225,7 @@ public function setConfigCacheFactory(ConfigCacheFactoryInterface $configCacheFa /** * {@inheritdoc} */ - public function generate(string $name, array $parameters = [], int $referenceType = self::ABSOLUTE_PATH) + public function generate(string $name, array $parameters = [], int $referenceType = self::ABSOLUTE_PATH): string { return $this->getGenerator()->generate($name, $parameters, $referenceType); } @@ -233,7 +233,7 @@ public function generate(string $name, array $parameters = [], int $referenceTyp /** * {@inheritdoc} */ - public function match(string $pathinfo) + public function match(string $pathinfo): array { return $this->getMatcher()->match($pathinfo); } @@ -241,7 +241,7 @@ public function match(string $pathinfo) /** * {@inheritdoc} */ - public function matchRequest(Request $request) + public function matchRequest(Request $request): array { $matcher = $this->getMatcher(); if (!$matcher instanceof RequestMatcherInterface) { @@ -257,7 +257,7 @@ public function matchRequest(Request $request) * * @return UrlMatcherInterface|RequestMatcherInterface */ - public function getMatcher() + public function getMatcher(): UrlMatcherInterface|RequestMatcherInterface { if (null !== $this->matcher) { return $this->matcher; @@ -300,7 +300,7 @@ function (ConfigCacheInterface $cache) { * * @return UrlGeneratorInterface */ - public function getGenerator() + public function getGenerator(): UrlGeneratorInterface { if (null !== $this->generator) { return $this->generator; @@ -340,7 +340,7 @@ public function addExpressionLanguageProvider(ExpressionFunctionProviderInterfac /** * @return GeneratorDumperInterface */ - protected function getGeneratorDumperInstance() + protected function getGeneratorDumperInstance(): GeneratorDumperInterface { return new $this->options['generator_dumper_class']($this->getRouteCollection()); } @@ -348,7 +348,7 @@ protected function getGeneratorDumperInstance() /** * @return MatcherDumperInterface */ - protected function getMatcherDumperInstance() + protected function getMatcherDumperInstance(): MatcherDumperInterface { return new $this->options['matcher_dumper_class']($this->getRouteCollection()); } diff --git a/src/Symfony/Component/Translation/Catalogue/AbstractOperation.php b/src/Symfony/Component/Translation/Catalogue/AbstractOperation.php index 9869fbb8bb34e..92a08d3017fa7 100644 --- a/src/Symfony/Component/Translation/Catalogue/AbstractOperation.php +++ b/src/Symfony/Component/Translation/Catalogue/AbstractOperation.php @@ -80,7 +80,7 @@ public function __construct(MessageCatalogueInterface $source, MessageCatalogueI /** * {@inheritdoc} */ - public function getDomains() + public function getDomains(): array { if (null === $this->domains) { $this->domains = array_values(array_unique(array_merge($this->source->getDomains(), $this->target->getDomains()))); @@ -92,7 +92,7 @@ public function getDomains() /** * {@inheritdoc} */ - public function getMessages(string $domain) + public function getMessages(string $domain): array { if (!\in_array($domain, $this->getDomains())) { throw new InvalidArgumentException(sprintf('Invalid domain: "%s".', $domain)); @@ -108,7 +108,7 @@ public function getMessages(string $domain) /** * {@inheritdoc} */ - public function getNewMessages(string $domain) + public function getNewMessages(string $domain): array { if (!\in_array($domain, $this->getDomains())) { throw new InvalidArgumentException(sprintf('Invalid domain: "%s".', $domain)); @@ -124,7 +124,7 @@ public function getNewMessages(string $domain) /** * {@inheritdoc} */ - public function getObsoleteMessages(string $domain) + public function getObsoleteMessages(string $domain): array { if (!\in_array($domain, $this->getDomains())) { throw new InvalidArgumentException(sprintf('Invalid domain: "%s".', $domain)); @@ -140,7 +140,7 @@ public function getObsoleteMessages(string $domain) /** * {@inheritdoc} */ - public function getResult() + public function getResult(): MessageCatalogueInterface { foreach ($this->getDomains() as $domain) { if (!isset($this->messages[$domain])) { diff --git a/src/Symfony/Component/Translation/Catalogue/OperationInterface.php b/src/Symfony/Component/Translation/Catalogue/OperationInterface.php index 9ffac88d28d4d..7d302406d5352 100644 --- a/src/Symfony/Component/Translation/Catalogue/OperationInterface.php +++ b/src/Symfony/Component/Translation/Catalogue/OperationInterface.php @@ -39,33 +39,33 @@ interface OperationInterface * * @return array */ - public function getDomains(); + public function getDomains(): array; /** * Returns all valid messages ('all') after operation. * * @return array */ - public function getMessages(string $domain); + public function getMessages(string $domain): array; /** * Returns new messages ('new') after operation. * * @return array */ - public function getNewMessages(string $domain); + public function getNewMessages(string $domain): array; /** * Returns obsolete messages ('obsolete') after operation. * * @return array */ - public function getObsoleteMessages(string $domain); + public function getObsoleteMessages(string $domain): array; /** * Returns resulting catalogue ('result'). * * @return MessageCatalogueInterface */ - public function getResult(); + public function getResult(): MessageCatalogueInterface; } diff --git a/src/Symfony/Component/Translation/Command/XliffLintCommand.php b/src/Symfony/Component/Translation/Command/XliffLintCommand.php index 64977e5c629ab..26ce70adc61b9 100644 --- a/src/Symfony/Component/Translation/Command/XliffLintCommand.php +++ b/src/Symfony/Component/Translation/Command/XliffLintCommand.php @@ -80,7 +80,7 @@ protected function configure() ; } - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); $filenames = (array) $input->getArgument('filename'); diff --git a/src/Symfony/Component/Translation/DataCollector/TranslationDataCollector.php b/src/Symfony/Component/Translation/DataCollector/TranslationDataCollector.php index 379130a44b0f5..a5bc68895c1e6 100644 --- a/src/Symfony/Component/Translation/DataCollector/TranslationDataCollector.php +++ b/src/Symfony/Component/Translation/DataCollector/TranslationDataCollector.php @@ -65,7 +65,7 @@ public function reset() /** * @return array|Data */ - public function getMessages() + public function getMessages(): array|Data { return $this->data['messages'] ?? []; } diff --git a/src/Symfony/Component/Translation/DataCollectorTranslator.php b/src/Symfony/Component/Translation/DataCollectorTranslator.php index ca56e46fadc8f..1e069e38119c5 100644 --- a/src/Symfony/Component/Translation/DataCollectorTranslator.php +++ b/src/Symfony/Component/Translation/DataCollectorTranslator.php @@ -74,7 +74,7 @@ public function getLocale(): string /** * {@inheritdoc} */ - public function getCatalogue(string $locale = null) + public function getCatalogue(string $locale = null): MessageCatalogueInterface { return $this->translator->getCatalogue($locale); } @@ -92,7 +92,7 @@ public function getCatalogues(): array * * @return string[] */ - public function warmUp(string $cacheDir) + public function warmUp(string $cacheDir): array { if ($this->translator instanceof WarmableInterface) { return (array) $this->translator->warmUp($cacheDir); @@ -106,7 +106,7 @@ public function warmUp(string $cacheDir) * * @return array The fallback locales */ - public function getFallbackLocales() + public function getFallbackLocales(): array { if ($this->translator instanceof Translator || method_exists($this->translator, 'getFallbackLocales')) { return $this->translator->getFallbackLocales(); @@ -126,7 +126,7 @@ public function __call(string $method, array $args) /** * @return array */ - public function getCollectedMessages() + public function getCollectedMessages(): array { return $this->messages; } diff --git a/src/Symfony/Component/Translation/DependencyInjection/TranslatorPathsPass.php b/src/Symfony/Component/Translation/DependencyInjection/TranslatorPathsPass.php index 99a074e5db92a..c0d527145a7db 100644 --- a/src/Symfony/Component/Translation/DependencyInjection/TranslatorPathsPass.php +++ b/src/Symfony/Component/Translation/DependencyInjection/TranslatorPathsPass.php @@ -86,7 +86,7 @@ public function process(ContainerBuilder $container) } } - protected function processValue(mixed $value, bool $isRoot = false) + protected function processValue(mixed $value, bool $isRoot = false): mixed { if ($value instanceof Reference) { if ((string) $value === $this->translatorServiceId) { diff --git a/src/Symfony/Component/Translation/Dumper/CsvFileDumper.php b/src/Symfony/Component/Translation/Dumper/CsvFileDumper.php index 0c8589af81d79..235c8aee0b8fc 100644 --- a/src/Symfony/Component/Translation/Dumper/CsvFileDumper.php +++ b/src/Symfony/Component/Translation/Dumper/CsvFileDumper.php @@ -26,7 +26,7 @@ class CsvFileDumper extends FileDumper /** * {@inheritdoc} */ - public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = []) + public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = []): string { $handle = fopen('php://memory', 'r+'); @@ -53,7 +53,7 @@ public function setCsvControl(string $delimiter = ';', string $enclosure = '"') /** * {@inheritdoc} */ - protected function getExtension() + protected function getExtension(): string { return 'csv'; } diff --git a/src/Symfony/Component/Translation/Dumper/FileDumper.php b/src/Symfony/Component/Translation/Dumper/FileDumper.php index e257e722461d0..30eca6616b4ec 100644 --- a/src/Symfony/Component/Translation/Dumper/FileDumper.php +++ b/src/Symfony/Component/Translation/Dumper/FileDumper.php @@ -89,14 +89,14 @@ public function dump(MessageCatalogue $messages, array $options = []) * * @return string representation */ - abstract public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = []); + abstract public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = []): string; /** * Gets the file extension of the dumper. * * @return string file extension */ - abstract protected function getExtension(); + abstract protected function getExtension(): string; /** * Gets the relative file path using the template. diff --git a/src/Symfony/Component/Translation/Dumper/IcuResFileDumper.php b/src/Symfony/Component/Translation/Dumper/IcuResFileDumper.php index cdc59913b3a3f..b62ea1536ddf1 100644 --- a/src/Symfony/Component/Translation/Dumper/IcuResFileDumper.php +++ b/src/Symfony/Component/Translation/Dumper/IcuResFileDumper.php @@ -28,7 +28,7 @@ class IcuResFileDumper extends FileDumper /** * {@inheritdoc} */ - public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = []) + public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = []): string { $data = $indexes = $resources = ''; @@ -97,7 +97,7 @@ private function getPosition(string $data) /** * {@inheritdoc} */ - protected function getExtension() + protected function getExtension(): string { return 'res'; } diff --git a/src/Symfony/Component/Translation/Dumper/IniFileDumper.php b/src/Symfony/Component/Translation/Dumper/IniFileDumper.php index 93c900a4a9fbc..75032be145289 100644 --- a/src/Symfony/Component/Translation/Dumper/IniFileDumper.php +++ b/src/Symfony/Component/Translation/Dumper/IniFileDumper.php @@ -23,7 +23,7 @@ class IniFileDumper extends FileDumper /** * {@inheritdoc} */ - public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = []) + public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = []): string { $output = ''; @@ -38,7 +38,7 @@ public function formatCatalogue(MessageCatalogue $messages, string $domain, arra /** * {@inheritdoc} */ - protected function getExtension() + protected function getExtension(): string { return 'ini'; } diff --git a/src/Symfony/Component/Translation/Dumper/JsonFileDumper.php b/src/Symfony/Component/Translation/Dumper/JsonFileDumper.php index 34c0b5694293f..11027303a17e0 100644 --- a/src/Symfony/Component/Translation/Dumper/JsonFileDumper.php +++ b/src/Symfony/Component/Translation/Dumper/JsonFileDumper.php @@ -23,7 +23,7 @@ class JsonFileDumper extends FileDumper /** * {@inheritdoc} */ - public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = []) + public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = []): string { $flags = $options['json_encoding'] ?? \JSON_PRETTY_PRINT; @@ -33,7 +33,7 @@ public function formatCatalogue(MessageCatalogue $messages, string $domain, arra /** * {@inheritdoc} */ - protected function getExtension() + protected function getExtension(): string { return 'json'; } diff --git a/src/Symfony/Component/Translation/Dumper/MoFileDumper.php b/src/Symfony/Component/Translation/Dumper/MoFileDumper.php index 9dc6101cbb66f..08c8f899747ba 100644 --- a/src/Symfony/Component/Translation/Dumper/MoFileDumper.php +++ b/src/Symfony/Component/Translation/Dumper/MoFileDumper.php @@ -24,7 +24,7 @@ class MoFileDumper extends FileDumper /** * {@inheritdoc} */ - public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = []) + public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = []): string { $sources = $targets = $sourceOffsets = $targetOffsets = ''; $offsets = []; @@ -70,7 +70,7 @@ public function formatCatalogue(MessageCatalogue $messages, string $domain, arra /** * {@inheritdoc} */ - protected function getExtension() + protected function getExtension(): string { return 'mo'; } diff --git a/src/Symfony/Component/Translation/Dumper/PhpFileDumper.php b/src/Symfony/Component/Translation/Dumper/PhpFileDumper.php index 6163b5297c104..565d893754250 100644 --- a/src/Symfony/Component/Translation/Dumper/PhpFileDumper.php +++ b/src/Symfony/Component/Translation/Dumper/PhpFileDumper.php @@ -23,7 +23,7 @@ class PhpFileDumper extends FileDumper /** * {@inheritdoc} */ - public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = []) + public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = []): string { return "all($domain), true).";\n"; } @@ -31,7 +31,7 @@ public function formatCatalogue(MessageCatalogue $messages, string $domain, arra /** * {@inheritdoc} */ - protected function getExtension() + protected function getExtension(): string { return 'php'; } diff --git a/src/Symfony/Component/Translation/Dumper/PoFileDumper.php b/src/Symfony/Component/Translation/Dumper/PoFileDumper.php index 2f7fc65e9ee36..313e5045875a5 100644 --- a/src/Symfony/Component/Translation/Dumper/PoFileDumper.php +++ b/src/Symfony/Component/Translation/Dumper/PoFileDumper.php @@ -23,7 +23,7 @@ class PoFileDumper extends FileDumper /** * {@inheritdoc} */ - public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = []) + public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = []): string { $output = 'msgid ""'."\n"; $output .= 'msgstr ""'."\n"; @@ -114,7 +114,7 @@ private function getStandardRules(string $id) /** * {@inheritdoc} */ - protected function getExtension() + protected function getExtension(): string { return 'po'; } diff --git a/src/Symfony/Component/Translation/Dumper/QtFileDumper.php b/src/Symfony/Component/Translation/Dumper/QtFileDumper.php index 406e9f0060b76..819409fc07453 100644 --- a/src/Symfony/Component/Translation/Dumper/QtFileDumper.php +++ b/src/Symfony/Component/Translation/Dumper/QtFileDumper.php @@ -23,7 +23,7 @@ class QtFileDumper extends FileDumper /** * {@inheritdoc} */ - public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = []) + public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = []): string { $dom = new \DOMDocument('1.0', 'utf-8'); $dom->formatOutput = true; @@ -54,7 +54,7 @@ public function formatCatalogue(MessageCatalogue $messages, string $domain, arra /** * {@inheritdoc} */ - protected function getExtension() + protected function getExtension(): string { return 'ts'; } diff --git a/src/Symfony/Component/Translation/Dumper/XliffFileDumper.php b/src/Symfony/Component/Translation/Dumper/XliffFileDumper.php index f7dbdcddf5fab..b8a109a41ffe7 100644 --- a/src/Symfony/Component/Translation/Dumper/XliffFileDumper.php +++ b/src/Symfony/Component/Translation/Dumper/XliffFileDumper.php @@ -24,7 +24,7 @@ class XliffFileDumper extends FileDumper /** * {@inheritdoc} */ - public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = []) + public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = []): string { $xliffVersion = '1.2'; if (\array_key_exists('xliff_version', $options)) { @@ -50,7 +50,7 @@ public function formatCatalogue(MessageCatalogue $messages, string $domain, arra /** * {@inheritdoc} */ - protected function getExtension() + protected function getExtension(): string { return 'xlf'; } diff --git a/src/Symfony/Component/Translation/Dumper/YamlFileDumper.php b/src/Symfony/Component/Translation/Dumper/YamlFileDumper.php index 0b21e8c830c06..bf7118b364d34 100644 --- a/src/Symfony/Component/Translation/Dumper/YamlFileDumper.php +++ b/src/Symfony/Component/Translation/Dumper/YamlFileDumper.php @@ -33,7 +33,7 @@ public function __construct(string $extension = 'yml') /** * {@inheritdoc} */ - public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = []) + public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = []): string { if (!class_exists(Yaml::class)) { throw new LogicException('Dumping translations in the YAML format requires the Symfony Yaml component.'); @@ -55,7 +55,7 @@ public function formatCatalogue(MessageCatalogue $messages, string $domain, arra /** * {@inheritdoc} */ - protected function getExtension() + protected function getExtension(): string { return $this->extension; } diff --git a/src/Symfony/Component/Translation/Extractor/AbstractFileExtractor.php b/src/Symfony/Component/Translation/Extractor/AbstractFileExtractor.php index e92e4e217d532..dfc6d9b887aa6 100644 --- a/src/Symfony/Component/Translation/Extractor/AbstractFileExtractor.php +++ b/src/Symfony/Component/Translation/Extractor/AbstractFileExtractor.php @@ -23,7 +23,7 @@ abstract class AbstractFileExtractor /** * @return iterable */ - protected function extractFiles(string|iterable $resource) + protected function extractFiles(string|iterable $resource): iterable { if (is_iterable($resource)) { $files = []; @@ -51,7 +51,7 @@ private function toSplFileInfo(string $file): \SplFileInfo * * @throws InvalidArgumentException */ - protected function isFile(string $file) + protected function isFile(string $file): bool { if (!is_file($file)) { throw new InvalidArgumentException(sprintf('The "%s" file does not exist.', $file)); diff --git a/src/Symfony/Component/Translation/Extractor/PhpExtractor.php b/src/Symfony/Component/Translation/Extractor/PhpExtractor.php index 4a061fb3ad20f..837e7d031416e 100644 --- a/src/Symfony/Component/Translation/Extractor/PhpExtractor.php +++ b/src/Symfony/Component/Translation/Extractor/PhpExtractor.php @@ -158,7 +158,7 @@ public function setPrefix(string $prefix) * * @return string|null */ - protected function normalizeToken(mixed $token) + protected function normalizeToken(mixed $token): ?string { if (isset($token[1]) && 'b"' !== $token) { return $token[1]; @@ -317,7 +317,7 @@ protected function parseTokens(array $tokens, MessageCatalogue $catalog, string * * @throws \InvalidArgumentException */ - protected function canBeExtracted(string $file) + protected function canBeExtracted(string $file): bool { return $this->isFile($file) && 'php' === pathinfo($file, \PATHINFO_EXTENSION); } @@ -325,7 +325,7 @@ protected function canBeExtracted(string $file) /** * {@inheritdoc} */ - protected function extractFromDirectory(string|array $directory) + protected function extractFromDirectory(string|array $directory): iterable { $finder = new Finder(); diff --git a/src/Symfony/Component/Translation/Extractor/PhpStringTokenParser.php b/src/Symfony/Component/Translation/Extractor/PhpStringTokenParser.php index 1d82caf26e597..7988cf676351e 100644 --- a/src/Symfony/Component/Translation/Extractor/PhpStringTokenParser.php +++ b/src/Symfony/Component/Translation/Extractor/PhpStringTokenParser.php @@ -67,7 +67,7 @@ class PhpStringTokenParser * * @return string The parsed string */ - public static function parse(string $str) + public static function parse(string $str): string { $bLength = 0; if ('b' === $str[0]) { @@ -93,7 +93,7 @@ public static function parse(string $str) * * @return string String with escape sequences parsed */ - public static function parseEscapeSequences(string $str, string $quote = null) + public static function parseEscapeSequences(string $str, string $quote = null): string { if (null !== $quote) { $str = str_replace('\\'.$quote, $quote, $str); @@ -127,7 +127,7 @@ private static function parseCallback(array $matches): string * * @return string Parsed string */ - public static function parseDocString(string $startToken, string $str) + public static function parseDocString(string $startToken, string $str): string { // strip last newline (thanks tokenizer for sticking it into the string!) $str = preg_replace('~(\r\n|\n|\r)$~', '', $str); diff --git a/src/Symfony/Component/Translation/Formatter/MessageFormatter.php b/src/Symfony/Component/Translation/Formatter/MessageFormatter.php index 04079648338c8..68821b1d0795e 100644 --- a/src/Symfony/Component/Translation/Formatter/MessageFormatter.php +++ b/src/Symfony/Component/Translation/Formatter/MessageFormatter.php @@ -37,7 +37,7 @@ public function __construct(TranslatorInterface $translator = null, IntlFormatte /** * {@inheritdoc} */ - public function format(string $message, string $locale, array $parameters = []) + public function format(string $message, string $locale, array $parameters = []): string { if ($this->translator instanceof TranslatorInterface) { return $this->translator->trans($message, $parameters, null, $locale); diff --git a/src/Symfony/Component/Translation/Formatter/MessageFormatterInterface.php b/src/Symfony/Component/Translation/Formatter/MessageFormatterInterface.php index b85dbfd115c17..6d45785ce89b5 100644 --- a/src/Symfony/Component/Translation/Formatter/MessageFormatterInterface.php +++ b/src/Symfony/Component/Translation/Formatter/MessageFormatterInterface.php @@ -26,5 +26,5 @@ interface MessageFormatterInterface * * @return string */ - public function format(string $message, string $locale, array $parameters = []); + public function format(string $message, string $locale, array $parameters = []): string; } diff --git a/src/Symfony/Component/Translation/Loader/ArrayLoader.php b/src/Symfony/Component/Translation/Loader/ArrayLoader.php index 13c046ee58880..35de9ef547e69 100644 --- a/src/Symfony/Component/Translation/Loader/ArrayLoader.php +++ b/src/Symfony/Component/Translation/Loader/ArrayLoader.php @@ -23,7 +23,7 @@ class ArrayLoader implements LoaderInterface /** * {@inheritdoc} */ - public function load(mixed $resource, string $locale, string $domain = 'messages') + public function load(mixed $resource, string $locale, string $domain = 'messages'): MessageCatalogue { $resource = $this->flatten($resource); $catalogue = new MessageCatalogue($locale); diff --git a/src/Symfony/Component/Translation/Loader/CsvFileLoader.php b/src/Symfony/Component/Translation/Loader/CsvFileLoader.php index 8d5d4db9a721f..8acba7a9ad194 100644 --- a/src/Symfony/Component/Translation/Loader/CsvFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/CsvFileLoader.php @@ -27,7 +27,7 @@ class CsvFileLoader extends FileLoader /** * {@inheritdoc} */ - protected function loadResource(string $resource) + protected function loadResource(string $resource): array { $messages = []; diff --git a/src/Symfony/Component/Translation/Loader/FileLoader.php b/src/Symfony/Component/Translation/Loader/FileLoader.php index 1e55a8908d1e6..e212cf569dccd 100644 --- a/src/Symfony/Component/Translation/Loader/FileLoader.php +++ b/src/Symfony/Component/Translation/Loader/FileLoader.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Translation\Loader; +use Symfony\Component\Translation\MessageCatalogue; use Symfony\Component\Config\Resource\FileResource; use Symfony\Component\Translation\Exception\InvalidResourceException; use Symfony\Component\Translation\Exception\NotFoundResourceException; @@ -23,7 +24,7 @@ abstract class FileLoader extends ArrayLoader /** * {@inheritdoc} */ - public function load(mixed $resource, string $locale, string $domain = 'messages') + public function load(mixed $resource, string $locale, string $domain = 'messages'): MessageCatalogue { if (!stream_is_local($resource)) { throw new InvalidResourceException(sprintf('This is not a local file "%s".', $resource)); @@ -59,5 +60,5 @@ public function load(mixed $resource, string $locale, string $domain = 'messages * * @throws InvalidResourceException if stream content has an invalid format */ - abstract protected function loadResource(string $resource); + abstract protected function loadResource(string $resource): array; } diff --git a/src/Symfony/Component/Translation/Loader/IcuDatFileLoader.php b/src/Symfony/Component/Translation/Loader/IcuDatFileLoader.php index e04d00b2d43db..c3ca5fd08b6f5 100644 --- a/src/Symfony/Component/Translation/Loader/IcuDatFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/IcuDatFileLoader.php @@ -26,7 +26,7 @@ class IcuDatFileLoader extends IcuResFileLoader /** * {@inheritdoc} */ - public function load(mixed $resource, string $locale, string $domain = 'messages') + public function load(mixed $resource, string $locale, string $domain = 'messages'): MessageCatalogue { if (!stream_is_local($resource.'.dat')) { throw new InvalidResourceException(sprintf('This is not a local file "%s".', $resource)); diff --git a/src/Symfony/Component/Translation/Loader/IcuResFileLoader.php b/src/Symfony/Component/Translation/Loader/IcuResFileLoader.php index af2a270ec4f3f..392a098863e8d 100644 --- a/src/Symfony/Component/Translation/Loader/IcuResFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/IcuResFileLoader.php @@ -26,7 +26,7 @@ class IcuResFileLoader implements LoaderInterface /** * {@inheritdoc} */ - public function load(mixed $resource, string $locale, string $domain = 'messages') + public function load(mixed $resource, string $locale, string $domain = 'messages'): MessageCatalogue { if (!stream_is_local($resource)) { throw new InvalidResourceException(sprintf('This is not a local file "%s".', $resource)); @@ -75,7 +75,7 @@ public function load(mixed $resource, string $locale, string $domain = 'messages * * @return array the flattened ResourceBundle */ - protected function flatten(\ResourceBundle $rb, array &$messages = [], string $path = null) + protected function flatten(\ResourceBundle $rb, array &$messages = [], string $path = null): array { foreach ($rb as $key => $value) { $nodePath = $path ? $path.'.'.$key : $key; diff --git a/src/Symfony/Component/Translation/Loader/IniFileLoader.php b/src/Symfony/Component/Translation/Loader/IniFileLoader.php index 7398f777814ab..04e294d119905 100644 --- a/src/Symfony/Component/Translation/Loader/IniFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/IniFileLoader.php @@ -21,7 +21,7 @@ class IniFileLoader extends FileLoader /** * {@inheritdoc} */ - protected function loadResource(string $resource) + protected function loadResource(string $resource): array { return parse_ini_file($resource, true); } diff --git a/src/Symfony/Component/Translation/Loader/JsonFileLoader.php b/src/Symfony/Component/Translation/Loader/JsonFileLoader.php index 5aefba07229f6..67a8d58ede73f 100644 --- a/src/Symfony/Component/Translation/Loader/JsonFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/JsonFileLoader.php @@ -23,7 +23,7 @@ class JsonFileLoader extends FileLoader /** * {@inheritdoc} */ - protected function loadResource(string $resource) + protected function loadResource(string $resource): array { $messages = []; if ($data = file_get_contents($resource)) { diff --git a/src/Symfony/Component/Translation/Loader/LoaderInterface.php b/src/Symfony/Component/Translation/Loader/LoaderInterface.php index 4970b2d2aa6eb..d92889a28dada 100644 --- a/src/Symfony/Component/Translation/Loader/LoaderInterface.php +++ b/src/Symfony/Component/Translation/Loader/LoaderInterface.php @@ -30,5 +30,5 @@ interface LoaderInterface * @throws NotFoundResourceException when the resource cannot be found * @throws InvalidResourceException when the resource cannot be loaded */ - public function load(mixed $resource, string $locale, string $domain = 'messages'); + public function load(mixed $resource, string $locale, string $domain = 'messages'): MessageCatalogue; } diff --git a/src/Symfony/Component/Translation/Loader/MoFileLoader.php b/src/Symfony/Component/Translation/Loader/MoFileLoader.php index 0ff6549d5292b..9e03e374c82e1 100644 --- a/src/Symfony/Component/Translation/Loader/MoFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/MoFileLoader.php @@ -41,7 +41,7 @@ class MoFileLoader extends FileLoader * * {@inheritdoc} */ - protected function loadResource(string $resource) + protected function loadResource(string $resource): array { $stream = fopen($resource, 'r'); diff --git a/src/Symfony/Component/Translation/Loader/PhpFileLoader.php b/src/Symfony/Component/Translation/Loader/PhpFileLoader.php index 85f10902b152d..e16ea0c1e0f8a 100644 --- a/src/Symfony/Component/Translation/Loader/PhpFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/PhpFileLoader.php @@ -23,7 +23,7 @@ class PhpFileLoader extends FileLoader /** * {@inheritdoc} */ - protected function loadResource(string $resource) + protected function loadResource(string $resource): array { if ([] === self::$cache && \function_exists('opcache_invalidate') && filter_var(ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN) && (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) || filter_var(ini_get('opcache.enable_cli'), \FILTER_VALIDATE_BOOLEAN))) { self::$cache = null; diff --git a/src/Symfony/Component/Translation/Loader/PoFileLoader.php b/src/Symfony/Component/Translation/Loader/PoFileLoader.php index ee143e20323cf..6df16148724b1 100644 --- a/src/Symfony/Component/Translation/Loader/PoFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/PoFileLoader.php @@ -60,7 +60,7 @@ class PoFileLoader extends FileLoader * * {@inheritdoc} */ - protected function loadResource(string $resource) + protected function loadResource(string $resource): array { $stream = fopen($resource, 'r'); diff --git a/src/Symfony/Component/Translation/Loader/QtFileLoader.php b/src/Symfony/Component/Translation/Loader/QtFileLoader.php index 13ece0fca99ff..6d5582d662adc 100644 --- a/src/Symfony/Component/Translation/Loader/QtFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/QtFileLoader.php @@ -28,7 +28,7 @@ class QtFileLoader implements LoaderInterface /** * {@inheritdoc} */ - public function load(mixed $resource, string $locale, string $domain = 'messages') + public function load(mixed $resource, string $locale, string $domain = 'messages'): MessageCatalogue { if (!class_exists(XmlUtils::class)) { throw new RuntimeException('Loading translations from the QT format requires the Symfony Config component.'); diff --git a/src/Symfony/Component/Translation/Loader/XliffFileLoader.php b/src/Symfony/Component/Translation/Loader/XliffFileLoader.php index d51c0ea17390a..85009b0db262c 100644 --- a/src/Symfony/Component/Translation/Loader/XliffFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/XliffFileLoader.php @@ -31,7 +31,7 @@ class XliffFileLoader implements LoaderInterface /** * {@inheritdoc} */ - public function load(mixed $resource, string $locale, string $domain = 'messages') + public function load(mixed $resource, string $locale, string $domain = 'messages'): MessageCatalogue { if (!class_exists(XmlUtils::class)) { throw new RuntimeException('Loading translations from the Xliff format requires the Symfony Config component.'); diff --git a/src/Symfony/Component/Translation/Loader/YamlFileLoader.php b/src/Symfony/Component/Translation/Loader/YamlFileLoader.php index 8588e186ad1a8..5eccf99de0d8e 100644 --- a/src/Symfony/Component/Translation/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/YamlFileLoader.php @@ -29,7 +29,7 @@ class YamlFileLoader extends FileLoader /** * {@inheritdoc} */ - protected function loadResource(string $resource) + protected function loadResource(string $resource): array { if (null === $this->yamlParser) { if (!class_exists(\Symfony\Component\Yaml\Parser::class)) { diff --git a/src/Symfony/Component/Translation/LoggingTranslator.php b/src/Symfony/Component/Translation/LoggingTranslator.php index 4b110865e9edf..8aa84ed9f4b22 100644 --- a/src/Symfony/Component/Translation/LoggingTranslator.php +++ b/src/Symfony/Component/Translation/LoggingTranslator.php @@ -77,7 +77,7 @@ public function getLocale(): string /** * {@inheritdoc} */ - public function getCatalogue(string $locale = null) + public function getCatalogue(string $locale = null): MessageCatalogueInterface { return $this->translator->getCatalogue($locale); } @@ -95,7 +95,7 @@ public function getCatalogues(): array * * @return array The fallback locales */ - public function getFallbackLocales() + public function getFallbackLocales(): array { if ($this->translator instanceof Translator || method_exists($this->translator, 'getFallbackLocales')) { return $this->translator->getFallbackLocales(); diff --git a/src/Symfony/Component/Translation/MessageCatalogue.php b/src/Symfony/Component/Translation/MessageCatalogue.php index 64ae2dd006bac..ed2de304e04d8 100644 --- a/src/Symfony/Component/Translation/MessageCatalogue.php +++ b/src/Symfony/Component/Translation/MessageCatalogue.php @@ -46,7 +46,7 @@ public function getLocale(): string /** * {@inheritdoc} */ - public function getDomains() + public function getDomains(): array { $domains = []; @@ -63,7 +63,7 @@ public function getDomains() /** * {@inheritdoc} */ - public function all(string $domain = null) + public function all(string $domain = null): array { if (null !== $domain) { // skip messages merge if intl-icu requested explicitly @@ -99,7 +99,7 @@ public function set(string $id, string $translation, string $domain = 'messages' /** * {@inheritdoc} */ - public function has(string $id, string $domain = 'messages') + public function has(string $id, string $domain = 'messages'): bool { if (isset($this->messages[$domain][$id]) || isset($this->messages[$domain.self::INTL_DOMAIN_SUFFIX][$id])) { return true; @@ -115,7 +115,7 @@ public function has(string $id, string $domain = 'messages') /** * {@inheritdoc} */ - public function defines(string $id, string $domain = 'messages') + public function defines(string $id, string $domain = 'messages'): bool { return isset($this->messages[$domain][$id]) || isset($this->messages[$domain.self::INTL_DOMAIN_SUFFIX][$id]); } @@ -123,7 +123,7 @@ public function defines(string $id, string $domain = 'messages') /** * {@inheritdoc} */ - public function get(string $id, string $domain = 'messages') + public function get(string $id, string $domain = 'messages'): string { if (isset($this->messages[$domain.self::INTL_DOMAIN_SUFFIX][$id])) { return $this->messages[$domain.self::INTL_DOMAIN_SUFFIX][$id]; @@ -233,7 +233,7 @@ public function addFallbackCatalogue(MessageCatalogueInterface $catalogue) /** * {@inheritdoc} */ - public function getFallbackCatalogue() + public function getFallbackCatalogue(): ?MessageCatalogueInterface { return $this->fallbackCatalogue; } @@ -241,7 +241,7 @@ public function getFallbackCatalogue() /** * {@inheritdoc} */ - public function getResources() + public function getResources(): array { return array_values($this->resources); } @@ -257,7 +257,7 @@ public function addResource(ResourceInterface $resource) /** * {@inheritdoc} */ - public function getMetadata(string $key = '', string $domain = 'messages') + public function getMetadata(string $key = '', string $domain = 'messages'): mixed { if ('' == $domain) { return $this->metadata; diff --git a/src/Symfony/Component/Translation/MessageCatalogueInterface.php b/src/Symfony/Component/Translation/MessageCatalogueInterface.php index 51e6dc8510270..792444c71fecd 100644 --- a/src/Symfony/Component/Translation/MessageCatalogueInterface.php +++ b/src/Symfony/Component/Translation/MessageCatalogueInterface.php @@ -27,14 +27,14 @@ interface MessageCatalogueInterface * * @return string The locale */ - public function getLocale(); + public function getLocale(): string; /** * Gets the domains. * * @return array An array of domains */ - public function getDomains(); + public function getDomains(): array; /** * Gets the messages within a given domain. @@ -45,7 +45,7 @@ public function getDomains(); * * @return array An array of messages */ - public function all(string $domain = null); + public function all(string $domain = null): array; /** * Sets a message translation. @@ -64,7 +64,7 @@ public function set(string $id, string $translation, string $domain = 'messages' * * @return bool true if the message has a translation, false otherwise */ - public function has(string $id, string $domain = 'messages'); + public function has(string $id, string $domain = 'messages'): bool; /** * Checks if a message has a translation (it does not take into account the fallback mechanism). @@ -74,7 +74,7 @@ public function has(string $id, string $domain = 'messages'); * * @return bool true if the message has a translation, false otherwise */ - public function defines(string $id, string $domain = 'messages'); + public function defines(string $id, string $domain = 'messages'): bool; /** * Gets a message translation. @@ -84,7 +84,7 @@ public function defines(string $id, string $domain = 'messages'); * * @return string The message translation */ - public function get(string $id, string $domain = 'messages'); + public function get(string $id, string $domain = 'messages'): string; /** * Sets translations for a given domain. @@ -119,17 +119,15 @@ public function addFallbackCatalogue(self $catalogue); /** * Gets the fallback catalogue. - * - * @return self|null */ - public function getFallbackCatalogue(); + public function getFallbackCatalogue(): ?self; /** * Returns an array of resources loaded to build this collection. * * @return ResourceInterface[] An array of resources */ - public function getResources(); + public function getResources(): array; /** * Adds a resource for this collection. diff --git a/src/Symfony/Component/Translation/MetadataAwareInterface.php b/src/Symfony/Component/Translation/MetadataAwareInterface.php index 240076971873d..2eaaceb36eb42 100644 --- a/src/Symfony/Component/Translation/MetadataAwareInterface.php +++ b/src/Symfony/Component/Translation/MetadataAwareInterface.php @@ -27,7 +27,7 @@ interface MetadataAwareInterface * * @return mixed The value that was set or an array with the domains/keys or null */ - public function getMetadata(string $key = '', string $domain = 'messages'); + public function getMetadata(string $key = '', string $domain = 'messages'): mixed; /** * Adds metadata to a message domain. diff --git a/src/Symfony/Component/Translation/Translator.php b/src/Symfony/Component/Translation/Translator.php index 8e013ef972e3c..566f3ef542a02 100644 --- a/src/Symfony/Component/Translation/Translator.php +++ b/src/Symfony/Component/Translation/Translator.php @@ -227,7 +227,7 @@ public function trans(?string $id, array $parameters = [], string $domain = null /** * {@inheritdoc} */ - public function getCatalogue(string $locale = null) + public function getCatalogue(string $locale = null): MessageCatalogueInterface { if (!$locale) { $locale = $this->getLocale(); @@ -255,7 +255,7 @@ public function getCatalogues(): array * * @return array LoaderInterface[] */ - protected function getLoaders() + protected function getLoaders(): array { return $this->loaders; } diff --git a/src/Symfony/Component/Translation/TranslatorBagInterface.php b/src/Symfony/Component/Translation/TranslatorBagInterface.php index 4228977352f29..a818e7ff73de8 100644 --- a/src/Symfony/Component/Translation/TranslatorBagInterface.php +++ b/src/Symfony/Component/Translation/TranslatorBagInterface.php @@ -31,5 +31,5 @@ interface TranslatorBagInterface * * @throws InvalidArgumentException If the locale contains invalid characters */ - public function getCatalogue(string $locale = null); + public function getCatalogue(string $locale = null): MessageCatalogueInterface; } diff --git a/src/Symfony/Component/Translation/Util/ArrayConverter.php b/src/Symfony/Component/Translation/Util/ArrayConverter.php index acfbfc363e8b7..639947bbf28c0 100644 --- a/src/Symfony/Component/Translation/Util/ArrayConverter.php +++ b/src/Symfony/Component/Translation/Util/ArrayConverter.php @@ -33,7 +33,7 @@ class ArrayConverter * * @return array Tree-like messages array */ - public static function expandToTree(array $messages) + public static function expandToTree(array $messages): array { $tree = []; diff --git a/src/Symfony/Component/Translation/Writer/TranslationWriter.php b/src/Symfony/Component/Translation/Writer/TranslationWriter.php index 0a349b824689f..41397cc05badb 100644 --- a/src/Symfony/Component/Translation/Writer/TranslationWriter.php +++ b/src/Symfony/Component/Translation/Writer/TranslationWriter.php @@ -38,7 +38,7 @@ public function addDumper(string $format, DumperInterface $dumper) * * @return array */ - public function getFormats() + public function getFormats(): array { return array_keys($this->dumpers); }