Skip to content

Commit 7a51052

Browse files
Enfore return types on all components
1 parent d8b20d5 commit 7a51052

30 files changed

+73
-880
lines changed

.github/expected-missing-return-types.diff

Lines changed: 0 additions & 632 deletions
This file was deleted.

.github/workflows/unit-tests.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -148,18 +148,6 @@ jobs:
148148
./phpunit install
149149
echo "::endgroup::"
150150
151-
- name: Patch return types
152-
if: "matrix.php == '8.4' && ! matrix.mode"
153-
run: |
154-
patch -sp1 < .github/expected-missing-return-types.diff
155-
git add .
156-
composer install -q --optimize-autoloader || composer install --optimize-autoloader
157-
SYMFONY_PATCH_TYPE_DECLARATIONS='force=2&php=8.4' php .github/patch-types.php
158-
git checkout src/Symfony/Contracts/Service/ResetInterface.php
159-
SYMFONY_PATCH_TYPE_DECLARATIONS='force=2&php=8.4' php .github/patch-types.php # ensure the script is idempotent
160-
git checkout src/Symfony/Contracts/Service/ResetInterface.php
161-
git diff --exit-code
162-
163151
- name: Check return types
164152
if: "matrix.php == '8.4' && ! matrix.mode"
165153
run: |

src/Symfony/Component/BrowserKit/AbstractBrowser.php

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -413,13 +413,11 @@ public function request(string $method, string $uri, array $parameters = [], arr
413413
*
414414
* @psalm-param TRequest $request
415415
*
416-
* @return object
417-
*
418416
* @psalm-return TResponse
419417
*
420418
* @throws \RuntimeException When processing returns exit code
421419
*/
422-
protected function doRequestInProcess(object $request)
420+
protected function doRequestInProcess(object $request): object
423421
{
424422
$deprecationsFile = tempnam(sys_get_temp_dir(), 'deprec');
425423
putenv('SYMFONY_DEPRECATIONS_SERIALIZE='.$deprecationsFile);
@@ -452,11 +450,9 @@ protected function doRequestInProcess(object $request)
452450
*
453451
* @psalm-param TRequest $request
454452
*
455-
* @return object
456-
*
457453
* @psalm-return TResponse
458454
*/
459-
abstract protected function doRequest(object $request);
455+
abstract protected function doRequest(object $request): object;
460456

461457
/**
462458
* Returns the script to execute when the request must be insulated.
@@ -465,23 +461,19 @@ abstract protected function doRequest(object $request);
465461
*
466462
* @param object $request An origin request instance
467463
*
468-
* @return string
469-
*
470464
* @throws LogicException When this abstract class is not implemented
471465
*/
472-
protected function getScript(object $request)
466+
protected function getScript(object $request): string
473467
{
474468
throw new LogicException('To insulate requests, you need to override the getScript() method.');
475469
}
476470

477471
/**
478472
* Filters the BrowserKit request to the origin one.
479473
*
480-
* @return object
481-
*
482474
* @psalm-return TRequest
483475
*/
484-
protected function filterRequest(Request $request)
476+
protected function filterRequest(Request $request): object
485477
{
486478
return $request;
487479
}
@@ -490,10 +482,8 @@ protected function filterRequest(Request $request)
490482
* Filters the origin response to the BrowserKit one.
491483
*
492484
* @psalm-param TResponse $response
493-
*
494-
* @return Response
495485
*/
496-
protected function filterResponse(object $response)
486+
protected function filterResponse(object $response): Response
497487
{
498488
return $response;
499489
}

src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,8 @@ public function attribute(string $key, mixed $value): static
111111

112112
/**
113113
* Returns the parent node.
114-
*
115-
* @return NodeParentInterface|NodeBuilder|self|ArrayNodeDefinition|VariableNodeDefinition
116114
*/
117-
public function end(): NodeParentInterface
115+
public function end(): NodeParentInterface|NodeBuilder|self|ArrayNodeDefinition|VariableNodeDefinition
118116
{
119117
return $this->parent;
120118
}

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,8 @@ public function isEnabled(): bool
197197

198198
/**
199199
* Configures the current command.
200-
*
201-
* @return void
202200
*/
203-
protected function configure()
201+
protected function configure(): void
204202
{
205203
}
206204

@@ -229,10 +227,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
229227
* This method is executed before the InputDefinition is validated.
230228
* This means that this is the only place where the command can
231229
* interactively ask for values of missing required arguments.
232-
*
233-
* @return void
234230
*/
235-
protected function interact(InputInterface $input, OutputInterface $output)
231+
protected function interact(InputInterface $input, OutputInterface $output): void
236232
{
237233
}
238234

@@ -245,10 +241,8 @@ protected function interact(InputInterface $input, OutputInterface $output)
245241
*
246242
* @see InputInterface::bind()
247243
* @see InputInterface::validate()
248-
*
249-
* @return void
250244
*/
251-
protected function initialize(InputInterface $input, OutputInterface $output)
245+
protected function initialize(InputInterface $input, OutputInterface $output): void
252246
{
253247
}
254248

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ abstract class AbstractRecursivePass implements CompilerPassInterface
3434
private ExpressionLanguage $expressionLanguage;
3535
private bool $inExpression = false;
3636

37-
/**
38-
* @return void
39-
*/
40-
public function process(ContainerBuilder $container)
37+
public function process(ContainerBuilder $container): void
4138
{
4239
$this->container = $container;
4340

@@ -65,10 +62,8 @@ protected function inExpression(bool $reset = true): bool
6562

6663
/**
6764
* Processes a value found in a definition tree.
68-
*
69-
* @return mixed
7065
*/
71-
protected function processValue(mixed $value, bool $isRoot = false)
66+
protected function processValue(mixed $value, bool $isRoot = false): mixed
7267
{
7368
if (\is_array($value)) {
7469
foreach ($value as $k => $v) {

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ interface CompilerPassInterface
2222
{
2323
/**
2424
* You can modify the container here before it is dumped to PHP code.
25-
*
26-
* @return void
2725
*/
28-
public function process(ContainerBuilder $container);
26+
public function process(ContainerBuilder $container): void;
2927
}

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,5 @@
2121
*/
2222
interface ConfigurationExtensionInterface
2323
{
24-
/**
25-
* Returns extension configuration.
26-
*
27-
* @return ConfigurationInterface|null
28-
*/
29-
public function getConfiguration(array $config, ContainerBuilder $container);
24+
public function getConfiguration(array $config, ContainerBuilder $container): ?ConfigurationInterface;
3025
}

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

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,12 @@ abstract class Extension implements ExtensionInterface, ConfigurationExtensionIn
2828
{
2929
private array $processedConfigs = [];
3030

31-
/**
32-
* @return string|false
33-
*/
34-
public function getXsdValidationBasePath()
31+
public function getXsdValidationBasePath(): string|false
3532
{
3633
return false;
3734
}
3835

39-
/**
40-
* @return string
41-
*/
42-
public function getNamespace()
36+
public function getNamespace(): string
4337
{
4438
return 'http://example.org/schema/dic/'.$this->getAlias();
4539
}
@@ -73,10 +67,7 @@ public function getAlias(): string
7367
return Container::underscore($classBaseName);
7468
}
7569

76-
/**
77-
* @return ConfigurationInterface|null
78-
*/
79-
public function getConfiguration(array $config, ContainerBuilder $container)
70+
public function getConfiguration(array $config, ContainerBuilder $container): ?ConfigurationInterface
8071
{
8172
$class = static::class;
8273

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

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,32 +25,24 @@ interface ExtensionInterface
2525
*
2626
* @param array<array<mixed>> $configs
2727
*
28-
* @return void
29-
*
3028
* @throws \InvalidArgumentException When provided tag is not defined in this extension
3129
*/
32-
public function load(array $configs, ContainerBuilder $container);
30+
public function load(array $configs, ContainerBuilder $container): void;
3331

3432
/**
3533
* Returns the namespace to be used for this extension (XML namespace).
36-
*
37-
* @return string
3834
*/
39-
public function getNamespace();
35+
public function getNamespace(): string;
4036

4137
/**
4238
* Returns the base path for the XSD files.
43-
*
44-
* @return string|false
4539
*/
46-
public function getXsdValidationBasePath();
40+
public function getXsdValidationBasePath(): string|false;
4741

4842
/**
4943
* Returns the recommended alias to use in XML.
5044
*
5145
* This alias is also the mandatory prefix to use when using YAML.
52-
*
53-
* @return string
5446
*/
55-
public function getAlias();
47+
public function getAlias(): string;
5648
}

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