Skip to content

Commit d536a47

Browse files
authored
Merge pull request #19 from frenchcomp/master
To use PHP-DI 6.0 with the Symfony Bridge, with Symfony 3.3, 3.4 et 4+
2 parents 043c7eb + a4965bc commit d536a47

File tree

9 files changed

+27
-20
lines changed

9 files changed

+27
-20
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ composer.lock
22
composer.phar
33
vendor/*
44
.idea/*
5+
/phpunit.xml

.travis.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
language: php
22

33
php:
4-
- 5.5
5-
- 5.6
64
- 7.0
75
- 7.1
8-
- hhvm
6+
- 7.2
97

108
matrix:
119
include:
12-
- php: 5.5
10+
- php: 7.0
1311
env: dependencies=lowest
1412

1513
before_script:
1614
- composer install -n
1715
- if [ "$dependencies" = "lowest" ]; then composer update --prefer-lowest --prefer-stable -n; fi;
16+
17+
script:
18+
- vendor/bin/phpunit

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
}
1616
},
1717
"require": {
18-
"php": "~5.5|~7.0",
19-
"php-di/php-di": "^5.0",
20-
"symfony/dependency-injection": "^3.0",
21-
"symfony/http-kernel": "^3.0",
22-
"symfony/proxy-manager-bridge": "^3.0",
23-
"symfony/config": "^3.0"
18+
"php": "~7.0",
19+
"php-di/php-di": "~6.0",
20+
"symfony/dependency-injection": "~3.3||~4.0",
21+
"symfony/http-kernel": "~3.3||~4.0",
22+
"symfony/proxy-manager-bridge": "~3.3||~4.0",
23+
"symfony/config": "~3.3||~4.0"
2424
},
2525
"require-dev": {
2626
"phpunit/phpunit": "^4.8",

src/Kernel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
namespace DI\Bridge\Symfony;
1111

12-
use Interop\Container\ContainerInterface;
12+
use Psr\Container\ContainerInterface;
1313
use Symfony\Component\Debug\DebugClassLoader;
1414
use Symfony\Component\DependencyInjection\Compiler\CheckExceptionOnInvalidReferenceBehaviorPass;
1515
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -92,7 +92,7 @@ private function removeInvalidReferenceBehaviorPass(ContainerBuilder $container)
9292

9393
private function disableDebugClassLoader()
9494
{
95-
if (!class_exists('Symfony\Component\Debug\DebugClassLoader')) {
95+
if (!class_exists(DebugClassLoader::class)) {
9696
return;
9797
}
9898

src/SymfonyContainerBridge.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace DI\Bridge\Symfony;
1111

1212
use DI\NotFoundException;
13-
use Interop\Container\ContainerInterface;
13+
use Psr\Container\ContainerInterface;
1414
use Symfony\Component\DependencyInjection\Container as SymfonyContainer;
1515
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
1616
use Symfony\Component\DependencyInjection\ContainerInterface as SymfonyContainerInterface;
@@ -87,7 +87,7 @@ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE
8787
return $entry;
8888
} catch (NotFoundException $e) {
8989
if ($invalidBehavior === self::EXCEPTION_ON_INVALID_REFERENCE) {
90-
throw new ServiceNotFoundException($id);
90+
throw new ServiceNotFoundException($id, null, $e);
9191
}
9292
}
9393

tests/FunctionalTest/ContainerInteractionTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function phpdi_should_get_entries_from_symfony()
3636

3737
$phpdiContainer->set(
3838
'foo',
39-
\DI\object(Class1::class)
39+
\DI\create(Class1::class)
4040
->constructor(\DI\get('class2'))
4141
);
4242

@@ -69,7 +69,9 @@ public function phpdi_aliases_can_reference_symfony_entries()
6969
/** @var Container $phpdiContainer */
7070
$phpdiContainer = $container->getFallbackContainer();
7171

72-
$phpdiContainer->set('foo', \DI\get('class2'));
72+
$ref = \DI\get('class2');
73+
$ref->setName('foo');
74+
$phpdiContainer->set('foo', $ref);
7375

7476
$class2 = $container->get('foo');
7577

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
services:
22
class1:
33
class: DI\Bridge\Symfony\Test\FunctionalTest\Fixtures\Class1
4+
public: true
45
arguments: [ '@DI\\Bridge\\Symfony\\Test\\FunctionalTest\\Fixtures\\Class2' ]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
services:
22
class2:
33
class: DI\Bridge\Symfony\Test\FunctionalTest\Fixtures\Class2
4+
public: true

tests/UnitTest/SymfonyContainerBridgeTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@
1111

1212
use DI\Bridge\Symfony\SymfonyContainerBridge;
1313
use DI\ContainerBuilder;
14-
use Symfony\Component\DependencyInjection\ContainerInterface;
14+
use Psr\Container\ContainerInterface;
15+
use Symfony\Component\DependencyInjection\ContainerInterface as SfContainerInterface;
1516

1617
class SymfonyContainerBridgeTest extends \PHPUnit_Framework_TestCase
1718
{
1819
public function testHasFallback()
1920
{
2021
$wrapper = new SymfonyContainerBridge();
2122

22-
$fallback = $this->getMockForAbstractClass('Interop\Container\ContainerInterface');
23+
$fallback = $this->getMockForAbstractClass(ContainerInterface::class);
2324
$fallback->expects($this->once())
2425
->method('has')
2526
->with('foo')
@@ -34,7 +35,7 @@ public function testGetFallback()
3435
{
3536
$wrapper = new SymfonyContainerBridge();
3637

37-
$fallback = $this->getMockForAbstractClass('Interop\Container\ContainerInterface');
38+
$fallback = $this->getMockForAbstractClass(ContainerInterface::class);
3839
$fallback->expects($this->once())
3940
->method('get')
4041
->with('foo')
@@ -51,7 +52,7 @@ public function testGetNotFoundReturnNull()
5152

5253
$wrapper->setFallbackContainer(ContainerBuilder::buildDevContainer());
5354

54-
$this->assertNull($wrapper->get('foo', ContainerInterface::NULL_ON_INVALID_REFERENCE));
55+
$this->assertNull($wrapper->get('foo', SfContainerInterface::NULL_ON_INVALID_REFERENCE));
5556
}
5657

5758
/**

0 commit comments

Comments
 (0)