8000 Merge branch '6.4' into 7.0 · symfony/symfony@ce5447b · GitHub
[go: up one dir, main page]

Skip to content

Commit ce5447b

Browse files
committed
Merge branch '6.4' into 7.0
* 6.4: Make more nullable types explicit Add more explicit nullable types for default null values
2 parents ea80120 + db4f6ba commit ce5447b

File tree

42 files changed

+90
-70
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+90
-70
lines changed

src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/ConfigurationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ public function testBaselineFileWriteError()
525525
$this->expectException(\ErrorException::class);
526526
$this->expectExceptionMessageMatches('/[Ff]ailed to open stream: Permission denied/');
527527

528-
set_error_handler(static function (int $errno, string $errstr, string $errfile = null, int $errline = null): bool {
528+
set_error_handler(static function (int $errno, string $errstr, ?string $errfile = null, ?int $errline = null): bool {
529529
if ($errno & (E_WARNING | E_WARNING)) {
530530
throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
531531
}

src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
use Symfony\Component\DependencyInjection\Tests\Fixtures\BarInterface;
3535
use Symfony\Component\DependencyInjection\Tests\Fixtures\CaseSensitiveClass;
3636
use Symfony\Component\DependencyInjection\Tests\Fixtures\includes\FooVariadic;
37+
use Symfony\Component\DependencyInjection\Tests\Fixtures\OptionalParameter;
3738
use Symfony\Component\DependencyInjection\Tests\Fixtures\WithTarget;
3839
use Symfony\Component\DependencyInjection\Tests\Fixtures\WithTargetAnonymous;
3940
use Symfony\Component\DependencyInjection\TypedReference;
@@ -399,6 +400,9 @@ public function testResolveParameter()
399400
$this->assertEquals(Foo::class, $container->getDefinition('bar')->getArgument(0));
400401
}
401402

403+
/**
404+
* @group legacy
405+
*/
402406
public function testOptionalParameter()
403407
{
404408
$container = new ContainerBuilder();

src/Symfony/Component/DependencyInjection/Tests/Fixtures/Bar.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ class Bar implements BarInterface
1515
{
1616
public $quz;
1717

18-
public function __construct($quz = null, \NonExistent $nonExistent = null, BarInterface $decorated = null, array $foo = [], iterable $baz = [])
18+
public function __construct($quz = null, ?\NonExistent $nonExistent = null, ?BarInterface $decorated = null, array $foo = [], iterable $baz = [])
1919
{
2020
$this->quz = $quz;
2121
}
2222

23-
public static function create(\NonExistent $nonExistent = null, $factory = null)
23+
public static function create(?\NonExistent $nonExistent = null, $factory = null)
2424
{
2525
}
2626

src/Symfony/Component/DependencyInjection/Tests/Fixtures/CheckTypeDeclarationsPass/BarMethodCall.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function setFoosVariadic(Foo $foo, Foo ...$foos)
2020
$this->foo = $foo;
2121
}
2222

23-
public function setFoosOptional(Foo $foo, Foo $fooOptional = null)
23+
public function setFoosOptional(Foo $foo, ?Foo $fooOptional = null)
2424
{
2525
$this->foo = $foo;
2626
}

src/Symfony/Component/DependencyInjection/Tests/Fixtures/CheckTypeDeclarationsPass/BarOptionalArgument.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class BarOptionalArgument
66
{
77
public $foo;
88

9-
public function __construct(\stdClass $foo = null)
9+
public function __construct(?\stdClass $foo = null)
1010
{
1111
$this->foo = $foo;
1212
}

src/Symfony/Component/DependencyInjection/Tests/Fixtures/CheckTypeDeclarationsPass/Foo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public static function createBar()
99
return new Bar(new \stdClass());
1010
}
1111

12-
public static function createBarArguments(\stdClass $stdClass, \stdClass $stdClassOptional = null)
12+
public static function createBarArguments(\stdClass $stdClass, ?\stdClass $stdClassOptional = null)
1313
{
1414
return new Bar($stdClass);
1515
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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\Component\DependencyInjection\Tests\Fixtures;
13+
14+
use Symfony\Component\DependencyInjection\Tests\Compiler\A;
15+
use Symfony\Component\DependencyInjection\Tests\Compiler\CollisionInterface;
16+
use Symfony\Component\DependencyInjection\Tests\Compiler\Foo;
17+
18+
class OptionalParameter
19+
{
20+
public function __construct(?CollisionInterface $c = null, A $a, ?Foo $f = null)
21+
{
22+
}
23+
}

src/Symfony/Component/DependencyInjection/Tests/Fixtures/Prototype/Foo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#[When(env: 'dev')]
99
class Foo implements FooInterface, Sub\BarInterface
1010
{
11-
public function __construct($bar = null, iterable $foo = null, object $baz = null)
11+
public function __construct($bar = null, ?iterable $foo = null, ?object $baz = null)
1212
{
1313
}
1414

src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/autowiring_classes.php

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public function __construct(A $a, DInterface $d)
106106

107107
class E
108108
{
109-
public function __construct(D $d = null)
109+
public function __construct(?D $d = null)
110110
{
111111
}
112112
}
@@ -162,13 +162,6 @@ public function __construct(Dunglas $j, Dunglas $k)
162162
}
163163
}
164164

165-
class OptionalParameter
166-
{
167-
public function __construct(CollisionInterface $c = null, A $a, Foo $f = null)
168-
{
169-
}
170-
}
171-
172165
class BadTypeHintedArgument
173166
{
174167
public function __construct(Dunglas $k, NotARealClass $r)
@@ -202,7 +195,7 @@ public function __construct(A $k, $foo, Dunglas $dunglas, array $bar)
202195

203196
class MultipleArgumentsOptionalScalar
204197
{
205-
public function __construct(A $a, $foo = 'default_val', Lille $lille = null)
198+
public function __construct(A $a, $foo = 'default_val', ?Lille $lille = null)
206199
{
207200
}
208201
}
@@ -226,7 +219,7 @@ public function __construct(
226219
*/
227220
class ClassForResource
228221
{
229-
public function __construct($foo, Bar $bar = null)
222+
public function __construct($foo, ?Bar $bar = null)
230223
{
231224
}
232225

@@ -345,7 +338,7 @@ public function setBar()
345338
{
346339
}
347340

348-
public function setOptionalNotAutowireable(NotARealClass $n = null)
341+
public function setOptionalNotAutowireable(?NotARealClass $n = null)
349342
{
350343
}
351344

@@ -392,7 +385,7 @@ class DecoratorImpl implements DecoratorInterface
392385

393386
class Decorated implements DecoratorInterface
394387
{
395-
public function __construct($quz = null, \NonExistent $nonExistent = null, DecoratorInterface $decorated = null, array $foo = [])
388+
public function __construct($quz = null, ?\NonExistent $nonExistent = null, ?DecoratorInterface $decorated = null, array $foo = [])
396389
{
397390
}
398391
}

src/Symfony/Component/ErrorHandler/Tests/Fixtures/ClassWithAnnotatedParameters.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ public function fooMethod(string $foo)
1414
/**
1515
* @param string $bar parameter not implemented yet
1616
*/
17-
public function barMethod(/* string $bar = null */)
17+
public function barMethod(/* ?string $bar = null */)
1818
{
1919
}
2020

2121
/**
2222
* @param Quz $quz parameter not implemented yet
2323
*/
24-
public function quzMethod(/* Quz $quz = null */)
24+
public function quzMethod(/* ?Quz $quz = null */)
2525
{
2626
}
2727

src/Symfony/Component/Filesystem/Tests/Fixtures/MockStream/MockStream.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class MockStream
2828
* @param string|null $opened_path If the path is opened successfully, and STREAM_USE_PATH is set in options,
2929
* opened_path should be set to the full path of the file/resource that was actually opened
3030
*/
31-
public function stream_open(string $path, string $mode, int $options, string &$opened_path = null): bool
31+
public function stream_open(string $path, string $mode, int $options, ?string &$opened_path = null): bool
3232
{
3333
return true;
3434
}

src/Symfony/Component/Form/Tests/Fixtures/CustomArrayObject.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class CustomArrayObject implements \ArrayAccess, \IteratorAggregate, \Countable
1919
{
2020
private array $array;
2121

22-
public function __construct(array $array = null)
22+
public function __construct(?array $array = null)
2323
{
2424
$this->array = $array ?: [];
2525
}

src/Symfony/Component/Form/Tests/Fixtures/FixedTranslator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function __construct(array $translations)
2222
$this->translations = $translations;
2323
}
2424

25-
public function trans(string $id, array $parameters = [], string $domain = null, string $locale = null): string
25+
public function trans(string $id, array $parameters = [], ?string $domain = null, ?string $locale = null): string
2626
{
2727
return $this->translations[$id] ?? $id;
2828
}

src/Symfony/Component/HttpKernel/Tests/Fixtures/DataCollector/CloneVarDataCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function __construct($varToClone)
2525
$this->varToClone = $varToClone;
2626
}
2727

28-
public function collect(Request $request, Response $response, \Throwable $exception = null): void
28+
public function collect(Request $request, Response $response, ?\Throwable $exception = null): void
2929
{
3030
$this->data = $this->cloneVar($this->varToClone);
3131
}

src/Symfony/Component/Messenger/Handler/BatchHandlerInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ interface BatchHandlerInterface
2323
* @return mixed The number of pending messages in the batch if $ack is not null,
2424
* the result from handling the message otherwise
2525
*/
26-
// public function __invoke(object $message, Acknowledger $ack = null): mixed;
26+
// public function __invoke(object $message, ?Acknowledger $ack = null): mixed;
2727

2828
/**
2929
* Flushes any pending buffers.

src/Symfony/Component/Notifier/Bridge/Esendex/CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ CHANGELOG
2121

2222
* The bridge is not marked as `@experimental` anymore
2323
* [BC BREAK] Change signature of `EsendexTransport::__construct()` method from:
24-
`public function __construct(string $token, string $accountReference, string $from, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null)`
24+
`public function __construct(string $token, string $accountReference, string $from, ?HttpClientInterface $client = null, ?EventDispatcherInterface $dispatcher = null)`
2525
to:
26-
`public function __construct(string $email, string $password, string $accountReference, string $from, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null)`
26+
`public function __construct(string $email, string $password, string $accountReference, string $from, ?HttpClientInterface $client = null, ?EventDispatcherInterface $dispatcher = null)`
2727

2828
5.2.0
2929
-----

src/Symfony/Component/Notifier/Bridge/GoogleChat/CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ CHANGELOG
1717
* The bridge is not marked as `@experimental` anymore
1818
* [BC BREAK] Remove `GoogleChatTransport::setThreadKey()` method, this parameter should now be provided via the constructor,
1919
which has changed from:
20-
`__construct(string $space, string $accessKey, string $accessToken, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null)`
20+
`__construct(string $space, string $accessKey, string $accessToken, ?HttpClientInterface $client = null, ?EventDispatcherInterface $dispatcher = null)`
2121
to:
22-
`__construct(string $space, string $accessKey, string $accessToken, string $threadKey = null, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null)`
22+
`__construct(string $space, string $accessKey, string $accessToken, ?string $threadKey = null, ?HttpClientInterface $client = null, ?EventDispatcherInterface $dispatcher = null)`
2323
* [BC BREAK] Rename the parameter `threadKey` to `thread_key` in DSN
2424

2525
5.2.0

src/Symfony/Component/Notifier/Bridge/Mattermost/CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ CHANGELOG
66

77
* The bridge is not marked as `@experimental` anymore
88
* [BC BREAK] Change signature of `MattermostTransport::__construct()` method from:
9-
`public function __construct(string $token, string $channel, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null, string $path = null)`
9+
`public function __construct(string $token, string $channel, ?HttpClientInterface $client = null, ?EventDispatcherInterface $dispatcher = null, ?string $path = null)`
1010
to:
11-
`public function __construct(string $token, string $channel, ?string $path = null, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null)`
11+
`public function __construct(string $token, string $channel, ?string $path = null, ?HttpClientInterface $client = null, ?EventDispatcherInterface $dispatcher = null)`
1212

1313
5.1.0
1414
-----

src/Symfony/Component/PropertyAccess/Tests/Fixtures/NonTraversableArrayObject.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class NonTraversableArrayObject implements \ArrayAccess, \Countable
1919
{
2020
private $array;
2121

22-
public function __construct(array $array = null)
22+
public function __construct(?array $array = null)
2323
{
2424
$this->array = $array ?: [];
2525
}

src/Symfony/Component/PropertyAccess/Tests/Fixtures/TraversableArrayObject.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class TraversableArrayObject implements \ArrayAccess, \IteratorAggregate, \Count
1919
{
2020
private $array;
2121

22-
public function __construct(array $array = null)
22+
public function __construct(?array $array = null)
2323
{
2424
$this->array = $array ?: [];
2525
}

src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ private function getMutatorMethod(string $class, string $property): ?array
640640
continue;
641641
}
642642

643-
// Parameter can be optional to allow things like: method(array $foo = null)
643+
// Parameter can be optional to allow things like: method(?array $foo = null)
644644
if ($reflectionMethod->getNumberOfParameters() >= 1) {
645645
return [$reflectionMethod, $prefix];
646646
}

src/Symfony/Component/PropertyInfo/Tests/Fixtures/Dummy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public function getA()
194194
*
195195
* @param ParentDummy|null $parent
196196
*/
197-
public function setB(ParentDummy $parent = null)
197+
public function setB(?ParentDummy $parent = null)
198198
{
199199
}
200200

src/Symfony/Component/Routing/Tests/Fixtures/RedirectableUrlMatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*/
2020
class RedirectableUrlMatcher extends UrlMatcher implements RedirectableUrlMatcherInterface
2121
{
22-
public function redirect(string $path, string $route, string $scheme = null): array
22+
public function redirect(string $path, string $route, ?string $scheme = null): array
2323
{
2424
return [
2525
'_controller' => 'Some controller reference...',

src/Symfony/Component/Serializer/Tests/Fixtures/AbstractNormalizerDummy.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,20 @@ public function getAllowedAttributes(string|object $classOrObject, array $contex
3030
return parent::getAllowedAttributes($classOrObject, $context, $attributesAsString);
3131
}
3232

33-
public function normalize(mixed $object, string $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
33+
public function normalize(mixed $object, ?string $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
3434
{
3535
}
3636

37-
public function supportsNormalization(mixed $data, string $format = null, array $context = []): bool
37+
public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool
3838
{
3939
return true;
4040
}
4141

42-
public function denormalize(mixed $data, string $type, string $format = null, array $context = []): mixed
42+
public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed
4343
{
4444
}
4545

46-
public function supportsDenormalization(mixed $data, string $type, string $format = null, array $context = []): bool
46+
public function supportsDenormalization(mixed $data, string $type, ?string $format = null, array $context = []): bool
4747
{
4848
return true;
4949
}

src/Symfony/Component/Serializer/Tests/Fixtures/DenormalizableDummy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
class DenormalizableDummy implements DenormalizableInterface
1818
{
19-
public function denormalize(DenormalizerInterface $denormalizer, array|string|int|float|bool $data, string $format = null, array $context = []): void
19+
public function denormalize(DenormalizerInterface $denormalizer, array|string|int|float|bool $data, ?string $format = null, array $context = []): void
2020
{
2121
}
2222
}

src/Symfony/Component/Serializer/Tests/Fixtures/Dummy.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Dummy implements NormalizableInterface, DenormalizableInterface
2323
public $baz;
2424
public $qux;
2525

26-
public function normalize(NormalizerInterface $normalizer, string $format = null, array $context = []): array|string|int|float|bool
26+
public function normalize(NormalizerInterface $normalizer, ?string $format = null, array $context = []): array|string|int|float|bool
2727
{
2828
return [
2929
'foo' => $this->foo,
@@ -33,7 +33,7 @@ public function normalize(NormalizerInterface $normalizer, string $format = null
3333
];
3434
}
3535

36-
public function denormalize(DenormalizerInterface $denormalizer, array|string|int|float|bool $data, string $format = null, array $context = []): void
36+
public function denormalize(DenormalizerInterface $denormalizer, array|string|int|float|bool $data, ?string $format = null, array $context = []): void
3737
{
3838
$this->foo = $data['foo'];
3939
$this->bar = $data['bar'];

src/Symfony/Component/Serializer/Tests/Fixtures/DummyString.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class DummyString implements DenormalizableInterface
2222
/** @var string $value */
2323
public $value;
2424

25-
public function denormalize(DenormalizerInterface $denormalizer, $data, string $format = null, array $context = []): void
25+
public function denormalize(DenormalizerInterface $denormalizer, $data, ?string $format = null, array $context = []): void
2626
{
2727
$this->value = $data;
2828
}

src/Symfony/Component/Serializer/Tests/Fixtures/EnvelopeNormalizer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class EnvelopeNormalizer implements NormalizerInterface
2020
{
2121
private $serializer;
2222

23-
public function normalize($envelope, string $format = null, array $context = []): array
23+
public function normalize($envelope, ?string $format = null, array $context = []): array
2424
{
2525
$xmlContent = $this->serializer->serialize($envelope->message, 'xml');
2626

@@ -38,7 +38,7 @@ public function getSupportedTypes(?string $format): array
3838
];
3939
}
4040

41-
public function supportsNormalization($data, string $format = null, array $context = []): bool
41+
public function supportsNormalization($data, ?string $format = null, array $context = []): bool
4242
{
4343
return $data instanceof EnvelopeObject;
4444
}

0 commit comments

Comments
 (0)
0