Skip to content

Commit 400acf6

Browse files
committed
Detect invalid service in conditionalTags
1 parent e356a65 commit 400acf6

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/DependencyInjection/ConditionalTagsExtension.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ public function beforeCompile(): void
1111
$builder = $this->getContainerBuilder();
1212

1313
foreach ($config as $type => $tags) {
14-
foreach ($builder->findByType($type) as $service) {
14+
$services = $builder->findByType($type);
15+
if (count($services) === 0) {
16+
throw new \PHPStan\ShouldNotHappenException(sprintf('No services of type "%s" found.', $type));
17+
}
18+
foreach ($services as $service) {
1519
foreach ($tags as $tag => $parameter) {
1620
if ((bool) $parameter) {
1721
$service->addTag($tag);

0 commit comments

Comments
 (0)