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 f61962d

Browse filesBrowse files
committed
Adding strict checking, and clear error handling
1 parent c6ac896 commit f61962d
Copy full SHA for f61962d

File tree

2 files changed

+7
-2
lines changed
Filter options

2 files changed

+7
-2
lines changed

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

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

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