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

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

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 & 1 deletion
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

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

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

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 & 7 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

@@ -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

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

0 commit comments

Comments
 (0)