Skip to content

Commit 594cdf6

Browse files
committed
1 parent 4981859 commit 594cdf6

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Symfony\Component\DependencyInjection\Definition;
2121
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
2222
use Symfony\Component\DependencyInjection\Exception\InvalidParameterTypeException;
23+
use Symfony\Component\DependencyInjection\Parameter;
2324
use Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag;
2425
use Symfony\Component\DependencyInjection\Reference;
2526
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\Bar;
@@ -28,6 +29,8 @@
2829
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\BarOptionalArgument;
2930
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\BarOptionalArgumentNotNull;
3031
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\Deprecated;
32+
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\ExpectsIntegerArgument;
33+
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\ExpectsIntegerArgumentWrapper;
3134
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\Foo;
3235
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\FooObject;
3336
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\IntersectionConstructor;
@@ -642,6 +645,27 @@ public function testProcessSuccessWhenExpressionReturnsObject()
642645
$this->addToAssertionCount(1);
643646
}
644647

648+
public function testErrorOnEvaluatingExpressionDoesNotStopTheProcess()
649+
{
650+
$container = new ContainerBuilder(new EnvPlaceholderParameterBag([
651+
'some_int' => '%env(SOME_INT)%',
652+
]));
653+
654+
$container
655+
->register('eia', ExpectsIntegerArgument::class)
656+
->setPublic(true)
657+
->setShared(false)
658+
->setFactory([ExpectsIntegerArgument::class, 'create'])
659+
->addArgument(new Parameter('some_int'));
660+
$container
661+
->register('eia_wrapper', ExpectsIntegerArgumentWrapper::class)
662+
->addArgument(new Expression('service("eia").instance()'));
663+
664+
(new CheckTypeDeclarationsPass(true))->process($container);
665+
666+
$this->addToAssertionCount(1);
667+
}
668+
645669
public function testProcessHandleMixedEnvPlaceholder()
646670
{
647671
$container = new ContainerBuilder(new EnvPlaceholderParameterBag([
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass;
6+
7+
final readonly class ExpectsIntegerArgument
8+
{
9+
public function __construct(public int $foo) {}
10+
11+
public static function create(int $foo): self
12+
{
13+
return new self($foo);
14+
}
15+
16+
public function instance(): self {
17+
return $this;
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass;
6+
7+
final readonly class ExpectsIntegerArgumentWrapper
8+
{
9+
public function __construct(public ExpectsIntegerArgument $b) {}
10+
}

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