removed irrelevant string case in XmlFileLoader

getAttribute() always returns a string
This commit is contained in:
Tobias Schultze 2012-11-05 18:21:19 +01:00 committed by Arnaud Le Blanc
parent 9ffe3de642
commit 94ec653818

View File

@ -73,10 +73,10 @@ class XmlFileLoader extends FileLoader
$this->parseRoute($collection, $node, $path); $this->parseRoute($collection, $node, $path);
break; break;
case 'import': case 'import':
$resource = (string) $node->getAttribute('resource'); $resource = $node->getAttribute('resource');
$type = (string) $node->getAttribute('type'); $type = $node->getAttribute('type');
$prefix = (string) $node->getAttribute('prefix'); $prefix = $node->getAttribute('prefix');
$hostnamePattern = (string) $node->getAttribute('hostname-pattern'); $hostnamePattern = $node->getAttribute('hostname-pattern');
$defaults = array(); $defaults = array();
$requirements = array(); $requirements = array();
@ -89,13 +89,13 @@ class XmlFileLoader extends FileLoader
switch ($n->tagName) { switch ($n->tagName) {
case 'default': case 'default':
$defaults[(string) $n->getAttribute('key')] = trim((string) $n->nodeValue); $defaults[$n->getAttribute('key')] = trim($n->nodeValue);
break; break;
case 'requirement': case 'requirement':
$requirements[(string) $n->getAttribute('key')] = trim((string) $n->nodeValue); $requirements[$n->getAttribute('key')] = trim($n->nodeValue);
break; break;
case 'option': case 'option':
$options[(string) $n->getAttribute('key')] = trim((string) $n->nodeValue); $options[$n->getAttribute('key')] = trim($n->nodeValue);
break; break;
default: default:
throw new \InvalidArgumentException(sprintf('Unable to parse tag "%s"', $n->tagName)); throw new \InvalidArgumentException(sprintf('Unable to parse tag "%s"', $n->tagName));
@ -142,22 +142,22 @@ class XmlFileLoader extends FileLoader
switch ($node->tagName) { switch ($node->tagName) {
case 'default': case 'default':
$defaults[(string) $node->getAttribute('key')] = trim((string) $node->nodeValue); $defaults[$node->getAttribute('key')] = trim((string) $node->nodeValue);
break; break;
case 'option': case 'option':
$options[(string) $node->getAttribute('key')] = trim((string) $node->nodeValue); $options[$node->getAttribute('key')] = trim((string) $node->nodeValue);
break; break;
case 'requirement': case 'requirement':
$requirements[(string) $node->getAttribute('key')] = trim((string) $node->nodeValue); $requirements[$node->getAttribute('key')] = trim((string) $node->nodeValue);
break; break;
default: default:
throw new \InvalidArgumentException(sprintf('Unable to parse tag "%s"', $node->tagName)); throw new \InvalidArgumentException(sprintf('Unable to parse tag "%s"', $node->tagName));
} }
} }
$route = new Route((string) $definition->getAttribute('pattern'), $defaults, $requirements, $options, (string) $definition->getAttribute('hostname-pattern')); $route = new Route($definition->getAttribute('pattern'), $defaults, $requirements, $options, $definition->getAttribute('hostname-pattern'));
$collection->add((string) $definition->getAttribute('id'), $route); $collection->add($definition->getAttribute('id'), $route);
} }
/** /**