Skip to content
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

Remove deprecated warning on DebugClassLoader #22

Closed
wants to merge 11 commits into from
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ composer.phar
vendor/*
.idea/*
/phpunit.xml
var/cache/*
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
language: php

php:
- 7.0
- 7.1
- 7.2
- 7.3
- 7.4

matrix:
include:
- php: 7.0
- php: 7.2
env: dependencies=lowest

before_script:
Expand Down
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
}
},
"require": {
"php": "~7.0",
"php": "~7.2",
"php-di/php-di": "~6.0",
"symfony/dependency-injection": "~3.3||~4.0",
"symfony/http-kernel": "~3.3||~4.0",
"symfony/proxy-manager-bridge": "~3.3||~4.0",
"symfony/config": "~3.3||~4.0"
"symfony/dependency-injection": "~3.4||~4.4||~5.1",
"symfony/http-kernel": "~3.4||~4.4||~5.1",
"symfony/proxy-manager-bridge": "~3.4||~4.4||~5.1",
"symfony/config": "~3.4||~4.4||~5.1"
},
"require-dev": {
"phpunit/phpunit": "^4.8",
"symfony/filesystem": "^3.0",
"symfony/yaml": "^3.0",
"symfony/debug": "^3.0"
"symfony/filesystem": "~3.4||~4.4||~5.1",
"symfony/yaml": "~3.4||~4.4||~5.1",
"symfony/error-handler": "~3.4||~4.4||~5.1"
}
}
31 changes: 21 additions & 10 deletions src/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
namespace DI\Bridge\Symfony;

use Psr\Container\ContainerInterface;
use Symfony\Component\Debug\DebugClassLoader;
use Symfony\Component\Debug\DebugClassLoader as LegacyDebugClassLoader;
use Symfony\Component\DependencyInjection\Compiler\CheckExceptionOnInvalidReferenceBehaviorPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\ErrorHandler\DebugClassLoader;

/**
* Customization of Symfony's kernel to setup PHP-DI.
Expand Down Expand Up @@ -78,25 +79,35 @@ protected function initializeContainer()
private function removeInvalidReferenceBehaviorPass(ContainerBuilder $container)
{
$passConfig = $container->getCompilerPassConfig();
$compilationPasses = $passConfig->getRemovingPasses();

foreach ($compilationPasses as $i => $pass) {
if ($pass instanceof CheckExceptionOnInvalidReferenceBehaviorPass) {
unset($compilationPasses[$i]);
break;
$compilationPassRemover = static function (array $compilationPasses): array {
foreach ($compilationPasses as $i => $pass) {
if ($pass instanceof CheckExceptionOnInvalidReferenceBehaviorPass) {
unset($compilationPasses[$i]);
break;
}
}
}

$passConfig->setRemovingPasses($compilationPasses);
return $compilationPasses;
};

$passConfig->setRemovingPasses($compilationPassRemover($passConfig->getRemovingPasses()));
$passConfig->setAfterRemovingPasses($compilationPassRemover($passConfig->getAfterRemovingPasses()));
}

private function disableDebugClassLoader()
{
if (!class_exists(DebugClassLoader::class)) {
if (class_exists(DebugClassLoader::class)) {
DebugClassLoader::disable();

return;
}

if (!class_exists(LegacyDebugClassLoader::class)) {
return;
}

DebugClassLoader::disable();
LegacyDebugClassLoader::disable();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/FunctionalTest/ContainerAwareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/**
* @coversNothing
*/
class ContainerAwareInterfaceTest extends AbstractFunctionalTest
class ContainerAwareTest extends AbstractFunctionalTest
{
/**
* @link https://github.com/PHP-DI/Symfony-Bridge/issues/2
Expand Down
2 changes: 1 addition & 1 deletion tests/FunctionalTest/Fixtures/config/class1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ services:
class1:
class: DI\Bridge\Symfony\Test\FunctionalTest\Fixtures\Class1
public: true
arguments: [ '@DI\\Bridge\\Symfony\\Test\\FunctionalTest\\Fixtures\\Class2' ]
arguments: [ '@DI\Bridge\Symfony\Test\FunctionalTest\Fixtures\Class2' ]