8000 Merge branch '7.4' into 8.0 · symfony/symfony@0144981 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0144981

Browse files
Merge branch '7.4' into 8.0
* 7.4: Tweak return type declarations and related CI checks [Process] Improve typing for process callback
2 parents d8b20d5 + 3fe77f0 commit 0144981

File tree

10 files changed

+131
-69
lines changed

10 files changed

+131
-69
lines changed

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

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ git checkout src/Symfony/Contracts/Service/ResetInterface.php
77
(echo "$head" && echo && git diff -U2 src/ | grep '^index ' -v) > .github/expected-missing-return-types.diff
88
git checkout composer.json src/
99

10+
diff --git a/src/Symfony/Bridge/Twig/Test/Traits/RuntimeLoaderProvider.php b/src/Symfony/Bridge/Twig/Test/Traits/RuntimeLoaderProvider.php
11+
--- a/src/Symfony/Bridge/Twig/Test/Traits/RuntimeLoaderProvider.php
12+
+++ b/src/Symfony/Bridge/Twig/Test/Traits/RuntimeLoaderProvider.php
13+
@@ -21,5 +21,5 @@ trait RuntimeLoaderProvider
14+
* @return void
15+
*/
16+
- protected function registerTwigRuntimeLoader(Environment $environment, FormRenderer $renderer)
17+
+ protected function registerTwigRuntimeLoader(Environment $environment, FormRenderer $renderer): void
18+
{
19+
$loader = $this->createMock(RuntimeLoaderInterface::class);
1020
diff --git a/src/Symfony/Component/BrowserKit/AbstractBrowser.php b/src/Symfony/Component/BrowserKit/AbstractBrowser.php
1121
--- a/src/Symfony/Component/BrowserKit/AbstractBrowser.php
1222
+++ b/src/Symfony/Component/BrowserKit/AbstractBrowser.php
@@ -48,7 +58,7 @@ diff --git a/src/Symfony/Component/BrowserKit/AbstractBrowser.php b/src/Symfony/
4858
diff --git a/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php
4959
--- a/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php
5060
+++ b/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php
51-
@@ -94,5 +94,5 @@ abstract class NodeDefinition implements NodeParentInterface
61+
@@ -115,5 +115,5 @@ abstract class NodeDefinition implements NodeParentInterface
5262
* @return NodeParentInterface|NodeBuilder|self|ArrayNodeDefinition|VariableNodeDefinition
5363
*/
5464
- public function end(): NodeParentInterface
@@ -58,21 +68,21 @@ diff --git a/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php
5868
diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php
5969
--- a/src/Symfony/Component/Console/Command/Command.php
6070
+++ b/src/Symfony/Component/Console/Command/Command.php
61-
@@ -163,5 +163,5 @@ class Command
71+
@@ -201,5 +201,5 @@ class Command implements SignalableCommandInterface
6272
* @return void
6373
*/
6474
- protected function configure()
6575
+ protected function configure(): void
6676
{
6777
}
68-
@@ -195,5 +195,5 @@ class Command
78+
@@ -233,5 +233,5 @@ class Command implements SignalableCommandInterface
6979
* @return void
7080
*/
7181
- protected function interact(InputInterface $input, OutputInterface $output)
7282
+ protected function interact(InputInterface $input, OutputInterface $output): void
7383
{
7484
}
75-
@@ -211,5 +211,5 @@ class Command
85+
@@ -249,5 +249,5 @@ class Command implements SignalableCommandInterface
7686
* @return void
7787
*/
7888
- protected function initialize(InputInterface $input, OutputInterface $output)
@@ -474,14 +484,14 @@ diff --git a/src/Symfony/Component/HttpKernel/KernelInterface.php b/src/Symfony/
474484
diff --git a/src/Symfony/Component/Routing/Loader/AttributeClassLoader.php b/src/Symfony/Component/Routing/Loader/AttributeClassLoader.php
475485
--- a/src/Symfony/Component/Routing/Loader/AttributeClassLoader.php
476486
+++ b/src/Symfony/Component/Routing/Loader/AttributeClassLoader.php
477-
@@ -253,5 +253,5 @@ abstract class AttributeClassLoader implements LoaderInterface
487+
@@ -277,5 +277,5 @@ abstract class AttributeClassLoader implements LoaderInterface
478488
* @return string
479489
*/
480490
- protected function getDefaultRouteName(\ReflectionClass $class, \ReflectionMethod $method)
481491
+ protected function getDefaultRouteName(\ReflectionClass $class, \ReflectionMethod $method): string
482492
{
483493
$name = str_replace('\\', '_', $class->name).'_'.$method->name;
484-
@@ -355,5 +355,5 @@ abstract class AttributeClassLoader implements LoaderInterface
494+
@@ -379,5 +379,5 @@ abstract class AttributeClassLoader implements LoaderInterface
485495
* @return void
486496
*/
487497
- abstract protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, object $attr);
@@ -578,7 +588,7 @@ diff --git a/src/Symfony/Component/Translation/Extractor/ExtractorInterface.php
578588
diff --git a/src/Symfony/Component/TypeInfo/Tests/Fixtures/DummyWithPhpDoc.php b/src/Symfony/Component/TypeInfo/Tests/Fixtures/DummyWithPhpDoc.php
579589
--- a/src/Symfony/Component/TypeInfo/Tests/Fixtures/DummyWithPhpDoc.php
580590
+++ b/src/Symfony/Component/TypeInfo/Tests/Fixtures/DummyWithPhpDoc.php
581-
@@ -15,5 +15,5 @@ final class DummyWithPhpDoc
591+
@@ -50,5 +50,5 @@ final class DummyWithPhpDoc
582592
* @return Dummy
583593
*/
584594
- public function getNextDummy(mixed $dummy): mixed
@@ -610,6 +620,23 @@ diff --git a/src/Symfony/Component/VarDumper/Dumper/DataDumperInterface.php b/sr
610620
- public function dump(Data $data);
611621
+ public function dump(Data $data): ?string;
612622
}
623+
diff --git a/src/Symfony/Component/VarDumper/Test/VarDumperTestTrait.php b/src/Symfony/Component/VarDumper/Test/VarDumperTestTrait.php
624+
--- a/src/Symfony/Component/VarDumper/Test/VarDumperTestTrait.php
625+
+++ b/src/Symfony/Component/VarDumper/Test/VarDumperTestTrait.php
626+
@@ -49,5 +49,5 @@ trait VarDumperTestTrait
627+
* @return void
628+
*/
629+
- public function assertDumpEquals(mixed $expected, mixed $data, int $filter = 0, string $message = '')
630+
+ public function assertDumpEquals(mixed $expected, mixed $data, int $filter = 0, string $message = ''): void
631+
{
632+
$this->assertSame($this->prepareExpectation($expected, $filter), $this->getDump($data, null, $filter), $message);
633+
@@ -57,5 +57,5 @@ trait VarDumperTestTrait
634+
* @return void
635+
*/
636+
- public function assertDumpMatchesFormat(mixed $expected, mixed $data, int $filter = 0, string $message = '')
637+
+ public function assertDumpMatchesFormat(mixed $expected, mixed $data, int $filter = 0, string $message = ''): void
638+
{
639+
$this->assertStringMatchesFormat($this->prepareExpectation($expected, $filter), $this->getDump($data, null, $filter), $message);
613640
diff --git a/src/Symfony/Contracts/Translation/LocaleAwareInterface.php b/src/Symfony/Contracts/Translation/LocaleAwareInterface.php
614641
--- a/src/Symfony/Contracts/Translation/LocaleAwareInterface.php
615642
+++ b/src/Symfony/Contracts/Translation/LocaleAwareInterface.php

.github/patch-types.php

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
use PHPUnit\Framework\TestCase;
4+
35
$mode = $argv[1] ?? 'patch';
46
if ('lint' !== $mode && false === getenv('SYMFONY_PATCH_TYPE_DECLARATIONS')) {
57
echo "Please define the SYMFONY_PATCH_TYPE_DECLARATIONS env var when running this script.\n";
@@ -18,17 +20,16 @@
1820

1921
switch (true) {
20< 10000 code>22
case false !== strpos($file, '/src/Symfony/Component/Cache/Traits/Redis'):
23+
case false !== strpos($file, '/src/Symfony/Component/Cache/Traits/Relay'):
2124
if (!str_ends_with($file, 'Proxy.php')) {
2225
break;
2326
}
24-
// no break;
27+
continue 2;
2528
case false !== strpos($file, '/vendor/'):
26-
case false !== strpos($file, '/src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php'):
2729
case false !== strpos($file, '/src/Symfony/Bridge/Doctrine/Middleware/Debug/'):
2830
case false !== strpos($file, '/src/Symfony/Bridge/Doctrine/Tests/Fixtures/LegacyQueryMock.php'):
2931
case false !== strpos($file, '/src/Symfony/Bridge/PhpUnit/'):
3032
case false !== strpos($file, '/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Validation/Article.php'):
31-
case false !== strpos($file, '/src/Symfony/Component/Cache/Tests/Fixtures/DriverWrapper.php'):
3233
case false !== strpos($file, '/src/Symfony/Component/Config/Tests/Fixtures/BadFileName.php'):
3334
case false !== strpos($file, '/src/Symfony/Component/Config/Tests/Fixtures/BadParent.php'):
3435
case false !== strpos($file, '/src/Symfony/Component/Config/Tests/Fixtures/ParseError.php'):
@@ -38,52 +39,46 @@
3839
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/compositetype_classes.php'):
3940
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/intersectiontype_classes.php'):
4041
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/MultipleArgumentsOptionalScalarNotReallyOptional.php'):
41-
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/CheckTypeDeclarationsPass/IntersectionConstructor.php'):
42-
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/NewInInitializer.php'):
4342
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/ParentNotExists.php'):
4443
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Preload/'):
4544
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Prototype/BadClasses/MissingParent.php'):
4645
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/'):
47-
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/TestServiceSubscriberIntersectionWithTrait.php'):
4846
case false !== strpos($file, '/src/Symfony/Component/ErrorHandler/Tests/Fixtures/'):
49-
case false !== strpos($file, '/src/Symfony/Component/HttpClient/Internal/'):
50-
case false !== strpos($file, '/src/Symfony/Component/Form/Tests/Fixtures/Answer.php'):
51-
case false !== strpos($file, '/src/Symfony/Component/Form/Tests/Fixtures/Number.php'):
52-
case false !== strpos($file, '/src/Symfony/Component/Form/Tests/Fixtures/Suit.php'):
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'):
5349
case false !== strpos($file, '/src/Symfony/Component/PropertyInfo/Tests/Fixtures/'):
54-
case false !== strpos($file, '/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Php81Dummy.php'):
5550
case false !== strpos($file, '/src/Symfony/Component/Runtime/Internal/ComposerPlugin.php'):
51+
case false !== strpos($file, '/src/Symfony/Component/Security/Http/Tests/Fixtures/IsGrantedAttributeMethodsWithClosureController.php'):
52+
case false !== strpos($file, '/src/Symfony/Component/Security/Http/Tests/Fixtures/IsGrantedAttributeWithClosureController.php'):
5653
case false !== strpos($file, '/src/Symfony/Component/Serializer/Tests/Fixtures/'):
5754
case false !== strpos($file, '/src/Symfony/Component/Serializer/Tests/Normalizer/Features/ObjectOuter.php'):
55+
case false !== strpos($file, '/src/Symfony/Component/Validator/Tests/Constraints/Fixtures/WhenTestWithClosure.php'):
5856
case false !== strpos($file, '/src/Symfony/Component/Validator/Tests/Fixtures/NestedAttribute/Entity.php'):
5957
case false !== strpos($file, '/src/Symfony/Component/VarDumper/Tests/Fixtures/NotLoadableClass.php'):
60-
case false !== strpos($file, '/src/Symfony/Component/VarDumper/Tests/Fixtures/ReflectionIntersectionTypeFixture.php'):
61-
case false !== strpos($file, '/src/Symfony/Component/VarDumper/Tests/Fixtures/ReflectionUnionTypeWithIntersectionFixture.php'):
6258
case false !== strpos($file, '/src/Symfony/Component/VarDumper/Tests/Fixtures/VirtualProperty.php'):
6359
case false !== strpos($file, '/src/Symfony/Component/VarExporter/Internal'):
6460
case false !== strpos($file, '/src/Symfony/Component/VarExporter/Tests/Fixtures/'):
65-
case false !== strpos($file, '/src/Symfony/Component/Cache/Traits/RelayProxy.php'):
66-
case false !== strpos($file, '/src/Symfony/Contracts/Service/Test/ServiceLocatorTest.php'):
67-
case false !== strpos($file, '/src/Symfony/Contracts/Service/Test/ServiceLocatorTestCase.php'):
61+
case false !== strpos($file, '/src/Symfony/Contracts/'):
6862
continue 2;
6963
}
7064

7165
class_exists($class);
7266

73-
if ('lint' !== $mode) {
67+
if ('lint' !== $mode || is_subclass_of($class, TestCase::class)) {
7468
continue;
7569
}
7670

7771
$refl = new \ReflectionClass($class);
7872
foreach ($refl->getMethods() as $method) {
7973
if (
8074
$method->getReturnType()
81-
|| str_contains($method->getDocComment(), '@return')
75+
|| (str_contains($method->getDocComment(), '@return') && str_contains($method->getDocComment(), 'resource'))
8276
|| '__construct' === $method->getName()
8377
|| '__destruct' === $method->getName()
8478
|| '__clone' === $method->getName()
8579
|| $method->getDeclaringClass()->getName() !== $class
86-
|| str_contains($method->getDeclaringClass()->getName(), '\\Test\\')
80+
|| str_contains($method->getDeclaringClass()->getName(), '\\Tests\\')
81+
|| str_contains($method->getDeclaringClass()->getName(), '\\Test\\') && str_starts_with($method->getName(), 'test')
8782
) {
8883
continue;
8984
}
@@ -95,6 +90,7 @@ class_exists($class);
9590
if ($missingReturnTypes) {
9691
echo \count($missingReturnTypes)." missing return types on interfaces\n\n";
9792
echo implode("\n", $missingReturnTypes);
93+
echo "\n";
9894
exit(1);
9995
}
10096

.github/workflows/unit-tests.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ jobs:
9999
100100
# Create local composer packages for each patched components and reference them in composer.json files when cross-testing components
101101
if [[ ! "${{ matrix.mode }}" = *-deps ]]; then
102-
php .github/build-packages.php HEAD^ $SYMFONY_VERSION src/Symfony/Bridge/PhpUnit
102+
php .github/build-packages.php HEAD^ $SYMFONY_VERSION src/Symfony/Bridge/PhpUnit
103103
else
104104
echo SYMFONY_DEPRECATIONS_HELPER=weak >> $GITHUB_ENV
105105
cp composer.json composer.json.orig
@@ -153,9 +153,10 @@ jobs:
153153
run: |
154154
patch -sp1 < .github/expected-missing-return-types.diff
155155
git add .
156+
sed -i 's/ *"\*\*\/Tests\/",//' composer.json
156157
composer install -q --optimize-autoloader || composer install --optimize-autoloader
157158
SYMFONY_PATCH_TYPE_DECLARATIONS='force=2&php=8.4' php .github/patch-types.php
158-
git checkout src/Symfony/Contracts/Service/ResetInterface.php
159+
git checkout composer.json src/Symfony/Contracts/Service/ResetInterface.php
159160
SYMFONY_PATCH_TYPE_DECLARATIONS='force=2&php=8.4' php .github/patch-types.php # ensure the script is idempotent
160161
git checkout src/Symfony/Contracts/Service/ResetInterface.php
161162
git diff --exit-code

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717

1818
trait RuntimeLoaderProvider
1919
{
20+
/**
21+
* @return void
22+
*/
2023
protected function registerTwigRuntimeLoader(Environment $environment, FormRenderer $renderer)
2124
{
2225
$loader = $this->createMock(RuntimeLoaderInterface::class);

src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/MicroKernelTraitTest.php

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Psr\Log\NullLogger;
1616
use Symfony\Bundle\FrameworkBundle\Console\Application;
17-
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
1817
use Symfony\Component\Console\Attribute\AsCommand;
1918
use Symfony\Component\Console\Input\ArrayInput;
2019
use Symfony\Component\Console\Output\BufferedOutput;
@@ -186,27 +185,3 @@ public function testDefaultKernel()
186185
$this->assertSame('OK', $response->getContent());
187186
}
188187
}
189-
190-
abstract class MinimalKernel extends Kernel
191-
{
192-
use MicroKernelTrait;
193-
194-
private string $cacheDir;
195-
196-
public function __construct(string $cacheDir)
197-
{
198-
parent::__construct('test', false);
199-
200-
$this->cacheDir = sys_get_temp_dir().'/'.$cacheDir;
201-
}
202-
203-
public function getCacheDir(): string
204-
{
205-
return $this->cacheDir;
206-
}
207-
208-
public function getLogDir(): string
209-
{
210-
return $this->cacheDir;
211-
}
212-
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\FrameworkBundle\Tests\Kernel;
13+
14+
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
15+
use Symfony\Component\HttpKernel\Kernel;
16+
17+
abstract class MinimalKernel extends Kernel
18+
{
19+
use MicroKernelTrait;
20+
21+
private string $cacheDir;
22+
23+
public function __construct(string $cacheDir)
24+
{
25+
parent::__construct('test', false);
26+
27+
$this->cacheDir = sys_get_temp_dir().'/'.$cacheDir;
28+
}
29+
30+
public function getCacheDir(): string
31+
{
32+
return $this->cacheDir;
33+
}
34+
35+
public function getLogDir(): string
36+
{
37+
return $this->cacheDir;
38+
}
39+
}

src/Symfony/Component/Process/PhpProcess.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ public static function fromShellCommandline(string $command, ?string $cwd = null
5555
throw new LogicException(\sprintf('The "%s()" method cannot be called when using "%s".', __METHOD__, self::class));
5656
}
5757

58+
/**
59+
* @param (callable('out'|'err', string):void)|null $callback
60+
*/
5861
public function start(?callable $callback = null, array $env = []): void
5962
{
6063
if (null === $this->getCommandLine()) {

src/Symfony/Component/Process/PhpSubprocess.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ public static function fromShellCommandline(string $command, ?string $cwd = null
7878
throw new LogicException(\sprintf('The "%s()" method cannot be called when using "%s".', __METHOD__, self::class));
7979
}
8080

81+
/**
82+
* @param (callable('out'|'err', string):void)|null $callback
83+
*/
8184
public function start(?callable $callback = null, array $env = []): void
8285
{
8386
if (null === $this->getCommandLine()) {

0 commit comments

Comments
 (0)
0