Skip to content

Commit a95fd2b

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

File tree

56 files changed

+100
-126
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
-126
lines changed

src/Symfony/Component/BrowserKit/AbstractBrowser.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -429,11 +429,9 @@ public function request(string $method, string $uri, array $parameters = [], arr
429429
/**
430430
* Makes a request in another process.
431431
*
432-
* @return object
433-
*
434432
* @throws \RuntimeException When processing returns exit code
435433
*/
436-
protected function doRequestInProcess(object $request)
434+
protected function doRequestInProcess(object $request): object
437435
{
438436
$deprecationsFile = tempnam(sys_get_temp_dir(), 'deprec');
439437
putenv('SYMFONY_DEPRECATIONS_SERIALIZE='.$deprecationsFile);
@@ -463,10 +461,8 @@ protected function doRequestInProcess(object $request)
463461

464462
/**
465463
* Makes a request.
466-
*
467-
* @return object
468464
*/
469-
abstract protected function doRequest(object $request);
465+
abstract protected function doRequest(object $request): object;
470466

471467
/**
472468
* Returns the script to execute when the request must be insulated.
@@ -482,20 +478,16 @@ protected function getScript(object $request)
482478

483479
/**
484480
* Filters the BrowserKit request to the origin one.
485-
*
486-
* @return object
487481
*/
488-
protected function filterRequest(Request $request)
482+
protected function filterRequest(Request $request): object
489483
{
490484
return $request;
491485
}
492486

493487
/**
494488
* Filters the origin response to the BrowserKit one.
495-
*
496-
* @return Response
497489
*/
498-
protected function filterResponse(object $response)
490+
protected function filterResponse(object $response): Response
499491
{
500492
return $response;
501493
}

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

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

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
@@ -64,13 +64,11 @@ public function getLocator()
6464
* @param string|null $sourceResource The original resource importing the new resource
6565
* @param string|string[]|null $exclude Glob patterns to exclude from the import
6666
*
67-
* @return mixed
68-
*
6967
* @throws LoaderLoadException
7068
* @throws FileLoaderImportCircularReferenceException
7169
* @throws FileLocatorFileNotFoundException
7270
*/
73-
public function import(mixed $resource, string $type = null, bool $ignoreErrors = false, string $sourceResource = null, string|array $exclude = null)
71+
public function import(mixed $resource, string $type = null, bool $ignoreErrors = false, string $sourceResource = null, string|array $exclude = null): mixed
7472
{
7573
if (\is_string($resource) && \strlen($resource) !== ($i = strcspn($resource, '*?{[')) && !str_contains($resource, "\n")) {
7674
$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 & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@ 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.
@@ -34,14 +32,12 @@ public function load(mixed $resource, string $type = null);
3432
*
3533
* @return bool True if this class supports the given resource, false otherwise
3634
*/
37-
public function supports(mixed $resource, string $type = null);
35+
public function supports(mixed $resource, string $type = null): bool;
3836

3937
/**
4038
* Gets the loader resolver.
41-
*
42-
* @return LoaderResolverInterface
4339
*/
44-
public function getResolver();
40+
public function getResolver(): LoaderResolverInterface;
4541

4642
/**
4743
* Sets the loader resolver.

src/Symfony/Component/Config/ResourceCheckerInterface.php

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

Lines changed: 7 additions & 9 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());
@@ -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

@@ -626,11 +626,9 @@ public function findNamespace(string $namespace)
626626
* Contrary to get, this command tries to find the best
627627
* match if you give it an abbreviation of a name or alias.
628628
*
629-
* @return Command
630-
*
631629
* @throws CommandNotFoundException When command name is incorrect or ambiguous
632630
*/
633-
public function find(string $name)
631+
public function find(string $name): Command
634632
{
635633
$this->init();
636634

@@ -740,7 +738,7 @@ public function find(string $name)
740738
*
741739
* @return Command[]
742740
*/
743-
public function all(string $namespace = null)
741+
public function all(string $namespace = null): array
744742
{
745743
$this->init();
746744

@@ -939,7 +937,7 @@ protected function configureIO(InputInterface $input, OutputInterface $output)
939937
*
940938
* @return int 0 if everything went fine, or an error code
941939
*/
942-
protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output)
940+
protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output): int
943941
{
944942
foreach ($command->getHelperSet() as $helper) {
945943
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
@@ -175,10 +175,8 @@ public function getApplication()
175175
*
176176
* Override this to check for x or y and return false if the command can not
177177
* run properly under the current conditions.
178-
*
179-
* @return bool
180178
*/
181-
public function isEnabled()
179+
public function isEnabled(): bool
182180
{
183181
return true;
184182
}
@@ -204,7 +202,7 @@ protected function configure()
204202
*
205203
* @see setCode()
206204
*/
207-
protected function execute(InputInterface $input, OutputInterface $output)
205+
protected function execute(InputInterface $input, OutputInterface $output): int
208206
{
209207
throw new LogicException('You must override the execute() method in the concrete command class.');
210208
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy