Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1d7d564

Browse filesBrowse 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
Copy full SHA for 1d7d564

File tree

2 files changed

+8
-0
lines changed
Filter options

2 files changed

+8
-0
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php
+4Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php
+4Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.