Thanks to visit codestin.com
Credit goes to github.com

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
}

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

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

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

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

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

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

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

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

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

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

Lines changed: 2 additions & 4 deletions
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
}
@@ -130,10 +130,8 @@ protected function loadTypeExtensions()
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
}

src/Symfony/Component/Form/AbstractRendererEngine.php

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

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

0 commit comments

Comments
 (0)