Skip to content

Commit f94e3aa

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

File tree

3 files changed

+23
-14
lines changed

3 files changed

+23
-14
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, 'createTrue'])
881881
->setArguments([true]);
882882

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

885889
$this->addToAssertionCount(1);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass;
4+
5+
class UnionConstructorPHP82
6+
{
7+
public static function createTrue(array|true $arg): static
8+
{
9+
return new static(0);
10+
}
11+
12+
public static function createNull(null $arg): static
13+
{
14+
return new static(0);
15+
}
16+
}

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

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

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