From 12465e08ada4460ec0cc6d06f1d114976d6a944f Mon Sep 17 00:00:00 2001 From: ReenExe Date: Sun, 3 Jul 2016 00:28:56 +0300 Subject: [PATCH 1/5] agree with scrutinizer --- lib/Doctrine/ORM/Query/SqlWalker.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index 0aa4349a1..6e607ffa9 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -501,7 +501,6 @@ class SqlWalker implements TreeWalker default: //@todo: throw exception? return ''; - break; } $filterClauses = array(); From 401300b2957a2082cf97e76e925af16760541beb Mon Sep 17 00:00:00 2001 From: ReenExe Date: Sun, 3 Jul 2016 00:55:40 +0300 Subject: [PATCH 2/5] decrease nested if --- lib/Doctrine/ORM/Tools/EntityGenerator.php | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/Doctrine/ORM/Tools/EntityGenerator.php b/lib/Doctrine/ORM/Tools/EntityGenerator.php index 3c0f9264f..e678ea8be 100644 --- a/lib/Doctrine/ORM/Tools/EntityGenerator.php +++ b/lib/Doctrine/ORM/Tools/EntityGenerator.php @@ -1259,21 +1259,21 @@ public function __construct() */ protected function generateEntityLifecycleCallbackMethods(ClassMetadataInfo $metadata) { - if (isset($metadata->lifecycleCallbacks) && $metadata->lifecycleCallbacks) { - $methods = array(); - - foreach ($metadata->lifecycleCallbacks as $name => $callbacks) { - foreach ($callbacks as $callback) { - if ($code = $this->generateLifecycleCallbackMethod($name, $callback, $metadata)) { - $methods[] = $code; - } - } - } - - return implode("\n\n", $methods); + if (empty($metadata->lifecycleCallbacks)) { + return ''; } - return ""; + $methods = []; + + foreach ($metadata->lifecycleCallbacks as $name => $callbacks) { + foreach ($callbacks as $callback) { + if ($code = $this->generateLifecycleCallbackMethod($name, $callback, $metadata)) { + $methods[] = $code; + } + } + } + + return implode("\n\n", $methods); } /** From b2f5da19a4ab28b70e565d6e9a195be0b3b90013 Mon Sep 17 00:00:00 2001 From: ReenExe Date: Sun, 3 Jul 2016 01:01:25 +0300 Subject: [PATCH 3/5] clear code --- lib/Doctrine/ORM/Query.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/Query.php b/lib/Doctrine/ORM/Query.php index e3f23cc6b..6a8a50ae0 100644 --- a/lib/Doctrine/ORM/Query.php +++ b/lib/Doctrine/ORM/Query.php @@ -309,7 +309,9 @@ final class Query extends AbstractQuery if ($paramCount > $mappingCount) { throw QueryException::tooManyParameters($mappingCount, $paramCount); - } elseif ($paramCount < $mappingCount) { + } + + if ($paramCount < $mappingCount) { throw QueryException::tooFewParameters($mappingCount, $paramCount); } From 5d477cdbbc121ab587234c508ab20d4bf2b42b72 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 26 Nov 2016 06:42:46 +0100 Subject: [PATCH 4/5] #5914 `ClassMetadataInfo#$lifecycleCallbacks` is a multi-dimensional array --- lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index 8fa11f360..3058a2eda 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -463,7 +463,7 @@ class ClassMetadataInfo implements ClassMetadata /** * READ-ONLY: The registered lifecycle callbacks for entities of this class. * - * @var array + * @var array[] */ public $lifecycleCallbacks = array(); From 0ed18fb062470a8d267a1bd88656430116b63e9f Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 26 Nov 2016 06:44:53 +0100 Subject: [PATCH 5/5] #5914 removed unused conditional inside `EntityGenerator`, replaced with `array_filter()` instead --- lib/Doctrine/ORM/Tools/EntityGenerator.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/Doctrine/ORM/Tools/EntityGenerator.php b/lib/Doctrine/ORM/Tools/EntityGenerator.php index e678ea8be..22d5b412a 100644 --- a/lib/Doctrine/ORM/Tools/EntityGenerator.php +++ b/lib/Doctrine/ORM/Tools/EntityGenerator.php @@ -1267,13 +1267,11 @@ public function __construct() foreach ($metadata->lifecycleCallbacks as $name => $callbacks) { foreach ($callbacks as $callback) { - if ($code = $this->generateLifecycleCallbackMethod($name, $callback, $metadata)) { - $methods[] = $code; - } + $methods[] = $this->generateLifecycleCallbackMethod($name, $callback, $metadata); } } - return implode("\n\n", $methods); + return implode("\n\n", array_filter($methods)); } /**