Skip to content

Commit cee0489

Browse files
Enforce return types on all components
1 parent 0144981 commit cee0489

33 files changed

+84
-920
lines changed

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

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

.github/patch-types.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@
4444
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Prototype/BadClasses/MissingParent.php'):
4545
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/'):
4646
case false !== strpos($file, '/src/Symfony/Component/ErrorHandler/Tests/Fixtures/'):
47-
case false !== strpos($file, '/src/Symfony/Component/HttpClient/Internal/') && str_contains($file, 'V5'):
48-
case false !== strpos($file, '/src/Symfony/Component/PropertyAccess/Tests/Fixtures/AsymmetricVisibility.php'):
47+
case false !== strpos($file, '/src/Symfony/Component/HttpClient/Internal/') && str_contains($file, 'V4'):
4948
case false !== strpos($file, '/src/Symfony/Component/PropertyInfo/Tests/Fixtures/'):
5049
case false !== strpos($file, '/src/Symfony/Component/Runtime/Internal/ComposerPlugin.php'):
5150
case false !== strpos($file, '/src/Symfony/Component/Security/Http/Tests/Fixtures/IsGrantedAttributeMethodsWithClosureController.php'):
@@ -55,7 +54,6 @@
5554
case false !== strpos($file, '/src/Symfony/Component/Validator/Tests/Constraints/Fixtures/WhenTestWithClosure.php'):
5655
case false !== strpos($file, '/src/Symfony/Component/Validator/Tests/Fixtures/NestedAttribute/Entity.php'):
5756
case false !== strpos($file, '/src/Symfony/Component/VarDumper/Tests/Fixtures/NotLoadableClass.php'):
58-
case false !== strpos($file, '/src/Symfony/Component/VarDumper/Tests/Fixtures/VirtualProperty.php'):
5957
case false !== strpos($file, '/src/Symfony/Component/VarExporter/Internal'):
6058
case false !== strpos($file, '/src/Symfony/Component/VarExporter/Tests/Fixtures/'):
6159
case false !== strpos($file, '/src/Symfony/Contracts/'):

.github/workflows/unit-tests.yml

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -148,22 +148,12 @@ jobs:
148148
./phpunit install
149149
echo "::endgroup::"
150150
151-
- name: Patch return types
151+
- name: Check return types
152152
if: "matrix.php == '8.4' && ! matrix.mode"
153153
run: |
154-
patch -sp1 < .github/expected-missing-return-types.diff
155-
git add .
156154
sed -i 's/ *"\*\*\/Tests\/",//' composer.json
157155
composer install -q --optimize-autoloader || composer install --optimize-autoloader
158-
SYMFONY_PATCH_TYPE_DECLARATIONS='force=2&php=8.4' php .github/patch-types.php
159-
git checkout composer.json src/Symfony/Contracts/Service/ResetInterface.php
160-
SYMFONY_PATCH_TYPE_DECLARATIONS='force=2&php=8.4' php .github/patch-types.php # ensure the script is idempotent
161-
git checkout src/Symfony/Contracts/Service/ResetInterface.php
162-
git diff --exit-code
163-
164-
- name: Check return types
165-
if: "matrix.php == '8.4' && ! matrix.mode"
166-
run: |
156+
git checkout composer.json
167157
php .github/patch-types.php lint
168158
169159
- name: Run tests
@@ -209,7 +199,7 @@ jobs:
209199
PATCHED_COMPONENTS=$(git diff --name-only src/ | grep composer.json || true)
210200
211201
# for 7.4 LTS, checkout and test previous major with the patched components (only for patched components)
212-
if [[ $PATCHED_COMPONENTS && $SYMFONY_VERSION = 7.4 ]]; then
202+
if [[ $PATCHED_COMPONENTS && $SYMFONY_VERSION = 7.4 && $FLIP = '' ]]; then
213203
export FLIP='^'
214204
SYMFONY_VERSION=$(echo $SYMFONY_VERSION | awk '{print $1 - 1}')
215205
echo -e "\\n\\e[33;1mChecking out Symfony $SYMFONY_VERSION and running tests with patched components as deps\\e[0m"

src/Symfony/Bridge/Twig/Test/Traits/RuntimeLoaderProvider.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@
1717

1818
trait RuntimeLoaderProvider
1919
{
20-
/**
21-
* @return void
22-
*/
23-
protected function registerTwigRuntimeLoader(Environment $environment, FormRenderer $renderer)
20+
protected function registerTwigRuntimeLoader(Environment $environment, FormRenderer $renderer): void
2421
{
2522
$loader = $this->createMock(RuntimeLoaderInterface::class);
2623
$loader->expects($this->any())->method('load')->willReturnMap([

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

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