Skip to content

Commit 1fdb01b

Browse files
committed
minor symfony#54890 [DependencyInjection] Improve error message when a class in not instantiable during auto-discovery (HMRDevil)
This PR was merged into the 7.2 branch. Discussion ---------- [DependencyInjection] Improve error message when a class in not instantiable during auto-discovery | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | Fix symfony#53651 | License | MIT See symfony#53651 Commits ------- 08ef880 change error msg
2 parents 9db6dea + 08ef880 commit 1fdb01b

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ private function createTypeNotFoundMessage(TypedReference $reference, string $la
631631
}
632632

633633
if ($r->isInterface() && !$alternatives) {
634-
$message .= ' Did you create a class that implements this interface?';
634+
$message .= ' Did you create an instantiable class that implements this interface?';
635635
}
636636
}
637637

src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ public function testTypeNotGuessableNoServicesFound()
245245
$pass->process($container);
246246
$this->fail('AutowirePass should have thrown an exception');
247247
} catch (AutowiringFailedException $e) {
248-
$this->assertSame('Cannot autowire service "a": argument "$collision" of method "Symfony\Component\DependencyInjection\Tests\Compiler\CannotBeAutowired::__construct()" references interface "Symfony\Component\DependencyInjection\Tests\Compiler\CollisionInterface" but no such service exists. Did you create a class that implements this interface?', (string) $e->getMessage());
248+
$this->assertSame('Cannot autowire service "a": argument "$collision" of method "Symfony\Component\DependencyInjection\Tests\Compiler\CannotBeAutowired::__construct()" references interface "Symfony\Component\DependencyInjection\Tests\Compiler\CollisionInterface" but no such service exists. Did you create an instantiable class that implements this interface?', (string) $e->getMessage());
249249
}
250250
}
251251

@@ -819,7 +819,7 @@ public function testInterfaceWithNoImplementationSuggestToWriteOne()
819819
$pass->process($container);
820820
$this->fail('AutowirePass should have thrown an exception');
821821
} catch (AutowiringFailedException $e) {
822-
$this->assertSame('Cannot autowire service "my_service": argument "$i" of method "Symfony\Component\DependencyInjection\Tests\Compiler\K::__construct()" references interface "Symfony\Component\DependencyInjection\Tests\Compiler\IInterface" but no such service exists. Did you create a class that implements this interface?', (string) $e->getMessage());
822+
$this->assertSame('Cannot autowire service "my_service": argument "$i" of method "Symfony\Component\DependencyInjection\Tests\Compiler\K::__construct()" references interface "Symfony\Component\DependencyInjection\Tests\Compiler\IInterface" but no such service exists. Did you create an instantiable class that implements this interface?', (string) $e->getMessage());
823823
}
824824
}
825825

0 commit comments

Comments
 (0)