Skip to content

Commit bb11086

Browse files
Add return types everywhere possible
1 parent 9004e35 commit bb11086

File tree

56 files changed

+100
-102
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+100
-102
lines changed

src/Symfony/Component/BrowserKit/AbstractBrowser.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ public function request(string $method, string $uri, array $parameters = [], arr
433433
*
434434
* @throws \RuntimeException When processing returns exit code
435435
*/
436-
protected function doRequestInProcess(object $request)
436+
protected function doRequestInProcess(object $request): object
437437
{
438438
$deprecationsFile = tempnam(sys_get_temp_dir(), 'deprec');
439439
putenv('SYMFONY_DEPRECATIONS_SERIALIZE='.$deprecationsFile);
@@ -466,7 +466,7 @@ protected function doRequestInProcess(object $request)
466466
*
467467
* @return object
468468
*/
469-
abstract protected function doRequest(object $request);
469+
abstract protected function doRequest(object $request): object;
470470

471471
/**
472472
* Returns the script to execute when the request must be insulated.
@@ -485,7 +485,7 @@ protected function getScript(object $request)
485485
*
486486
* @return object
487487
*/
488-
protected function filterRequest(Request $request)
488+
protected function filterRequest(Request $request): object
489489
{
490490
return $request;
491491
}
@@ -495,7 +495,7 @@ protected function filterRequest(Request $request)
495495
*
496496
* @return Response
497497
*/
498-
protected function filterResponse(object $response)
498+
protected function filterResponse(object $response): Response
499499
{
500500
return $response;
501501
}

src/Symfony/Component/Config/Definition/ConfigurationInterface.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\Component\Config\Definition;
1313

14+
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
15+
1416
/**
1517
* Configuration interface.
1618
*
@@ -20,8 +22,6 @@ interface ConfigurationInterface
2022
{
2123
/**
2224
* Generates the configuration tree builder.
23-
*
24-
* @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder
2525
*/
26-
public function getConfigTreeBuilder();
26+
public function getConfigTreeBuilder(): TreeBuilder;
2727
}

src/Symfony/Component/Config/FileLocator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function __construct(string|array $paths = [])
3333
/**
3434
* {@inheritdoc}
3535
*/
36-
public function locate(string $name, string $currentPath = null, bool $first = true)
36+
public function locate(string $name, string $currentPath = null, bool $first = true): string|array
3737
{
3838
if ('' === $name) {
3939
throw new \InvalidArgumentException('An empty file name is not valid to be located.');

src/Symfony/Component/Config/FileLocatorInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ interface FileLocatorInterface
3030
* @throws \InvalidArgumentException If $name is empty
3131
* @throws FileLocatorFileNotFoundException If a file is not found
3232
*/
33-
public function locate(string $name, string $currentPath = null, bool $first = true);
33+
public function locate(string $name, string $currentPath = null, bool $first = true): string|array;
3434
}

src/Symfony/Component/Config/Loader/FileLoader.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function getLocator()
7070
* @throws FileLoaderImportCircularReferenceException
7171
* @throws FileLocatorFileNotFoundException
7272
*/
73-
public function import(mixed $resource, string $type = null, bool $ignoreErrors = false, string $sourceResource = null, string|array $exclude = null)
73+
public function import(mixed $resource, string $type = null, bool $ignoreErrors = false, string $sourceResource = null, string|array $exclude = null): mixed
7474
{
7575
if (\is_string($resource) && \strlen($resource) !== ($i = strcspn($resource, '*?{[')) && !str_contains($resource, "\n")) {
7676
$excluded = [];

src/Symfony/Component/Config/Loader/Loader.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function setResolver(LoaderResolverInterface $resolver)
4949
*
5050
* @return mixed
5151
*/
52-
public function import(mixed $resource, string $type = null)
52+
public function import(mixed $resource, string $type = null): mixed
5353
{
5454
return $this->resolve($resource, $type)->load($resource, $type);
5555
}

src/Symfony/Component/Config/Loader/LoaderInterface.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ interface LoaderInterface
2525
*
2626
* @throws \Exception If something went wrong
2727
*/
28-
public function load(mixed $resource, string $type = null);
28+
public function load(mixed $resource, string $type = null): mixed;
2929

3030
/**
3131
* Returns whether this class supports the given resource.
@@ -34,14 +34,14 @@ public function load(mixed $resource, string $type = null);
3434
*
3535
* @return bool True if this class supports the given resource, false otherwise
3636
*/
37-
public function supports(mixed $resource, string $type = null);
37+
public function supports(mixed $resource, string $type = null): bool;
3838

3939
/**
4040
* Gets the loader resolver.
4141
*
4242
* @return LoaderResolverInterface
4343
*/
44-
public function getResolver();
44+
public function getResolver(): LoaderResolverInterface;
4545

4646
/**
4747
* Sets the loader resolver.

src/Symfony/Component/Config/ResourceCheckerInterface.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ interface ResourceCheckerInterface
3232
*
3333
* @return bool True if the ResourceChecker can handle this resource type, false if not
3434
*/
35-
public function supports(ResourceInterface $metadata);
35+
public function supports(ResourceInterface $metadata): bool;
3636

3737
/**
3838
* Validates the resource.
@@ -41,5 +41,5 @@ public function supports(ResourceInterface $metadata);
4141
*
4242
* @return bool True if the resource has not changed since the given timestamp, false otherwise
4343
*/
44-
public function isFresh(ResourceInterface $resource, int $timestamp);
44+
public function isFresh(ResourceInterface $resource, int $timestamp): bool;
4545
}

src/Symfony/Component/Console/Application.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ public function run(InputInterface $input = null, OutputInterface $output = null
213213
*
214214
* @return int 0 if everything went fine, or an error code
215215
*/
216-
public function doRun(InputInterface $input, OutputInterface $output)
216+
public function doRun(InputInterface $input, OutputInterface $output): int
217217
{
218218
if (true === $input->hasParameterOption(['--version', '-V'], true)) {
219219
$output->writeln($this->getLongVersion());
@@ -437,7 +437,7 @@ public function setVersion(string $version)
437437
*
438438
* @return string The long application version
439439
*/
440-
public function getLongVersion()
440+
public function getLongVersion(): string
441441
{
442442
if ('UNKNOWN' !== $this->getName()) {
443443
if ('UNKNOWN' !== $this->getVersion()) {
@@ -482,7 +482,7 @@ public function addCommands(array $commands)
482482
*
483483
* @return Command|null The registered command if enabled or null
484484
*/
485-
public function add(Command $command)
485+
public function add(Command $command): ?Command
486486
{
487487
$this->init();
488488

@@ -519,7 +519,7 @@ public function add(Command $command)
519519
*
520520
* @throws CommandNotFoundException When given command name does not exist
521521
*/
522-
public function get(string $name)
522+
public function get(string $name): Command
523523
{
524524
$this->init();
525525

@@ -630,7 +630,7 @@ public function findNamespace(string $namespace)
630630
*
631631
* @throws CommandNotFoundException When command name is incorrect or ambiguous
632632
*/
633-
public function find(string $name)
633+
public function find(string $name): Command
634634
{
635635
$this->init();
636636

@@ -740,7 +740,7 @@ public function find(string $name)
740740
*
741741
* @return Command[]
742742
*/
743-
public function all(string $namespace = null)
743+
public function all(string $namespace = null): array
744744
{
745745
$this->init();
746746

@@ -939,7 +939,7 @@ protected function configureIO(InputInterface $input, OutputInterface $output)
939939
*
940940
* @return int 0 if everything went fine, or an error code
941941
*/
942-
protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output)
942+
protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output): int
943943
{
944944
foreach ($command->getHelperSet() as $helper) {
945945
if ($helper instanceof InputAwareInterface) {

src/Symfony/Component/Console/Command/Command.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public function getApplication()
178178
*
179179
* @return bool
180180
*/
181-
public function isEnabled()
181+
public function isEnabled(): bool
182182
{
183183
return true;
184184
}
@@ -204,7 +204,7 @@ protected function configure()
204204
*
205205
* @see setCode()
206206
*/
207-
protected function execute(InputInterface $input, OutputInterface $output)
207+
protected function execute(InputInterface $input, OutputInterface $output): int
208208
{
209209
throw new LogicException('You must override the execute() method in the concrete command class.');
210210
}

src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ protected function inExpression(bool $reset = true): bool
6969
*
7070
* @return mixed The processed value
7171
*/
72-
protected function processValue(mixed $value, bool $isRoot = false)
72+
protected function processValue(mixed $value, bool $isRoot = false): mixed
7373
{
7474
if (\is_array($value)) {
7575
foreach ($value as $k => $v) {

src/Symfony/Component/DependencyInjection/Container.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function getParameterBag()
111111
*
112112
* @throws InvalidArgumentException if the parameter is not defined
113113
*/
114-
public function getParameter(string $name)
114+
public function getParameter(string $name): array|bool|string|int|float|null
115115
{
116116
return $this->parameterBag->get($name);
117117
}

src/Symfony/Component/DependencyInjection/ContainerInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function initialized(string $id);
5959
*
6060
* @throws InvalidArgumentException if the parameter is not defined
6161
*/
62-
public function getParameter(string $name);
62+
public function getParameter(string $name): array|bool|string|int|float|null;
6363

6464
/**
6565
* @return bool

src/Symfony/Component/DependencyInjection/Extension/ConfigurationExtensionInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ interface ConfigurationExtensionInterface
2626
*
2727
* @return ConfigurationInterface|null The configuration or null
2828
*/
29-
public function getConfiguration(array $config, ContainerBuilder $container);
29+
public function getConfiguration(array $config, ContainerBuilder $container): ?ConfigurationInterface;
3030
}

src/Symfony/Component/DependencyInjection/Extension/Extension.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ abstract class Extension implements ExtensionInterface, ConfigurationExtensionIn
3131
/**
3232
* {@inheritdoc}
3333
*/
34-
public function getXsdValidationBasePath()
34+
public function getXsdValidationBasePath(): string|false
3535
{
3636
return false;
3737
}
3838

3939
/**
4040
* {@inheritdoc}
4141
*/
42-
public function getNamespace()
42+
public function getNamespace(): string
4343
{
4444
return 'http://example.org/schema/dic/'.$this->getAlias();
4545
}
@@ -78,7 +78,7 @@ public function getAlias()
7878
/**
7979
* {@inheritdoc}
8080
*/
81-
public function getConfiguration(array $config, ContainerBuilder $container)
81+
public function getConfiguration(array $config, ContainerBuilder $container): ?ConfigurationInterface
8282
{
8383
$class = static::class;
8484

src/Symfony/Component/DependencyInjection/Extension/ExtensionInterface.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ public function load(array $configs, ContainerBuilder $container);
3232
*
3333
* @return string The XML namespace
3434
*/
35-
public function getNamespace();
35+
public function getNamespace(): string;
3636

3737
/**
3838
* Returns the base path for the XSD files.
3939
*
4040
* @return string|false
4141
*/
42-
public function getXsdValidationBasePath();
42+
public function getXsdValidationBasePath(): string|false;
4343

4444
/**
4545
* Returns the recommended alias to use in XML.

src/Symfony/Component/DependencyInjection/LazyProxy/Instantiator/InstantiatorInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ interface InstantiatorInterface
3030
*
3131
* @return object
3232
*/
33-
public function instantiateProxy(ContainerInterface $container, Definition $definition, string $id, callable $realInstantiator);
33+
public function instantiateProxy(ContainerInterface $container, Definition $definition, string $id, callable $realInstantiator): object;
3434
}

src/Symfony/Component/EventDispatcher/EventSubscriberInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,5 @@ interface EventSubscriberInterface
4545
*
4646
* @return array<string, mixed> The event names to listen to
4747
*/
48-
public static function getSubscribedEvents();
48+
public static function getSubscribedEvents(): array;
4949
}

src/Symfony/Component/ExpressionLanguage/ExpressionFunctionProviderInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ interface ExpressionFunctionProviderInterface
1919
/**
2020
* @return ExpressionFunction[]
2121
*/
22-
public function getFunctions();
22+
public function getFunctions(): array;
2323
}

src/Symfony/Component/Form/AbstractExtension.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function getTypeGuesser()
113113
*
114114
* @return FormTypeInterface[]
115115
*/
116-
protected function loadTypes()
116+
protected function loadTypes(): array
117117
{
118118
return [];
119119
}
@@ -133,7 +133,7 @@ protected function loadTypeExtensions()
133133
*
134134
* @return FormTypeGuesserInterface|null
135135
*/
136-
protected function loadTypeGuesser()
136+
protected function loadTypeGuesser(): ?FormTypeGuesserInterface
137137
{
138138
return null;
139139
}

src/Symfony/Component/Form/AbstractRendererEngine.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public function getResourceHierarchyLevel(FormView $view, array $blockNameHierar
134134
*
135135
* @return bool True if the resource could be loaded, false otherwise
136136
*/
137-
abstract protected function loadResourceForBlockName(string $cacheKey, FormView $view, string $blockName);
137+
abstract protected function loadResourceForBlockName(string $cacheKey, FormView $view, string $blockName): bool;
138138

139139
/**
140140
* Loads the cache with the resource for a specific level of a block hierarchy.

src/Symfony/Component/Form/AbstractType.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ public function configureOptions(OptionsResolver $resolver)
5151
/**
5252
* {@inheritdoc}
5353
*/
54-
public function getBlockPrefix()
54+
public function getBlockPrefix(): string
5555
{
5656
return StringUtil::fqcnToBlockPrefix(static::class) ?: '';
5757
}
5858

5959
/**
6060
* {@inheritdoc}
6161
*/
62-
public function getParent()
62+
public function getParent(): ?string
6363
{
6464
return FormType::class;
6565
}

src/Symfony/Component/Form/DataTransformerInterface.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ interface DataTransformerInterface
5959
*
6060
* @throws TransformationFailedException when the transformation fails
6161
*/
62-
public function transform(mixed $value);
62+
public function transform(mixed $value): mixed;
6363

6464
/**
6565
* Transforms a value from the transformed representation to its original
@@ -88,5 +88,5 @@ public function transform(mixed $value);
8888
*
8989
* @throws TransformationFailedException when the transformation fails
9090
*/
91-
public function reverseTransform(mixed $value);
91+
public function reverseTransform(mixed $value): mixed;
9292
}

src/Symfony/Component/Form/FormRendererEngineInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,5 +132,5 @@ public function getResourceHierarchyLevel(FormView $view, array $blockNameHierar
132132
*
133133
* @return string The HTML markup
134134
*/
135-
public function renderBlock(FormView $view, mixed $resource, string $blockName, array $variables = []);
135+
public function renderBlock(FormView $view, mixed $resource, string $blockName, array $variables = []): string;
136136
}

0 commit comments

Comments
 (0)