Skip to content

Commit f3613a6

Browse files
committed
Fix type inspection for app.root service
1 parent 068e9c6 commit f3613a6

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Type/ServiceDynamicReturnTypeExtension.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ public function getTypeFromMethodCall(
5555
if ($methodReflection->getName() === 'get') {
5656
$service = $this->serviceMap->getService($serviceId);
5757
if ($service instanceof DrupalServiceDefinition) {
58+
// Work around Drupal misusing the SplString class for string
59+
// pseudo-services such as 'app.root'.
60+
// @see https://www.drupal.org/project/drupal/issues/3074585
61+
if ($service->getClass() === 'SplString') {
62+
return new StringType();
63+
}
5864
return new ObjectType($service->getClass() ?? $serviceId);
5965
}
6066
return $returnType;

0 commit comments

Comments
 (0)