8000 Add return types everywhere possible · symfony/symfony@19f28cb · GitHub
[go: up one dir, main page]

Skip to content

Commit 19f28cb

Browse files
Add return types everywhere possible
1 parent c881201 commit 19f28cb

File tree

51 files changed

+90
-233
lines changed

Some content is hidden

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

51 files changed

+90
-233
lines changed

src/Symfony/Component/BrowserKit/AbstractBrowser.php

Lines changed: 4 additions & 12 deletions
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

Lines changed: 1 addition & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 3 deletions
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

Lines changed: 1 addition & 3 deletions
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

Lines changed: 3 additions & 9 deletions
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

Lines changed: 2 additions & 6 deletions
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

Lines changed: 7 additions & 15 deletions
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

Lines changed: 2 additions & 4 deletions
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
}

0 commit comments

Comments
 (0)
0