merged branch alexpods/patch-1 (PR #7864)

This PR was merged into the master branch.

Discussion
----------

Place hasArgument() check at the beginning of getArgument() method

If input definition doesn't have specified argument, then unnecessary operations will be executed ($arguments = is_int($name) ? array_values($this->arguments) : $this->arguments;)

Commits
-------

992c218 Place hasArgument() check at the beginning of getArgument() method
This commit is contained in:
Fabien Potencier 2013-04-29 09:12:08 +02:00
commit 2dfcc8d8aa
1 changed files with 2 additions and 2 deletions

View File

@ -153,12 +153,12 @@ class InputDefinition
*/
public function getArgument($name)
{
$arguments = is_int($name) ? array_values($this->arguments) : $this->arguments;
if (!$this->hasArgument($name)) {
throw new \InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
}
$arguments = is_int($name) ? array_values($this->arguments) : $this->arguments;
return $arguments[$name];
}