From 6f79a378d56101516ad379307794e4ada0a76caf Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Thu, 8 Sep 2016 00:43:29 +0200 Subject: [PATCH] #6003 removed useless method parameter count checking duplication --- lib/Doctrine/ORM/EntityRepository.php | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/lib/Doctrine/ORM/EntityRepository.php b/lib/Doctrine/ORM/EntityRepository.php index 00e53c341..a3fcf0aff 100644 --- a/lib/Doctrine/ORM/EntityRepository.php +++ b/lib/Doctrine/ORM/EntityRepository.php @@ -310,22 +310,10 @@ class EntityRepository implements ObjectRepository, Selectable $fieldName = lcfirst(\Doctrine\Common\Util\Inflector::classify($by)); - if ($this->_class->hasField($fieldName) || $this->_class->hasAssociation($fieldName)) { - switch ($argsCount) { - case 1: - return $this->$method(array($fieldName => $arguments[0])); - - case 2: - return $this->$method(array($fieldName => $arguments[0]), $arguments[1]); - - case 3: - return $this->$method(array($fieldName => $arguments[0]), $arguments[1], $arguments[2]); - - case 4: - return $this->$method(array($fieldName => $arguments[0]), $arguments[1], $arguments[2], $arguments[3]); - } + if (! ($this->_class->hasField($fieldName) || $this->_class->hasAssociation($fieldName))) { + throw ORMException::invalidMagicCall($this->_entityName, $fieldName, $method . $by); } - throw ORMException::invalidMagicCall($this->_entityName, $fieldName, $method.$by); + return $this->$method([$fieldName => $arguments[0]], ...array_slice($arguments, 1)); } }