|
29 | 29 | use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\Deprecated;
|
30 | 30 | use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\Foo;
|
31 | 31 | use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\FooObject;
|
| 32 | +use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\IntersectionConstructor; |
32 | 33 | use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\UnionConstructor;
|
33 | 34 | use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\Waldo;
|
| 35 | +use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\WaldoFoo; |
34 | 36 | use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\Wobble;
|
35 | 37 | use Symfony\Component\ExpressionLanguage\Expression;
|
36 | 38 |
|
@@ -953,4 +955,37 @@ public function testReferencePassesMixed()
|
953 | 955 |
|
954 | 956 | $this->addToAssertionCount(1);
|
955 | 957 | }
|
| 958 | + |
| 959 | + /** |
| 960 | + * @requires PHP 8.1 |
| 961 | + */ |
| 962 | + public function testIntersectionTypePassesWithReference() |
| 963 | + { |
| 964 | + $container = new ContainerBuilder(); |
| 965 | + |
| 966 | + $container->register('foo', WaldoFoo::class); |
| 967 | + $container->register('intersection', IntersectionConstructor::class) |
| 968 | + ->setArguments([new Reference('foo')]); |
| 969 | + |
| 970 | + (new CheckTypeDeclarationsPass(true))->process($container); |
| 971 | + |
| 972 | + $this->addToAssertionCount(1); |
| 973 | + } |
| 974 | + |
| 975 | + /** |
| 976 | + * @requires PHP 8.1 |
| 977 | + */ |
| 978 | + public function testIntersectionTypeFailsWithReference() |
| 979 | + { |
| 980 | + $container = new ContainerBuilder(); |
| 981 | + |
| 982 | + $container->register('waldo', Waldo::class); |
| 983 | + $container->register('intersection', IntersectionConstructor::class) |
| 984 | + ->setArguments([new Reference('waldo')]); |
| 985 | + |
| 986 | + $this->expectException(InvalidArgumentException::class); |
| 987 | + $this->expectExceptionMessage('Invalid definition for service "intersection": argument 1 of "Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CheckTypeDeclarationsPass\\IntersectionConstructor::__construct()" accepts "Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\Foo&Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\WaldoInterface", "Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\Waldo" passed.'); |
| 988 | + |
| 989 | + (new CheckTypeDeclarationsPass(true))->process($container); |
| 990 | + } |
956 | 991 | }
|
0 commit comments