Permalink
Browse files

bug #29107 [DI] dont track classes/interfaces used to compute autowir…

…ing error messages (nicolas-grekas)

This PR was merged into the 3.4 branch.

Discussion
----------

[DI] dont track classes/interfaces used to compute autowiring error messages

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #29019
| License       | MIT
| Doc PR        | -

This will also improve DX since tracking these files is not needed at all.

Commits
-------

09a0c23 [DI] dont track classes/interfaces used to compute autowiring error messages
  • Loading branch information...
nicolas-grekas committed Nov 6, 2018
2 parents 3ed98de + 09a0c23 commit f898332fb56cda2e02e9bceae41babc0838e463e
@@ -452,7 +452,17 @@ private function createAutowiredDefinition($type)
private function createTypeNotFoundMessage(TypedReference $reference, $label)
{
if (!$r = $this->container->getReflectionClass($type = $reference->getType(), false)) {
$trackResources = $this->container->isTrackingResources();
$this->container->setResourceTracking(false);
try {
if ($r = $this->container->getReflectionClass($type = $reference->getType(), false)) {
$alternatives = $this->createTypeAlternatives($reference);
}
} finally {
$this->container->setResourceTracking($trackResources);
}
if (!$r) {
// either $type does not exist or a parent class does not exist
try {
$resource = new ClassExistenceResource($type, false);
@@ -465,7 +475,6 @@ private function createTypeNotFoundMessage(TypedReference $reference, $label)
$message = sprintf('has type "%s" but this class %s.', $type, $parentMsg ? sprintf('is missing a parent class (%s)', $parentMsg) : 'was not found');
} else {
$alternatives = $this->createTypeAlternatives($reference);
$message = $this->container->has($type) ? 'this service is abstract' : 'no such service exists';
$message = sprintf('references %s "%s" but %s.%s', $r->isInterface() ? 'interface' : 'class', $type, $message, $alternatives);
@@ -364,7 +364,7 @@ public function getReflectionClass($class, $throw = true)
try {
if (isset($this->classReflectors[$class])) {
$classReflector = $this->classReflectors[$class];
} elseif ($this->trackResources) {
} elseif (class_exists(ClassExistenceResource::class)) {
$resource = new ClassExistenceResource($class, false);
$classReflector = $resource->isFresh(0) ? false : new \ReflectionClass($class);
} else {

0 comments on commit f898332

Please sign in to comment.