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

Skip to content
8000

Commit f3da69a

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

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/Compiler/ServiceAnnotationsPass.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ private function updateMethodArguments(Definition $definition, \ReflectionMethod
101101

102102
$onInvalid = $arg->getOnInvalid();
103103
$invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE;
104-
if ('ignore' == $onInvalid) {
104+
if ('ignore' === $onInvalid) {
105105
$invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE;
106-
} elseif ('null' == $onInvalid) {
106+
} elseif ('null' === $onInvalid) {
107107
$invalidBehavior = ContainerInterface::NULL_ON_INVALID_REFERENCE;
108108
}
109109

0 commit comments

Comments
 (0)
0