definitions are valid objects

This commit is contained in:
Christian Flothmann 2019-11-22 13:53:53 +01:00
parent bfae515d52
commit 0acaa5cfb3
3 changed files with 28 additions and 0 deletions

View File

@ -152,6 +152,10 @@ final class CheckTypeDeclarationsPass extends AbstractRecursivePass
return;
}
if ('object' === $type) {
return;
}
if (is_a($class, $type, true)) {
return;
}

View File

@ -15,12 +15,14 @@ use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
use Symfony\Component\DependencyInjection\Compiler\CheckTypeDeclarationsPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\Bar;
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\BarMethodCall;
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\BarOptionalArgument;
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\BarOptionalArgumentNotNull;
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\Foo;
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\FooObject;
/**
* @author Nicolas Grekas <p@tchwork.com>
@ -390,6 +392,18 @@ class CheckTypeDeclarationsPassTest extends TestCase
$this->addToAssertionCount(1);
}
public function testProcessSuccessWhenPassingDefintionForObjectType()
{
$container = new ContainerBuilder();
$container->register('foo_object', FooObject::class)
->addArgument(new Definition(Foo::class));
(new CheckTypeDeclarationsPass(true))->process($container);
$this->addToAssertionCount(1);
}
public function testProcessFactory()
{
$container = new ContainerBuilder();

View File

@ -0,0 +1,10 @@
<?php
namespace Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass;
class FooObject
{
public function __construct(object $foo)
{
}
}