8000 Adding strict checking, and clear error handling · symfony/symfony@f61962d · GitHub
[go: up one dir, main page]

Skip to content

Commit f61962d

Browse files
committed
Adding strict checking, and clear error handling
1 parent c6ac896 commit f61962d

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/Symfony/Component/DependencyInjection/Annotation/Argument.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ public function getOnInvalid()
8989

9090
public function setOnInvalid($onInvalid)
9191
{
92+
$validOptions = array('exception', 'ignore', 'null');
93+
if (!in_array($onInvalid, $validOptions, true)) {
94+
throw new \InvalidArgumentException(sprintf('Invalid onInvalid property "%s" set on annotation "%s. Expected on of: %s', $onInvalid, get_class($this), implode(', ', $validOptions)));
95+
};
96+
9297
$this->onInvalid = $onInvalid;
9398
}
9499

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,9 +466,9 @@ private function getArgumentsAsPhp(\DOMElement $node, $name, $lowercase = true)
466466

467467
$onInvalid = $arg->getAttribute('on-invalid');
468468
$invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE;
469-
if ('ignore' == $onInvalid) {
469+
if ('ignore' === $onInvalid) {
470470
$invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE;
471-
} elseif ('null' == $onInvalid) {
471+
} elseif ('null' === $onInvalid) {
472472
$invalidBehavior = ContainerInterface::NULL_ON_INVALID_REFERENCE;
473473
}
474474

0 commit comments

Comments
 (0)
0