8000 minor #21466 [DI] Remove usages of ClassExistenceResource (nicolas-gr… · symfony/dependency-injection@b09dd17 · GitHub
[go: up one dir, main page]

Skip to content

Commit b09dd17

Browse files
committed
minor #21466 [DI] Remove usages of ClassExistenceResource (nicolas-grekas)
This PR was merged into the 3.3-dev branch. Discussion ---------- [DI] Remove usages of ClassExistenceResource | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - As discussed in #21452 (see last comments) Commits ------- ec8f1ad453 [DI] Remove usages of ClassExistenceResource
2 parents cf0869d + 08ca7cc commit b09dd17

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Compiler/FactoryReturnTypePass.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\DependencyInjection\Compiler;
1313

14+
use Symfony\Component\Config\Resource\FileResource;
1415
use Symfony\Component\DependencyInjection\ContainerBuilder;
1516
use Symfony\Component\DependencyInjection\Definition;
1617
use Symfony\Component\DependencyInjection\Reference;
@@ -65,6 +66,9 @@ private function updateDefinition(ContainerBuilder $container, $id, Definition $
6566
if (is_string($factory)) {
6667
try {
6768
$m = new \ReflectionFunction($factory);
69+
if (false !== $m->getFileName() && file_exists($m->getFileName())) {
70+
$container->addResource(new FileResource($m->getFileName()));
71+
}
6872
} catch (\ReflectionException $e) {
6973
return;
7074
}

ContainerBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,7 @@ public function resolveServices($value)
10071007
if ('service_container' === $id = (string) $reference) {
10081008
$class = parent::class;
10091009
} elseif (!$this->hasDefinition($id) && ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $reference->getInvalidBehavior()) {
1010-
return null;
1010+
return;
10111011
} else {
10121012
$class = $parameterBag->resolveValue($this->findDefinition($id)->getClass());
10131013
}

0 commit comments

Comments
 (0)
0