Skip to content

[DependencyInjection] Fix tests on PHP 7.1 #45156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ services:
- { name: t, a: b }
autowire: true
autoconfigure: true
arguments: ['@bar', !tagged_iterator foo, !service { class: Baz }]
arguments: ['@bar', !tagged_iterator foo]
bar:
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo
public: true
tags:
- { name: t, a: b }
autowire: true
arguments: [null, !tagged_iterator foo, !service { class: Baz }]
arguments: [null, !tagged_iterator foo]
calls:
- [setFoo, ['@bar']]

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
->tag('t', ['a' => 'b'])
->bind(Foo::class, ref('bar'))
->bind('iterable $foo', tagged_iterator('foo'))
->bind('object $baz', inline('Baz'))
->public();

$s->set(Foo::class)->args([ref('bar')])->public();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

services:
service_container:
class: Symfony\Component\DependencyInjection\ContainerInterface
public: true
synthetic: true
App\BarService:
class: App\BarService
public: true
arguments: [!service { class: FooClass }]
Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo:
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo
public: true
tags:
- { name: t, a: b }
autowire: true
autoconfigure: true
arguments: ['@bar', !tagged_iterator foo, !service { class: Baz }]
bar:
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo
public: true
tags:
- { name: t, a: b }
autowire: true
arguments: [null, !tagged_iterator foo, !service { class: Baz }]
calls:
- [setFoo, ['@bar']]

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo;

return function (ContainerConfigurator $c) {
$c->import('basic.php');

$s = $c->services()->defaults()
->public()
->private()
->autoconfigure()
->autowire()
->tag('t', ['a' => 'b'])
->bind(Foo::class, ref('bar'))
->bind('iterable $foo', tagged_iterator('foo'))
->bind('object $baz', inline('Baz'))
->public();

$s->set(Foo::class)->args([ref('bar')])->public();
$s->set('bar', Foo::class)->call('setFoo')->autoconfigure(false);
};
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ public function provideConfig()
yield ['php7'];
yield ['anonymous'];
yield ['lazy_fqcn'];

// fixture uses PHP 7.2+ object typehint
if (70200 <= \PHP_VERSION_ID) {
yield ['inline_binding'];
}
}

public function testAutoConfigureAndChildDefinitionNotAllowed()
Expand Down