The 'config' variable is already used as an array expression less...

This commit is contained in:
Aarón Nieves Fernández 2015-09-29 18:57:23 +02:00 committed by Fabien Potencier
parent 36306ab7c6
commit f15d179fbd

View File

@ -58,7 +58,7 @@ class YamlFileLoader extends FileLoader
} }
try { try {
$config = $this->yamlParser->parse(file_get_contents($path)); $parsedConfig = $this->yamlParser->parse(file_get_contents($path));
} catch (ParseException $e) { } catch (ParseException $e) {
throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML.', $path), 0, $e); throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML.', $path), 0, $e);
} }
@ -67,16 +67,16 @@ class YamlFileLoader extends FileLoader
$collection->addResource(new FileResource($path)); $collection->addResource(new FileResource($path));
// empty file // empty file
if (null === $config) { if (null === $parsedConfig) {
return $collection; return $collection;
} }
// not an array // not an array
if (!is_array($config)) { if (!is_array($parsedConfig)) {
throw new \InvalidArgumentException(sprintf('The file "%s" must contain a YAML array.', $path)); throw new \InvalidArgumentException(sprintf('The file "%s" must contain a YAML array.', $path));
} }
foreach ($config as $name => $config) { foreach ($parsedConfig as $name => $config) {
if (isset($config['pattern'])) { if (isset($config['pattern'])) {
if (isset($config['path'])) { if (isset($config['path'])) {
throw new \InvalidArgumentException(sprintf('The file "%s" cannot define both a "path" and a "pattern" attribute. Use only "path".', $path)); throw new \InvalidArgumentException(sprintf('The file "%s" cannot define both a "path" and a "pattern" attribute. Use only "path".', $path));