Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1d7d564

Browse files
committed
bug #25137 Adding checks for the expression language (weaverryan)
This PR was merged into the 3.4 branch. Discussion ---------- Adding checks for the expression language | Q | A | ------------- | --- | Branch? | 4.0 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | none | License | MIT | Doc PR | not needed If you try to use the expression syntax in DI, this will drastically improve the error message :) Commits ------- 3502020 adding checks for the expression language
2 parents d5f0428 + 3502020 commit 1d7d564

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,10 @@ private function getArgumentsAsPhp(\DOMElement $node, $name, $file, $lowercase =
506506
$arguments[$key] = new Reference($arg->getAttribute('id'), $invalidBehavior);
507507
break;
508508
case 'expression':
509+
if (!class_exists(Expression::class)) {
510+
throw new \LogicException(sprintf('The type="expression" attribute cannot be used without the ExpressionLanguage component. Try running "composer require symfony/expression-language".'));
511+
}
512+
509513
$arguments[$key] = new Expression($arg->nodeValue);
510514
break;
511515
case 'collection':

src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,10 @@ private function resolveServices($value, $file, $isParameter = false)
775775
$value[$k] = $this->resolveServices($v, $file, $isParameter);
776776
}
777777
} elseif (is_string($value) && 0 === strpos($value, '@=')) {
778+
if (!class_exists(Expression::class)) {
779+
throw new \LogicException(sprintf('The "@=" expression syntax cannot be used without the ExpressionLanguage component. Try running "composer require symfony/expression-language".'));
780+
}
781+
778782
return new Expression(substr($value, 2));
779783
} elseif (is_string($value) && 0 === strpos($value, '@')) {
780784
if (0 === strpos($value, '@@')) {

0 commit comments

Comments
 (0)