Skip to content

Commit ea96144

Browse files
Add return types everywhere possible
1 parent 444d43f commit ea96144

File tree

50 files changed

+90
-230
lines changed

Some content is hidden

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

50 files changed

+90
-230
lines changed

src/Symfony/Component/BrowserKit/AbstractBrowser.php

+4-12
Original file line numberDiff line numberDiff line change
@@ -403,11 +403,9 @@ public function request(string $method, string $uri, array $parameters = [], arr
403403
/**
404404
* Makes a request in another process.
405405
*
406-
* @return object
407-
*
408406
* @throws \RuntimeException When processing returns exit code
409407
*/
410-
protected function doRequestInProcess(object $request)
408+
protected function doRequestInProcess(object $request): object
411409
{
412410
$deprecationsFile = tempnam(sys_get_temp_dir(), 'deprec');
413411
putenv('SYMFONY_DEPRECATIONS_SERIALIZE='.$deprecationsFile);
@@ -437,10 +435,8 @@ protected function doRequestInProcess(object $request)
437435

438436
/**
439437
* Makes a request.
440-
*
441-
* @return object
442438
*/
443-
abstract protected function doRequest(object $request);
439+
abstract protected function doRequest(object $request): object;
444440

445441
/**
446442
* Returns the script to execute when the request must be insulated.
@@ -456,20 +452,16 @@ protected function getScript(object $request)
456452

457453
/**
458454
* Filters the BrowserKit request to the origin one.
459-
*
460-
* @return object
461455
*/
462-
protected function filterRequest(Request $request)
456+
protected function filterRequest(Request $request): object
463457
{
464458
return $request;
465459
}
466460

467461
/**
468462
* Filters the origin response to the BrowserKit one.
469-
*
470-
* @return Response
471463
*/
472-
protected function filterResponse(object $response)
464+
protected function filterResponse(object $response): Response
473465
{
474466
return $response;
475467
}

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

+1-3
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ interface ConfigurationInterface
2222
{
2323
/**
2424
* Generates the configuration tree builder.
25-
*
26-
* @return TreeBuilder
2725
*/
28-
public function getConfigTreeBuilder();
26+
public function getConfigTreeBuilder(): TreeBuilder;
2927
}

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-3
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,11 @@ public function getLocator(): FileLocatorInterface
6262
* @param string|null $sourceResource The original resource importing the new resource
6363
* @param string|string[]|null $exclude Glob patterns to exclude from the import
6464
*
65-
* @return mixed
66-
*
6765
* @throws LoaderLoadException
6866
* @throws FileLoaderImportCircularReferenceException
6967
* @throws FileLocatorFileNotFoundException
7068
*/
71-
public function import(mixed $resource, string $type = null, bool $ignoreErrors = false, string $sourceResource = null, string|array $exclude = null)
69+
public function import(mixed $resource, string $type = null, bool $ignoreErrors = false, string $sourceResource = null, string|array $exclude = null): mixed
7270
{
7371
if (\is_string($resource) && \strlen($resource) !== ($i = strcspn($resource, '*?{[')) && !str_contains($resource, "\n")) {
7472
$excluded = [];

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

+1-3
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,8 @@ public function setResolver(LoaderResolverInterface $resolver)
4646

4747
/**
4848
* Imports a resource.
49-
*
50-
* @return mixed
5149
*/
52-
public function import(mixed $resource, string $type = null)
50+
public function import(mixed $resource, string $type = null): mixed
5351
{
5452
return $this->resolve($resource, $type)->load($resource, $type);
5553
}

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

+3-9
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,21 @@ interface LoaderInterface
2121
/**
2222
* Loads a resource.
2323
*
24-
* @return mixed
25-
*
2624
* @throws \Exception If something went wrong
2725
*/
28-
public function load(mixed $resource, string $type = null);
26+
public function load(mixed $resource, string $type = null): mixed;
2927

3028
/**
3129
* Returns whether this class supports the given resource.
3230
*
3331
* @param mixed $resource A resource
34-
*
35-
* @return bool
3632
*/
37-
public function supports(mixed $resource, string $type = null);
33+
public function supports(mixed $resource, string $type = null): bool;
3834

3935
/**
4036
* Gets the loader resolver.
41-
*
42-
* @return LoaderResolverInterface
4337
*/
44-
public function getResolver();
38+
public function getResolver(): LoaderResolverInterface;
4539

4640
/**
4741
* Sets the loader resolver.

src/Symfony/Component/Config/ResourceCheckerInterface.php

+2-6
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,13 @@ interface ResourceCheckerInterface
2929
/**
3030
* Queries the ResourceChecker whether it can validate a given
3131
* resource or not.
32-
*
33-
* @return bool
3432
*/
35-
public function supports(ResourceInterface $metadata);
33+
public function supports(ResourceInterface $metadata): bool;
3634

3735
/**
3836
* Validates the resource.
3937
*
4038
* @param int $timestamp The timestamp at which the cache associated with this resource was created
41-
*
42-
* @return bool
4339
*/
44-
public function isFresh(ResourceInterface $resource, int $timestamp);
40+
public function isFresh(ResourceInterface $resource, int $timestamp): bool;
4541
}

src/Symfony/Component/Console/Application.php

+7-15
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());
@@ -420,10 +420,8 @@ public function setVersion(string $version)
420420

421421
/**
422422
* Returns the long version of the application.
423-
*
424-
* @return string
425423
*/
426-
public function getLongVersion()
424+
public function getLongVersion(): string
427425
{
428426
if ('UNKNOWN' !== $this->getName()) {
429427
if ('UNKNOWN' !== $this->getVersion()) {
@@ -463,10 +461,8 @@ public function addCommands(array $commands)
463461
*
464462
* If a command with the same name already exists, it will be overridden.
465463
* If the command is not enabled it will not be added.
466-
*
467-
* @return Command|null
468464
*/
469-
public function add(Command $command)
465+
public function add(Command $command): ?Command
470466
{
471467
$this->init();
472468

@@ -499,11 +495,9 @@ public function add(Command $command)
499495
/**
500496
* Returns a registered command by name or alias.
501497
*
502-
* @return Command
503-
*
504498
* @throws CommandNotFoundException When given command name does not exist
505499
*/
506-
public function get(string $name)
500+
public function get(string $name): Command
507501
{
508502
$this->init();
509503

@@ -606,11 +600,9 @@ public function findNamespace(string $namespace): string
606600
* Contrary to get, this command tries to find the best
607601
* match if you give it an abbreviation of a name or alias.
608602
*
609-
* @return Command
610-
*
611603
* @throws CommandNotFoundException When command name is incorrect or ambiguous
612604
*/
613-
public function find(string $name)
605+
public function find(string $name): Command
614606
{
615607
$this->init();
616608

@@ -720,7 +712,7 @@ public function find(string $name)
720712
*
721713
* @return Command[]
722714
*/
723-
public function all(string $namespace = null)
715+
public function all(string $namespace = null): array
724716
{
725717
$this->init();
726718

@@ -919,7 +911,7 @@ protected function configureIO(InputInterface $input, OutputInterface $output)
919911
*
920912
* @return int 0 if everything went fine, or an error code
921913
*/
922-
protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output)
914+
protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output): int
923915
{
924916
foreach ($command->getHelperSet() as $helper) {
925917
if ($helper instanceof InputAwareInterface) {

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

+2-4
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,8 @@ public function getApplication(): ?Application
165165
*
166166
* Override this to check for x or y and return false if the command can not
167167
* run properly under the current conditions.
168-
*
169-
* @return bool
170168
*/
171-
public function isEnabled()
169+
public function isEnabled(): bool
172170
{
173171
return true;
174172
}
@@ -194,7 +192,7 @@ protected function configure()
194192
*
195193
* @see setCode()
196194
*/
197-
protected function execute(InputInterface $input, OutputInterface $output)
195+
protected function execute(InputInterface $input, OutputInterface $output): int
198196
{
199197
throw new LogicException('You must override the execute() method in the concrete command class.');
200198
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ protected function inExpression(bool $reset = true): bool
6767
/**
6868
* Processes a value found in a definition tree.
6969
*/
70-
protected function processValue(mixed $value, bool $isRoot = false)
70+
protected function processValue(mixed $value, bool $isRoot = false): mixed
7171
{
7272
if (\is_array($value)) {
7373
foreach ($value as $k => $v) {

src/Symfony/Component/DependencyInjection/Container.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,9 @@ public function getParameterBag(): ParameterBagInterface
103103
/**
104104
* Gets a parameter.
105105
*
106-
* @return array|bool|string|int|float|null
107-
*
108106
* @throws InvalidArgumentException if the parameter is not defined
109107
*/
110-
public function getParameter(string $name)
108+
public function getParameter(string $name): array|bool|string|int|float|null
111109
{
112110
return $this->parameterBag->get($name);
113111
}

src/Symfony/Component/DependencyInjection/ContainerInterface.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,9 @@ public function has(string $id): bool;
4848
public function initialized(string $id): bool;
4949

5050
/**
51-
* @return array|bool|string|int|float|null
52-
*
5351
* @throws InvalidArgumentException if the parameter is not defined
5452
*/
55-
public function getParameter(string $name);
53+
public function getParameter(string $name): array|bool|string|int|float|null;
5654

5755
public function hasParameter(string $name): bool;
5856

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

+1-3
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ interface ConfigurationExtensionInterface
2323
{
2424
/**
2525
* Returns extension configuration.
26-
*
27-
* @return ConfigurationInterface|null
2826
*/
29-
public function getConfiguration(array $config, ContainerBuilder $container);
27+
public function getConfiguration(array $config, ContainerBuilder $container): ?ConfigurationInterface;
3028
}

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
}
@@ -76,7 +76,7 @@ public function getAlias(): string
7676
/**
7777
* {@inheritdoc}
7878
*/
79-
public function getConfiguration(array $config, ContainerBuilder $container)
79+
public function getConfiguration(array $config, ContainerBuilder $container): ?ConfigurationInterface
8080
{
8181
$class = static::class;
8282

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

+3-9
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,18 @@ public function load(array $configs, ContainerBuilder $container);
2929

3030
/**
3131
* Returns the namespace to be used for this extension (XML namespace).
32-
*
33-
* @return string
3432
*/
35-
public function getNamespace();
33+
public function getNamespace(): string;
3634

3735
/**
3836
* Returns the base path for the XSD files.
39-
*
40-
* @return string|false
4137
*/
42-
public function getXsdValidationBasePath();
38+
public function getXsdValidationBasePath(): string|false;
4339

4440
/**
4541
* Returns the recommended alias to use in XML.
4642
*
4743
* This alias is also the mandatory prefix to use when using YAML.
48-
*
49-
* @return string
5044
*/
51-
public function getAlias();
45+
public function getAlias(): string;
5246
}

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

+1-3
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ interface InstantiatorInterface
2727
*
2828
* @param string $id Identifier of the requested service
2929
* @param callable $realInstantiator Zero-argument callback that is capable of producing the real service instance
30-
*
31-
* @return object
3230
*/
33-
public function instantiateProxy(ContainerInterface $container, Definition $definition, string $id, callable $realInstantiator);
31+
public function instantiateProxy(ContainerInterface $container, Definition $definition, string $id, callable $realInstantiator): object;
3432
}

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, string|array{0: string, 1: int}|list<array{0: string, 1?: int}>>
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-4
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function getTypeGuesser(): ?FormTypeGuesserInterface
113113
*
114114
* @return FormTypeInterface[]
115115
*/
116-
protected function loadTypes()
116+
protected function loadTypes(): array
117117
{
118118
return [];
119119
}
@@ -130,10 +130,8 @@ protected function loadTypeExtensions(): array
130130

131131
/**
132132
* Registers the type guesser.
133-
*
134-
* @return FormTypeGuesserInterface|null
135133
*/
136-
protected function loadTypeGuesser()
134+
protected function loadTypeGuesser(): ?FormTypeGuesserInterface
137135
{
138136
return null;
139137
}

0 commit comments

Comments
 (0)