Skip to content

Commit 63bcf2e

Browse files
committed
Added support for string concatenation
1 parent b1a2809 commit 63bcf2e

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

src/ServiceMap.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Lookyman\PHPStan\Symfony\Exception\XmlContainerNotExistsException;
88
use PhpParser\Node;
9+
use PhpParser\Node\Expr\BinaryOp\Concat;
910
use PhpParser\Node\Expr\ClassConstFetch;
1011
use PhpParser\Node\Name;
1112
use PhpParser\Node\Scalar\String_;
@@ -80,6 +81,13 @@ public static function getServiceIdFromNode(Node $node)
8081
return $serviceId;
8182
}
8283
}
84+
if ($node instanceof Concat) {
85+
$left = self::getServiceIdFromNode($node->left);
86+
$right = self::getServiceIdFromNode($node->right);
87+
if ($left !== null && $right !== null) {
88+
return \sprintf('%s%s', $left, $right);
89+
}
90+
}
8391
return \null;
8492
}
8593

tests/Rules/ContainerInterfaceUnknownServiceRuleTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ public function testGetUnknownService()
2828
'Service "Lookyman\PHPStan\Symfony\ServiceMap" is not registered in the container.',
2929
27,
3030
],
31+
[
32+
'Service "service.Lookyman\PHPStan\Symfony\ServiceMap" is not registered in the container.',
33+
39,
34+
],
3135
]);
3236
}
3337

tests/Rules/data/ExampleController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function getVariableService(string $serviceKey)
3636

3737
public function getConcatenatedService()
3838
{
39-
$service = $this->get('service.' . self::class);
39+
$service = $this->get('service.' . ServiceMap::class);
4040
$service->noMethod();
4141
}
4242

0 commit comments

Comments
 (0)