Skip to content

Commit 0b0542d

Browse files
bug symfony#25285 [DI] Throw an exception if Expression Language is not installed (sroze)
This PR was merged into the 3.4 branch. Discussion ---------- [DI] Throw an exception if Expression Language is not installed | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony#25277 | License | MIT | Doc PR | ø The [`PhpDumper` already has this check](https://github.com/symfony/symfony/blob/master/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php#L1688-L1690) but it is missing here. Commits ------- 75b21e9 Throw an exception is expression language is not installed
2 parents abd76ba + 75b21e9 commit 0b0542d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\DependencyInjection\Argument\ArgumentInterface;
1515
use Symfony\Component\DependencyInjection\ContainerInterface;
1616
use Symfony\Component\DependencyInjection\Definition;
17+
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
1718
use Symfony\Component\DependencyInjection\ExpressionLanguage;
1819
use Symfony\Component\DependencyInjection\Reference;
1920
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -155,6 +156,10 @@ private function getDefinitionId($id)
155156
private function getExpressionLanguage()
156157
{
157158
if (null === $this->expressionLanguage) {
159+
if (!class_exists(ExpressionLanguage::class)) {
160+
throw new RuntimeException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.');
161+
}
162+
158163
$providers = $this->container->getExpressionLanguageProviders();
159164
$this->expressionLanguage = new ExpressionLanguage(null, $providers, function ($arg) {
160165
if ('""' === substr_replace($arg, '', 1, -1)) {

0 commit comments

Comments
 (0)