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

Skip to content

Commit 7e21e06

Browse files
committed
[DependencyInjection] Support PHP 8.2 null type
1 parent 073f2df commit 7e21e06

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\FooObject;
3333
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\IntersectionConstructor;
3434
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\UnionConstructor;
35-
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\UnionConstructorWithTrue;
35+
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\UnionConstructorPHP82;
3636
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\Waldo;
3737
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\WaldoFoo;
3838
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\Wobble;
@@ -876,10 +876,14 @@ public function testUnionTypePassesWithTrue()
876876
{
877877
$container = new ContainerBuilder();
878878

879-
$container->register('union', UnionConstructorWithTrue::class)
880-
->setFactory([UnionConstructorWithTrue::class, 'create'])
879+
$container->register('unionTrue', UnionConstructorPHP82::class)
880+
->setFactory([UnionConstructorPHP82::class, 'create'])
881881
->setArguments([true]);
882882

883+
$container->register('unionNull', UnionConstructorPHP82::class)
884+
->setFactory([UnionConstructorPHP82::class, 'create'])
885+
->setArguments([null]);
886+
883887
(new CheckTypeDeclarationsPass(true))->process($container);
884888

885889
$this->addToAssertionCount(1);
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass;
44

5-
class UnionConstructorWithTrue
5+
class UnionConstructorPHP82
66
{
7-
public static function create(array|true $arg): static
7+
public static function create(null|true $arg): static
88
{
99
return new static(0);
1010
}

0 commit comments

Comments
 (0)