From aff51f64b105c543919e311d49239cbc0beac4ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Thu, 14 Mar 2019 13:49:58 +0100 Subject: [PATCH 01/33] Updated file header comment, added strict_types declaration --- src/TableGateway/AbstractTableGateway.php | 10 +++++----- src/TableGateway/Exception/ExceptionInterface.php | 10 +++++----- .../Exception/InvalidArgumentException.php | 10 +++++----- src/TableGateway/Exception/RuntimeException.php | 10 +++++----- src/TableGateway/Feature/AbstractFeature.php | 10 +++++----- src/TableGateway/Feature/EventFeature.php | 10 +++++----- .../Feature/EventFeature/TableGatewayEvent.php | 10 +++++----- .../Feature/EventFeatureEventsInterface.php | 10 +++++----- src/TableGateway/Feature/FeatureSet.php | 10 +++++----- src/TableGateway/Feature/GlobalAdapterFeature.php | 10 +++++----- src/TableGateway/Feature/MasterSlaveFeature.php | 10 +++++----- src/TableGateway/Feature/MetadataFeature.php | 10 +++++----- src/TableGateway/Feature/RowGatewayFeature.php | 10 +++++----- src/TableGateway/Feature/SequenceFeature.php | 10 +++++----- src/TableGateway/TableGateway.php | 10 +++++----- src/TableGateway/TableGatewayInterface.php | 10 +++++----- 16 files changed, 80 insertions(+), 80 deletions(-) diff --git a/src/TableGateway/AbstractTableGateway.php b/src/TableGateway/AbstractTableGateway.php index b97a0dc293..813299d012 100644 --- a/src/TableGateway/AbstractTableGateway.php +++ b/src/TableGateway/AbstractTableGateway.php @@ -1,12 +1,12 @@ Date: Thu, 14 Mar 2019 13:50:58 +0100 Subject: [PATCH 02/33] Removed DocBlock for non-existing argument --- src/TableGateway/Feature/RowGatewayFeature.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/TableGateway/Feature/RowGatewayFeature.php b/src/TableGateway/Feature/RowGatewayFeature.php index 8726ea8eb6..38b15d0517 100644 --- a/src/TableGateway/Feature/RowGatewayFeature.php +++ b/src/TableGateway/Feature/RowGatewayFeature.php @@ -21,9 +21,6 @@ class RowGatewayFeature extends AbstractFeature */ protected $constructorArguments = []; - /** - * @param null $primaryKey - */ public function __construct() { $this->constructorArguments = func_get_args(); From c8d67b93a3acde2b625ed4dccd92718a69bc8639 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Thu, 14 Mar 2019 13:51:45 +0100 Subject: [PATCH 03/33] Defined access modifier for class constants --- .../Feature/EventFeatureEventsInterface.php | 20 +++++++++---------- src/TableGateway/Feature/FeatureSet.php | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/TableGateway/Feature/EventFeatureEventsInterface.php b/src/TableGateway/Feature/EventFeatureEventsInterface.php index cef39a68aa..d4ce8ede95 100644 --- a/src/TableGateway/Feature/EventFeatureEventsInterface.php +++ b/src/TableGateway/Feature/EventFeatureEventsInterface.php @@ -19,18 +19,18 @@ */ interface EventFeatureEventsInterface { - const EVENT_PRE_INITIALIZE = 'preInitialize'; - const EVENT_POST_INITIALIZE = 'postInitialize'; + public const EVENT_PRE_INITIALIZE = 'preInitialize'; + public const EVENT_POST_INITIALIZE = 'postInitialize'; - const EVENT_PRE_SELECT = 'preSelect'; - const EVENT_POST_SELECT = 'postSelect'; + public const EVENT_PRE_SELECT = 'preSelect'; + public const EVENT_POST_SELECT = 'postSelect'; - const EVENT_PRE_INSERT = 'preInsert'; - const EVENT_POST_INSERT = 'postInsert'; + public const EVENT_PRE_INSERT = 'preInsert'; + public const EVENT_POST_INSERT = 'postInsert'; - const EVENT_PRE_DELETE = 'preDelete'; - const EVENT_POST_DELETE = 'postDelete'; + public const EVENT_PRE_DELETE = 'preDelete'; + public const EVENT_POST_DELETE = 'postDelete'; - const EVENT_PRE_UPDATE = 'preUpdate'; - const EVENT_POST_UPDATE = 'postUpdate'; + public const EVENT_PRE_UPDATE = 'preUpdate'; + public const EVENT_POST_UPDATE = 'postUpdate'; } diff --git a/src/TableGateway/Feature/FeatureSet.php b/src/TableGateway/Feature/FeatureSet.php index 8a5abef343..f15182ac8b 100644 --- a/src/TableGateway/Feature/FeatureSet.php +++ b/src/TableGateway/Feature/FeatureSet.php @@ -14,7 +14,7 @@ class FeatureSet { - const APPLY_HALT = 'halt'; + public const APPLY_HALT = 'halt'; protected $tableGateway = null; From 36a09d80e50cedbd98ac73efb2734ee370bf5485 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Thu, 14 Mar 2019 13:52:24 +0100 Subject: [PATCH 04/33] Removed unnecessary parentheses --- src/TableGateway/AbstractTableGateway.php | 2 +- src/TableGateway/Feature/EventFeature.php | 2 +- src/TableGateway/TableGateway.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/TableGateway/AbstractTableGateway.php b/src/TableGateway/AbstractTableGateway.php index 813299d012..86f98cef78 100644 --- a/src/TableGateway/AbstractTableGateway.php +++ b/src/TableGateway/AbstractTableGateway.php @@ -528,7 +528,7 @@ public function __call($method, $arguments) */ public function __clone() { - $this->resultSetPrototype = (isset($this->resultSetPrototype)) ? clone $this->resultSetPrototype : null; + $this->resultSetPrototype = isset($this->resultSetPrototype) ? clone $this->resultSetPrototype : null; $this->sql = clone $this->sql; if (is_object($this->table)) { $this->table = clone $this->table; diff --git a/src/TableGateway/Feature/EventFeature.php b/src/TableGateway/Feature/EventFeature.php index e0bf9422db..36d5e01219 100644 --- a/src/TableGateway/Feature/EventFeature.php +++ b/src/TableGateway/Feature/EventFeature.php @@ -50,7 +50,7 @@ public function __construct( 'Zend\Db\TableGateway\TableGateway', ]); - $this->event = ($tableGatewayEvent) ?: new EventFeature\TableGatewayEvent(); + $this->event = $tableGatewayEvent ?: new EventFeature\TableGatewayEvent(); } /** diff --git a/src/TableGateway/TableGateway.php b/src/TableGateway/TableGateway.php index 3bf4a03e0a..845a9ccf7b 100644 --- a/src/TableGateway/TableGateway.php +++ b/src/TableGateway/TableGateway.php @@ -66,10 +66,10 @@ public function __construct( } // result prototype - $this->resultSetPrototype = ($resultSetPrototype) ?: new ResultSet; + $this->resultSetPrototype = $resultSetPrototype ?: new ResultSet; // Sql object (factory for select, insert, update, delete) - $this->sql = ($sql) ?: new Sql($this->adapter, $this->table); + $this->sql = $sql ?: new Sql($this->adapter, $this->table); // check sql object bound to same table if ($this->sql->getTable() != $this->table) { From 58aa29229606a62b679550fb3c768bee3439311f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Thu, 14 Mar 2019 13:53:06 +0100 Subject: [PATCH 05/33] Removed senseless return statement --- src/TableGateway/Feature/EventFeature/TableGatewayEvent.php | 1 - src/TableGateway/Feature/FeatureSet.php | 2 -- 2 files changed, 3 deletions(-) diff --git a/src/TableGateway/Feature/EventFeature/TableGatewayEvent.php b/src/TableGateway/Feature/EventFeature/TableGatewayEvent.php index f29e03bd2c..4cfee024fa 100644 --- a/src/TableGateway/Feature/EventFeature/TableGatewayEvent.php +++ b/src/TableGateway/Feature/EventFeature/TableGatewayEvent.php @@ -124,7 +124,6 @@ public function setParam($name, $value) */ public function stopPropagation($flag = true) { - return; } /** diff --git a/src/TableGateway/Feature/FeatureSet.php b/src/TableGateway/Feature/FeatureSet.php index f15182ac8b..08a48badd6 100644 --- a/src/TableGateway/Feature/FeatureSet.php +++ b/src/TableGateway/Feature/FeatureSet.php @@ -166,7 +166,5 @@ public function callMagicCall($method, $arguments) return $feature->$method($arguments); } } - - return; } } From d64052eecfc2cac2dcdd5e1f1d2976e4feab14a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Thu, 14 Mar 2019 13:54:20 +0100 Subject: [PATCH 06/33] Makes usage of compact() --- src/TableGateway/Feature/EventFeature.php | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/TableGateway/Feature/EventFeature.php b/src/TableGateway/Feature/EventFeature.php index 36d5e01219..5c9cc1c2dd 100644 --- a/src/TableGateway/Feature/EventFeature.php +++ b/src/TableGateway/Feature/EventFeature.php @@ -174,10 +174,7 @@ public function preInsert(Insert $insert) public function postInsert(StatementInterface $statement, ResultInterface $result) { $this->event->setName(static::EVENT_POST_INSERT); - $this->event->setParams([ - 'statement' => $statement, - 'result' => $result, - ]); + $this->event->setParams(compact('statement', 'result')); $this->eventManager->triggerEvent($this->event); } @@ -211,10 +208,7 @@ public function preUpdate(Update $update) public function postUpdate(StatementInterface $statement, ResultInterface $result) { $this->event->setName(static::EVENT_POST_UPDATE); - $this->event->setParams([ - 'statement' => $statement, - 'result' => $result, - ]); + $this->event->setParams(compact('statement', 'result')); $this->eventManager->triggerEvent($this->event); } @@ -248,10 +242,7 @@ public function preDelete(Delete $delete) public function postDelete(StatementInterface $statement, ResultInterface $result) { $this->event->setName(static::EVENT_POST_DELETE); - $this->event->setParams([ - 'statement' => $statement, - 'result' => $result, - ]); + $this->event->setParams(compact('statement', 'result')); $this->eventManager->triggerEvent($this->event); } } From 56e4064d00bf081323972edd1de1032bce284cd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Thu, 14 Mar 2019 13:54:57 +0100 Subject: [PATCH 07/33] Removed redundanct variables --- src/TableGateway/Feature/FeatureSet.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/TableGateway/Feature/FeatureSet.php b/src/TableGateway/Feature/FeatureSet.php index 08a48badd6..cce5d447ca 100644 --- a/src/TableGateway/Feature/FeatureSet.php +++ b/src/TableGateway/Feature/FeatureSet.php @@ -112,8 +112,7 @@ public function canCallMagicGet($property) */ public function callMagicGet($property) { - $return = null; - return $return; + return null; } /** @@ -132,8 +131,7 @@ public function canCallMagicSet($property) */ public function callMagicSet($property, $value) { - $return = null; - return $return; + return null; } /** From f976f590831503582ddeaf601761fd4a27ebcebd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Thu, 14 Mar 2019 13:56:16 +0100 Subject: [PATCH 08/33] Use ::class instead --- src/TableGateway/Feature/EventFeature.php | 3 ++- src/TableGateway/Feature/RowGatewayFeature.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/TableGateway/Feature/EventFeature.php b/src/TableGateway/Feature/EventFeature.php index 5c9cc1c2dd..deddb6a3b1 100644 --- a/src/TableGateway/Feature/EventFeature.php +++ b/src/TableGateway/Feature/EventFeature.php @@ -19,6 +19,7 @@ use Zend\EventManager\EventManager; use Zend\EventManager\EventManagerInterface; use Zend\EventManager\EventsCapableInterface; +use Zend\Db\TableGateway\TableGateway; class EventFeature extends AbstractFeature implements EventFeatureEventsInterface, @@ -47,7 +48,7 @@ public function __construct( : new EventManager; $this->eventManager->addIdentifiers([ - 'Zend\Db\TableGateway\TableGateway', + TableGateway::class, ]); $this->event = $tableGatewayEvent ?: new EventFeature\TableGatewayEvent(); diff --git a/src/TableGateway/Feature/RowGatewayFeature.php b/src/TableGateway/Feature/RowGatewayFeature.php index 38b15d0517..7d55ffaaf7 100644 --- a/src/TableGateway/Feature/RowGatewayFeature.php +++ b/src/TableGateway/Feature/RowGatewayFeature.php @@ -13,6 +13,7 @@ use Zend\Db\RowGateway\RowGateway; use Zend\Db\RowGateway\RowGatewayInterface; use Zend\Db\TableGateway\Exception; +use Zend\Db\TableGateway\Feature\MetadataFeature; class RowGatewayFeature extends AbstractFeature { @@ -55,7 +56,7 @@ public function postInitialize() } else { // get from metadata feature $metadata = $this->tableGateway->featureSet->getFeatureByClassName( - 'Zend\Db\TableGateway\Feature\MetadataFeature' + MetadataFeature::class ); if ($metadata === false || ! isset($metadata->sharedData['metadata'])) { throw new Exception\RuntimeException( From 32c592f8d9ed02592e58cc8b5c006d814547001c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Thu, 14 Mar 2019 13:56:41 +0100 Subject: [PATCH 09/33] Use static::class instead --- src/TableGateway/Feature/GlobalAdapterFeature.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/TableGateway/Feature/GlobalAdapterFeature.php b/src/TableGateway/Feature/GlobalAdapterFeature.php index b39b20605f..c602ef3375 100644 --- a/src/TableGateway/Feature/GlobalAdapterFeature.php +++ b/src/TableGateway/Feature/GlobalAdapterFeature.php @@ -26,7 +26,7 @@ class GlobalAdapterFeature extends AbstractFeature */ public static function setStaticAdapter(Adapter $adapter) { - $class = get_called_class(); + $class = static::class; static::$staticAdapters[$class] = $adapter; if ($class === __CLASS__) { @@ -42,7 +42,7 @@ public static function setStaticAdapter(Adapter $adapter) */ public static function getStaticAdapter() { - $class = get_called_class(); + $class = static::class; // class specific adapter if (isset(static::$staticAdapters[$class])) { From ac634306b2d456dea26b7e8786f6cb26e44ce5c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Thu, 14 Mar 2019 14:02:03 +0100 Subject: [PATCH 10/33] Declared return types --- src/TableGateway/AbstractTableGateway.php | 44 +++++++++---------- src/TableGateway/Feature/AbstractFeature.php | 6 +-- src/TableGateway/Feature/EventFeature.php | 24 +++++----- .../EventFeature/TableGatewayEvent.php | 14 +++--- src/TableGateway/Feature/FeatureSet.php | 14 +++--- .../Feature/GlobalAdapterFeature.php | 6 +-- .../Feature/MasterSlaveFeature.php | 10 ++--- src/TableGateway/Feature/MetadataFeature.php | 2 +- .../Feature/RowGatewayFeature.php | 2 +- src/TableGateway/Feature/SequenceFeature.php | 12 ++--- 10 files changed, 67 insertions(+), 67 deletions(-) diff --git a/src/TableGateway/AbstractTableGateway.php b/src/TableGateway/AbstractTableGateway.php index 86f98cef78..f8484865c0 100644 --- a/src/TableGateway/AbstractTableGateway.php +++ b/src/TableGateway/AbstractTableGateway.php @@ -74,7 +74,7 @@ abstract class AbstractTableGateway implements TableGatewayInterface /** * @return bool */ - public function isInitialized() + public function isInitialized() : bool { return $this->isInitialized; } @@ -83,9 +83,9 @@ public function isInitialized() * Initialize * * @throws Exception\RuntimeException - * @return null + * @return void */ - public function initialize() + public function initialize() : void { if ($this->isInitialized) { return; @@ -124,7 +124,7 @@ public function initialize() * * @return string */ - public function getTable() + public function getTable() : string { return $this->table; } @@ -134,7 +134,7 @@ public function getTable() * * @return AdapterInterface */ - public function getAdapter() + public function getAdapter() : AdapterInterface { return $this->adapter; } @@ -142,7 +142,7 @@ public function getAdapter() /** * @return array */ - public function getColumns() + public function getColumns() : array { return $this->columns; } @@ -150,7 +150,7 @@ public function getColumns() /** * @return Feature\FeatureSet */ - public function getFeatureSet() + public function getFeatureSet() : Feature\FeatureSet { return $this->featureSet; } @@ -160,7 +160,7 @@ public function getFeatureSet() * * @return ResultSetInterface */ - public function getResultSetPrototype() + public function getResultSetPrototype() : ResultSetInterface { return $this->resultSetPrototype; } @@ -168,7 +168,7 @@ public function getResultSetPrototype() /** * @return Sql */ - public function getSql() + public function getSql() : Sql { return $this->sql; } @@ -179,7 +179,7 @@ public function getSql() * @param Where|\Closure|string|array $where * @return ResultSetInterface */ - public function select($where = null) + public function select($where = null) : ResultSetInterface { if (! $this->isInitialized) { $this->initialize(); @@ -200,7 +200,7 @@ public function select($where = null) * @param Select $select * @return ResultSetInterface */ - public function selectWith(Select $select) + public function selectWith(Select $select) : ResultSetInterface { if (! $this->isInitialized) { $this->initialize(); @@ -213,7 +213,7 @@ public function selectWith(Select $select) * @return ResultSetInterface * @throws Exception\RuntimeException */ - protected function executeSelect(Select $select) + protected function executeSelect(Select $select) : ResultSetInterface { $selectState = $select->getRawState(); if ($selectState['table'] != $this->table @@ -253,7 +253,7 @@ protected function executeSelect(Select $select) * @param array $set * @return int */ - public function insert($set) + public function insert($set) : int { if (! $this->isInitialized) { $this->initialize(); @@ -267,7 +267,7 @@ public function insert($set) * @param Insert $insert * @return int */ - public function insertWith(Insert $insert) + public function insertWith(Insert $insert) : int { if (! $this->isInitialized) { $this->initialize(); @@ -282,7 +282,7 @@ public function insertWith(Insert $insert) * @return int * @throws Exception\RuntimeException */ - protected function executeInsert(Insert $insert) + protected function executeInsert(Insert $insert) : int { $insertState = $insert->getRawState(); if ($insertState['table'] != $this->table) { @@ -326,7 +326,7 @@ protected function executeInsert(Insert $insert) * @param null|array $joins * @return int */ - public function update($set, $where = null, array $joins = null) + public function update($set, $where = null, array $joins = null) : int { if (! $this->isInitialized) { $this->initialize(); @@ -352,7 +352,7 @@ public function update($set, $where = null, array $joins = null) * @param \Zend\Db\Sql\Update $update * @return int */ - public function updateWith(Update $update) + public function updateWith(Update $update) : int { if (! $this->isInitialized) { $this->initialize(); @@ -367,7 +367,7 @@ public function updateWith(Update $update) * @return int * @throws Exception\RuntimeException */ - protected function executeUpdate(Update $update) + protected function executeUpdate(Update $update) : int { $updateState = $update->getRawState(); if ($updateState['table'] != $this->table) { @@ -406,7 +406,7 @@ protected function executeUpdate(Update $update) * @param Where|\Closure|string|array $where * @return int */ - public function delete($where) + public function delete($where) : int { if (! $this->isInitialized) { $this->initialize(); @@ -424,7 +424,7 @@ public function delete($where) * @param Delete $delete * @return int */ - public function deleteWith(Delete $delete) + public function deleteWith(Delete $delete) : int { $this->initialize(); return $this->executeDelete($delete); @@ -437,7 +437,7 @@ public function deleteWith(Delete $delete) * @return int * @throws Exception\RuntimeException */ - protected function executeDelete(Delete $delete) + protected function executeDelete(Delete $delete) : int { $deleteState = $delete->getRawState(); if ($deleteState['table'] != $this->table) { @@ -463,7 +463,7 @@ protected function executeDelete(Delete $delete) * * @return int */ - public function getLastInsertValue() + public function getLastInsertValue() : int { return $this->lastInsertValue; } diff --git a/src/TableGateway/Feature/AbstractFeature.php b/src/TableGateway/Feature/AbstractFeature.php index 8a6394ea26..6dc29a17d2 100644 --- a/src/TableGateway/Feature/AbstractFeature.php +++ b/src/TableGateway/Feature/AbstractFeature.php @@ -26,17 +26,17 @@ public function getName() return get_class($this); } - public function setTableGateway(AbstractTableGateway $tableGateway) + public function setTableGateway(AbstractTableGateway $tableGateway) : void: void { $this->tableGateway = $tableGateway; } - public function initialize() + public function initialize() : void { throw new Exception\RuntimeException('This method is not intended to be called on this object.'); } - public function getMagicMethodSpecifications() + public function getMagicMethodSpecifications() : array: array { return []; } diff --git a/src/TableGateway/Feature/EventFeature.php b/src/TableGateway/Feature/EventFeature.php index deddb6a3b1..4437a96c95 100644 --- a/src/TableGateway/Feature/EventFeature.php +++ b/src/TableGateway/Feature/EventFeature.php @@ -59,7 +59,7 @@ public function __construct( * * @return EventManagerInterface */ - public function getEventManager() + public function getEventManager() : EventManagerInterface { return $this->eventManager; } @@ -69,7 +69,7 @@ public function getEventManager() * * @return EventFeature\TableGatewayEvent */ - public function getEvent() + public function getEvent() : EventFeature\TableGatewayEvent { return $this->event; } @@ -83,7 +83,7 @@ public function getEvent() * * @return void */ - public function preInitialize() + public function preInitialize() : void { if (get_class($this->tableGateway) != 'Zend\Db\TableGateway\TableGateway') { $this->eventManager->addIdentifiers([get_class($this->tableGateway)]); @@ -99,7 +99,7 @@ public function preInitialize() * * @return void */ - public function postInitialize() + public function postInitialize() : void { $this->event->setName(static::EVENT_POST_INITIALIZE); $this->eventManager->triggerEvent($this->event); @@ -114,7 +114,7 @@ public function postInitialize() * @param Select $select * @return void */ - public function preSelect(Select $select) + public function preSelect(Select $select) : void { $this->event->setName(static::EVENT_PRE_SELECT); $this->event->setParams(['select' => $select]); @@ -134,7 +134,7 @@ public function preSelect(Select $select) * @param ResultSetInterface $resultSet * @return void */ - public function postSelect(StatementInterface $statement, ResultInterface $result, ResultSetInterface $resultSet) + public function postSelect(StatementInterface $statement, ResultInterface $result, ResultSetInterface $resultSet) : void { $this->event->setName(static::EVENT_POST_SELECT); $this->event->setParams([ @@ -154,7 +154,7 @@ public function postSelect(StatementInterface $statement, ResultInterface $resul * @param Insert $insert * @return void */ - public function preInsert(Insert $insert) + public function preInsert(Insert $insert) : void { $this->event->setName(static::EVENT_PRE_INSERT); $this->event->setParams(['insert' => $insert]); @@ -172,7 +172,7 @@ public function preInsert(Insert $insert) * @param ResultInterface $result * @return void */ - public function postInsert(StatementInterface $statement, ResultInterface $result) + public function postInsert(StatementInterface $statement, ResultInterface $result) : void { $this->event->setName(static::EVENT_POST_INSERT); $this->event->setParams(compact('statement', 'result')); @@ -188,7 +188,7 @@ public function postInsert(StatementInterface $statement, ResultInterface $resul * @param Update $update * @return void */ - public function preUpdate(Update $update) + public function preUpdate(Update $update) : void { $this->event->setName(static::EVENT_PRE_UPDATE); $this->event->setParams(['update' => $update]); @@ -206,7 +206,7 @@ public function preUpdate(Update $update) * @param ResultInterface $result * @return void */ - public function postUpdate(StatementInterface $statement, ResultInterface $result) + public function postUpdate(StatementInterface $statement, ResultInterface $result) : void { $this->event->setName(static::EVENT_POST_UPDATE); $this->event->setParams(compact('statement', 'result')); @@ -222,7 +222,7 @@ public function postUpdate(StatementInterface $statement, ResultInterface $resul * @param Delete $delete * @return void */ - public function preDelete(Delete $delete) + public function preDelete(Delete $delete) : void { $this->event->setName(static::EVENT_PRE_DELETE); $this->event->setParams(['delete' => $delete]); @@ -240,7 +240,7 @@ public function preDelete(Delete $delete) * @param ResultInterface $result * @return void */ - public function postDelete(StatementInterface $statement, ResultInterface $result) + public function postDelete(StatementInterface $statement, ResultInterface $result) : void { $this->event->setName(static::EVENT_POST_DELETE); $this->event->setParams(compact('statement', 'result')); diff --git a/src/TableGateway/Feature/EventFeature/TableGatewayEvent.php b/src/TableGateway/Feature/EventFeature/TableGatewayEvent.php index 4cfee024fa..20350796d0 100644 --- a/src/TableGateway/Feature/EventFeature/TableGatewayEvent.php +++ b/src/TableGateway/Feature/EventFeature/TableGatewayEvent.php @@ -34,7 +34,7 @@ class TableGatewayEvent implements EventInterface * * @return string */ - public function getName() + public function getName() : string { return $this->name; } @@ -77,7 +77,7 @@ public function getParam($name, $default = null) * @param string $name * @return void */ - public function setName($name) + public function setName($name) : void { $this->name = $name; } @@ -88,7 +88,7 @@ public function setName($name) * @param null|string|object $target * @return void */ - public function setTarget($target) + public function setTarget($target) : void { $this->target = $target; } @@ -99,7 +99,7 @@ public function setTarget($target) * @param string $params * @return void */ - public function setParams($params) + public function setParams($params) : void { $this->params = $params; } @@ -111,7 +111,7 @@ public function setParams($params) * @param mixed $value * @return void */ - public function setParam($name, $value) + public function setParam($name, $value) : void { $this->params[$name] = $value; } @@ -122,7 +122,7 @@ public function setParam($name, $value) * @param bool $flag * @return void */ - public function stopPropagation($flag = true) + public function stopPropagation($flag = true) : void { } @@ -131,7 +131,7 @@ public function stopPropagation($flag = true) * * @return bool */ - public function propagationIsStopped() + public function propagationIsStopped() : bool { return false; } diff --git a/src/TableGateway/Feature/FeatureSet.php b/src/TableGateway/Feature/FeatureSet.php index cce5d447ca..36b910f815 100644 --- a/src/TableGateway/Feature/FeatureSet.php +++ b/src/TableGateway/Feature/FeatureSet.php @@ -39,7 +39,7 @@ public function __construct(array $features = []) * @param AbstractTableGateway $tableGateway * @return self Provides a fluent interface */ - public function setTableGateway(AbstractTableGateway $tableGateway) + public function setTableGateway(AbstractTableGateway $tableGateway) : self { $this->tableGateway = $tableGateway; foreach ($this->features as $feature) { @@ -64,7 +64,7 @@ public function getFeatureByClassName($featureClassName) * @param array $features * @return self Provides a fluent interface */ - public function addFeatures(array $features) + public function addFeatures(array $features) : self { foreach ($features as $feature) { $this->addFeature($feature); @@ -76,7 +76,7 @@ public function addFeatures(array $features) * @param AbstractFeature $feature * @return self Provides a fluent interface */ - public function addFeature(AbstractFeature $feature) + public function addFeature(AbstractFeature $feature) : self { if ($this->tableGateway instanceof TableGatewayInterface) { $feature->setTableGateway($this->tableGateway); @@ -85,7 +85,7 @@ public function addFeature(AbstractFeature $feature) return $this; } - public function apply($method, $args) + public function apply($method, $args) : void { foreach ($this->features as $feature) { if (method_exists($feature, $method)) { @@ -101,7 +101,7 @@ public function apply($method, $args) * @param string $property * @return bool */ - public function canCallMagicGet($property) + public function canCallMagicGet($property) : bool { return false; } @@ -119,7 +119,7 @@ public function callMagicGet($property) * @param string $property * @return bool */ - public function canCallMagicSet($property) + public function canCallMagicSet($property) : bool { return false; } @@ -139,7 +139,7 @@ public function callMagicSet($property, $value) * @param string $method * @return bool */ - public function canCallMagicCall($method) + public function canCallMagicCall($method) : bool { if (! empty($this->features)) { foreach ($this->features as $feature) { diff --git a/src/TableGateway/Feature/GlobalAdapterFeature.php b/src/TableGateway/Feature/GlobalAdapterFeature.php index c602ef3375..d6b25b2a61 100644 --- a/src/TableGateway/Feature/GlobalAdapterFeature.php +++ b/src/TableGateway/Feature/GlobalAdapterFeature.php @@ -24,7 +24,7 @@ class GlobalAdapterFeature extends AbstractFeature * * @param Adapter $adapter */ - public static function setStaticAdapter(Adapter $adapter) + public static function setStaticAdapter(Adapter $adapter) : void { $class = static::class; @@ -40,7 +40,7 @@ public static function setStaticAdapter(Adapter $adapter) * @throws Exception\RuntimeException * @return Adapter */ - public static function getStaticAdapter() + public static function getStaticAdapter() : Adapter { $class = static::class; @@ -60,7 +60,7 @@ public static function getStaticAdapter() /** * after initialization, retrieve the original adapter as "master" */ - public function preInitialize() + public function preInitialize() : void { $this->tableGateway->adapter = self::getStaticAdapter(); } diff --git a/src/TableGateway/Feature/MasterSlaveFeature.php b/src/TableGateway/Feature/MasterSlaveFeature.php index 67f7f3527c..8ac10653b4 100644 --- a/src/TableGateway/Feature/MasterSlaveFeature.php +++ b/src/TableGateway/Feature/MasterSlaveFeature.php @@ -43,7 +43,7 @@ public function __construct(AdapterInterface $slaveAdapter, Sql $slaveSql = null } } - public function getSlaveAdapter() + public function getSlaveAdapter() : AdapterInterface { return $this->slaveAdapter; } @@ -51,7 +51,7 @@ public function getSlaveAdapter() /** * @return Sql */ - public function getSlaveSql() + public function getSlaveSql() : Sql { return $this->slaveSql; } @@ -59,7 +59,7 @@ public function getSlaveSql() /** * after initialization, retrieve the original adapter as "master" */ - public function postInitialize() + public function postInitialize() : void { $this->masterSql = $this->tableGateway->sql; if ($this->slaveSql === null) { @@ -75,7 +75,7 @@ public function postInitialize() * preSelect() * Replace adapter with slave temporarily */ - public function preSelect() + public function preSelect() : void { $this->tableGateway->sql = $this->slaveSql; } @@ -84,7 +84,7 @@ public function preSelect() * postSelect() * Ensure to return to the master adapter */ - public function postSelect() + public function postSelect() : void { $this->tableGateway->sql = $this->masterSql; } diff --git a/src/TableGateway/Feature/MetadataFeature.php b/src/TableGateway/Feature/MetadataFeature.php index 9217dc7645..270929db59 100644 --- a/src/TableGateway/Feature/MetadataFeature.php +++ b/src/TableGateway/Feature/MetadataFeature.php @@ -37,7 +37,7 @@ public function __construct(MetadataInterface $metadata = null) ]; } - public function postInitialize() + public function postInitialize() : void { if ($this->metadata === null) { $this->metadata = SourceFactory::createSourceFromAdapter($this->tableGateway->adapter); diff --git a/src/TableGateway/Feature/RowGatewayFeature.php b/src/TableGateway/Feature/RowGatewayFeature.php index 7d55ffaaf7..a9b3d32c3b 100644 --- a/src/TableGateway/Feature/RowGatewayFeature.php +++ b/src/TableGateway/Feature/RowGatewayFeature.php @@ -27,7 +27,7 @@ public function __construct() $this->constructorArguments = func_get_args(); } - public function postInitialize() + public function postInitialize() : void { $args = $this->constructorArguments; diff --git a/src/TableGateway/Feature/SequenceFeature.php b/src/TableGateway/Feature/SequenceFeature.php index 8ef2c5f227..b169f7fc24 100644 --- a/src/TableGateway/Feature/SequenceFeature.php +++ b/src/TableGateway/Feature/SequenceFeature.php @@ -45,7 +45,7 @@ public function __construct($primaryKeyField, $sequenceName) * @param Insert $insert * @return Insert */ - public function preInsert(Insert $insert) + public function preInsert(Insert $insert) : Insert { $columns = $insert->getRawState('columns'); $values = $insert->getRawState('values'); @@ -68,7 +68,7 @@ public function preInsert(Insert $insert) * @param StatementInterface $statement * @param ResultInterface $result */ - public function postInsert(StatementInterface $statement, ResultInterface $result) + public function postInsert(StatementInterface $statement, ResultInterface $result) : void { if ($this->sequenceValue !== null) { $this->tableGateway->lastInsertValue = $this->sequenceValue; @@ -79,7 +79,7 @@ public function postInsert(StatementInterface $statement, ResultInterface $resul * Generate a new value from the specified sequence in the database, and return it. * @return int */ - public function nextSequenceId() + public function nextSequenceId() : ?int { $platform = $this->tableGateway->adapter->getPlatform(); $platformName = $platform->getName(); @@ -92,7 +92,7 @@ public function nextSequenceId() $sql = 'SELECT NEXTVAL(\'"' . $this->sequenceName . '"\')'; break; default: - return; + return null; } $statement = $this->tableGateway->adapter->createStatement(); @@ -107,7 +107,7 @@ public function nextSequenceId() * Return the most recent value from the specified sequence in the database. * @return int */ - public function lastSequenceId() + public function lastSequenceId() : ?int { $platform = $this->tableGateway->adapter->getPlatform(); $platformName = $platform->getName(); @@ -120,7 +120,7 @@ public function lastSequenceId() $sql = 'SELECT CURRVAL(\'' . $this->sequenceName . '\')'; break; default: - return; + return null; } $statement = $this->tableGateway->adapter->createStatement(); From 4890d501d5e1477f8c33f8c8de3af51f2f82d60c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Thu, 14 Mar 2019 14:06:32 +0100 Subject: [PATCH 11/33] Initialize string property as string --- src/TableGateway/Feature/EventFeature/TableGatewayEvent.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/TableGateway/Feature/EventFeature/TableGatewayEvent.php b/src/TableGateway/Feature/EventFeature/TableGatewayEvent.php index 20350796d0..ee09b1ebf1 100644 --- a/src/TableGateway/Feature/EventFeature/TableGatewayEvent.php +++ b/src/TableGateway/Feature/EventFeature/TableGatewayEvent.php @@ -19,10 +19,7 @@ class TableGatewayEvent implements EventInterface */ protected $target = null; - /** - * @var null - */ - protected $name = null; + protected $name = ''; /** * @var array|\ArrayAccess From 860da62f925c3f33a1db58c1a44aa8825d002e45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Thu, 14 Mar 2019 14:08:35 +0100 Subject: [PATCH 12/33] Updated possible types for --- .../Feature/EventFeature/TableGatewayEvent.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/TableGateway/Feature/EventFeature/TableGatewayEvent.php b/src/TableGateway/Feature/EventFeature/TableGatewayEvent.php index ee09b1ebf1..8473f85f1d 100644 --- a/src/TableGateway/Feature/EventFeature/TableGatewayEvent.php +++ b/src/TableGateway/Feature/EventFeature/TableGatewayEvent.php @@ -15,9 +15,9 @@ class TableGatewayEvent implements EventInterface { /** - * @var AbstractTableGateway + * @var null|string|object|AbstractTableGateway */ - protected $target = null; + protected $target; protected $name = ''; @@ -39,7 +39,7 @@ public function getName() : string /** * Get target/context from which event was triggered * - * @return null|string|object + * @return null|string|object|AbstractTableGateway */ public function getTarget() { @@ -82,7 +82,7 @@ public function setName($name) : void /** * Set the event target/context * - * @param null|string|object $target + * @param null|string|object|AbstractTableGateway $target * @return void */ public function setTarget($target) : void From f9b6214b6e760de2a1e06864ca5387c6f592d787 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Thu, 14 Mar 2019 14:11:05 +0100 Subject: [PATCH 13/33] Write single-line comments with @var as one-liners --- src/TableGateway/AbstractTableGateway.php | 33 +++++-------------- src/TableGateway/Feature/EventFeature.php | 8 ++--- .../EventFeature/TableGatewayEvent.php | 8 ++--- src/TableGateway/Feature/FeatureSet.php | 8 ++--- .../Feature/GlobalAdapterFeature.php | 4 +-- .../Feature/MasterSlaveFeature.php | 12 ++----- src/TableGateway/Feature/MetadataFeature.php | 4 +-- .../Feature/RowGatewayFeature.php | 4 +-- src/TableGateway/Feature/SequenceFeature.php | 12 ++----- 9 files changed, 23 insertions(+), 70 deletions(-) diff --git a/src/TableGateway/AbstractTableGateway.php b/src/TableGateway/AbstractTableGateway.php index f8484865c0..c2ab2640b3 100644 --- a/src/TableGateway/AbstractTableGateway.php +++ b/src/TableGateway/AbstractTableGateway.php @@ -30,45 +30,28 @@ */ abstract class AbstractTableGateway implements TableGatewayInterface { - /** - * @var bool - */ + /** @var bool */ protected $isInitialized = false; - /** - * @var AdapterInterface - */ + /** @var AdapterInterface */ protected $adapter = null; - /** - * @var string|array|TableIdentifier - */ + /** @var string|array|TableIdentifier */ protected $table = null; - /** - * @var array - */ + /** @var array */ protected $columns = []; - /** - * @var Feature\FeatureSet - */ + /** @var Feature\FeatureSet */ protected $featureSet = null; - /** - * @var ResultSetInterface - */ + /** @var ResultSetInterface */ protected $resultSetPrototype = null; - /** - * @var Sql - */ + /** @var Sql */ protected $sql = null; - /** - * - * @var int - */ + /** @var int */ protected $lastInsertValue = null; /** diff --git a/src/TableGateway/Feature/EventFeature.php b/src/TableGateway/Feature/EventFeature.php index 4437a96c95..f0cba93772 100644 --- a/src/TableGateway/Feature/EventFeature.php +++ b/src/TableGateway/Feature/EventFeature.php @@ -25,14 +25,10 @@ class EventFeature extends AbstractFeature implements EventFeatureEventsInterface, EventsCapableInterface { - /** - * @var EventManagerInterface - */ + /** @var EventManagerInterface */ protected $eventManager = null; - /** - * @var null - */ + /** @var null */ protected $event = null; /** diff --git a/src/TableGateway/Feature/EventFeature/TableGatewayEvent.php b/src/TableGateway/Feature/EventFeature/TableGatewayEvent.php index 8473f85f1d..f2c2f0fbb9 100644 --- a/src/TableGateway/Feature/EventFeature/TableGatewayEvent.php +++ b/src/TableGateway/Feature/EventFeature/TableGatewayEvent.php @@ -14,16 +14,12 @@ class TableGatewayEvent implements EventInterface { - /** - * @var null|string|object|AbstractTableGateway - */ + /** @var null|string|object|AbstractTableGateway */ protected $target; protected $name = ''; - /** - * @var array|\ArrayAccess - */ + /** @var array|\ArrayAccess */ protected $params = []; /** diff --git a/src/TableGateway/Feature/FeatureSet.php b/src/TableGateway/Feature/FeatureSet.php index 36b910f815..2f85ab5e68 100644 --- a/src/TableGateway/Feature/FeatureSet.php +++ b/src/TableGateway/Feature/FeatureSet.php @@ -18,14 +18,10 @@ class FeatureSet protected $tableGateway = null; - /** - * @var AbstractFeature[] - */ + /** @var AbstractFeature[] */ protected $features = []; - /** - * @var array - */ + /** @var array */ protected $magicSpecifications = []; public function __construct(array $features = []) diff --git a/src/TableGateway/Feature/GlobalAdapterFeature.php b/src/TableGateway/Feature/GlobalAdapterFeature.php index d6b25b2a61..94607b6447 100644 --- a/src/TableGateway/Feature/GlobalAdapterFeature.php +++ b/src/TableGateway/Feature/GlobalAdapterFeature.php @@ -14,9 +14,7 @@ class GlobalAdapterFeature extends AbstractFeature { - /** - * @var Adapter[] - */ + /** @var Adapter[] */ protected static $staticAdapters = []; /** diff --git a/src/TableGateway/Feature/MasterSlaveFeature.php b/src/TableGateway/Feature/MasterSlaveFeature.php index 8ac10653b4..4e04ab12a0 100644 --- a/src/TableGateway/Feature/MasterSlaveFeature.php +++ b/src/TableGateway/Feature/MasterSlaveFeature.php @@ -14,19 +14,13 @@ class MasterSlaveFeature extends AbstractFeature { - /** - * @var AdapterInterface - */ + /** @var AdapterInterface */ protected $slaveAdapter = null; - /** - * @var Sql - */ + /** @var Sql */ protected $masterSql = null; - /** - * @var Sql - */ + /** @var Sql */ protected $slaveSql = null; /** diff --git a/src/TableGateway/Feature/MetadataFeature.php b/src/TableGateway/Feature/MetadataFeature.php index 270929db59..1e1410d65d 100644 --- a/src/TableGateway/Feature/MetadataFeature.php +++ b/src/TableGateway/Feature/MetadataFeature.php @@ -16,9 +16,7 @@ class MetadataFeature extends AbstractFeature { - /** - * @var MetadataInterface - */ + /** @var MetadataInterface */ protected $metadata = null; /** diff --git a/src/TableGateway/Feature/RowGatewayFeature.php b/src/TableGateway/Feature/RowGatewayFeature.php index a9b3d32c3b..22cfbda985 100644 --- a/src/TableGateway/Feature/RowGatewayFeature.php +++ b/src/TableGateway/Feature/RowGatewayFeature.php @@ -17,9 +17,7 @@ class RowGatewayFeature extends AbstractFeature { - /** - * @var array - */ + /** @var array */ protected $constructorArguments = []; public function __construct() diff --git a/src/TableGateway/Feature/SequenceFeature.php b/src/TableGateway/Feature/SequenceFeature.php index b169f7fc24..1813427455 100644 --- a/src/TableGateway/Feature/SequenceFeature.php +++ b/src/TableGateway/Feature/SequenceFeature.php @@ -15,19 +15,13 @@ class SequenceFeature extends AbstractFeature { - /** - * @var string - */ + /** @var string */ protected $primaryKeyField; - /** - * @var string - */ + /** @var string */ protected $sequenceName; - /** - * @var int - */ + /** @var int */ protected $sequenceValue; From 5e5af611b7aeba843881b9b853a63dece785e992 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Thu, 14 Mar 2019 14:12:53 +0100 Subject: [PATCH 14/33] Do not align @param tags --- src/TableGateway/TableGateway.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/TableGateway/TableGateway.php b/src/TableGateway/TableGateway.php index 845a9ccf7b..6e869eca98 100644 --- a/src/TableGateway/TableGateway.php +++ b/src/TableGateway/TableGateway.php @@ -20,11 +20,11 @@ class TableGateway extends AbstractTableGateway /** * Constructor * - * @param string|TableIdentifier|array $table - * @param AdapterInterface $adapter + * @param string|TableIdentifier|array $table + * @param AdapterInterface $adapter * @param Feature\AbstractFeature|Feature\FeatureSet|Feature\AbstractFeature[]|null $features - * @param ResultSetInterface|null $resultSetPrototype - * @param Sql|null $sql + * @param ResultSetInterface|null $resultSetPrototype + * @param Sql|null $sql * * @throws Exception\InvalidArgumentException */ From 6ed30ef0381aa92a05b2d7ce687af51618b7d682 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Thu, 14 Mar 2019 14:16:18 +0100 Subject: [PATCH 15/33] Write single-line comments with @var as one-liners, removed null initialization, fixed duplicate return type declarations --- src/TableGateway/Feature/AbstractFeature.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/TableGateway/Feature/AbstractFeature.php b/src/TableGateway/Feature/AbstractFeature.php index 6dc29a17d2..0698e52995 100644 --- a/src/TableGateway/Feature/AbstractFeature.php +++ b/src/TableGateway/Feature/AbstractFeature.php @@ -14,10 +14,8 @@ abstract class AbstractFeature extends AbstractTableGateway { - /** - * @var AbstractTableGateway - */ - protected $tableGateway = null; + /** @var AbstractTableGateway */ + protected $tableGateway; protected $sharedData = []; @@ -26,7 +24,7 @@ public function getName() return get_class($this); } - public function setTableGateway(AbstractTableGateway $tableGateway) : void: void + public function setTableGateway(AbstractTableGateway $tableGateway) : void { $this->tableGateway = $tableGateway; } @@ -36,7 +34,7 @@ public function initialize() : void throw new Exception\RuntimeException('This method is not intended to be called on this object.'); } - public function getMagicMethodSpecifications() : array: array + public function getMagicMethodSpecifications() : array { return []; } From 77e045ed4ed95b458ebd22d11b49ee45da91b310 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Thu, 14 Mar 2019 14:16:50 +0100 Subject: [PATCH 16/33] Removed comment --- src/TableGateway/Feature/AbstractFeature.php | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/TableGateway/Feature/AbstractFeature.php b/src/TableGateway/Feature/AbstractFeature.php index 0698e52995..a3d1d67977 100644 --- a/src/TableGateway/Feature/AbstractFeature.php +++ b/src/TableGateway/Feature/AbstractFeature.php @@ -38,18 +38,4 @@ public function getMagicMethodSpecifications() : array { return []; } - - - /* - public function preInitialize(); - public function postInitialize(); - public function preSelect(Select $select); - public function postSelect(StatementInterface $statement, ResultInterface $result, ResultSetInterface $resultSet); - public function preInsert(Insert $insert); - public function postInsert(StatementInterface $statement, ResultInterface $result); - public function preUpdate(Update $update); - public function postUpdate(StatementInterface $statement, ResultInterface $result); - public function preDelete(Delete $delete); - public function postDelete(StatementInterface $statement, ResultInterface $result); - */ } From d0b743f2940e86aee08f7deab4b8112b1a80a75a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Thu, 14 Mar 2019 14:21:20 +0100 Subject: [PATCH 17/33] Removed comment which does not add valuable information, import ArrayAccess --- .../Feature/EventFeature/TableGatewayEvent.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/TableGateway/Feature/EventFeature/TableGatewayEvent.php b/src/TableGateway/Feature/EventFeature/TableGatewayEvent.php index f2c2f0fbb9..085ee88ff8 100644 --- a/src/TableGateway/Feature/EventFeature/TableGatewayEvent.php +++ b/src/TableGateway/Feature/EventFeature/TableGatewayEvent.php @@ -9,6 +9,7 @@ namespace Zend\Db\TableGateway\Feature\EventFeature; +use ArrayAccess; use Zend\Db\TableGateway\AbstractTableGateway; use Zend\EventManager\EventInterface; @@ -19,14 +20,9 @@ class TableGatewayEvent implements EventInterface protected $name = ''; - /** @var array|\ArrayAccess */ + /** @var array|ArrayAccess */ protected $params = []; - /** - * Get event name - * - * @return string - */ public function getName() : string { return $this->name; @@ -45,7 +41,7 @@ public function getTarget() /** * Get parameters passed to the event * - * @return array|\ArrayAccess + * @return array|ArrayAccess */ public function getParams() { From 1c3734744daaf9b657299ff2a199da71ba473e76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Thu, 14 Mar 2019 14:22:16 +0100 Subject: [PATCH 18/33] Added information on where type declarations are blocked --- 3.0.0.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/3.0.0.md b/3.0.0.md index b1c3abfb90..16d8cba518 100644 --- a/3.0.0.md +++ b/3.0.0.md @@ -28,3 +28,7 @@ Changed `setDriver(DriverInterface $driver)` for all the following platforms: - Zend\Db\Adapter\Platform\Postgresql - Zend\Db\Adapter\Platform\Sqlite - Zend\Db\Adapter\Platform\SqlServer + +- Zend\Db\TableGateway\Feature\EventFeature\TableGatewayEvent + +We cannot use type hint because the usage of `Zend\EventManager\EventInterface`. From b5a668c941b219cab84f75674c1e469d3961be7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Thu, 14 Mar 2019 14:23:06 +0100 Subject: [PATCH 19/33] Removed comments which do not add valuable information, updated type declarations, removed null initializations --- src/TableGateway/Feature/EventFeature.php | 40 ++++++----------------- 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/src/TableGateway/Feature/EventFeature.php b/src/TableGateway/Feature/EventFeature.php index f0cba93772..90f210c11c 100644 --- a/src/TableGateway/Feature/EventFeature.php +++ b/src/TableGateway/Feature/EventFeature.php @@ -16,56 +16,41 @@ use Zend\Db\Sql\Insert; use Zend\Db\Sql\Select; use Zend\Db\Sql\Update; +use Zend\Db\TableGateway\Feature\EventFeature\TableGatewayEvent; +use Zend\Db\TableGateway\TableGateway; use Zend\EventManager\EventManager; use Zend\EventManager\EventManagerInterface; use Zend\EventManager\EventsCapableInterface; -use Zend\Db\TableGateway\TableGateway; class EventFeature extends AbstractFeature implements EventFeatureEventsInterface, EventsCapableInterface { /** @var EventManagerInterface */ - protected $eventManager = null; + protected $eventManager; - /** @var null */ - protected $event = null; + /** @var TableGatewayEvent */ + protected $event; - /** - * @param EventManagerInterface $eventManager - * @param EventFeature\TableGatewayEvent $tableGatewayEvent - */ public function __construct( - EventManagerInterface $eventManager = null, - EventFeature\TableGatewayEvent $tableGatewayEvent = null + ?EventManagerInterface $eventManager = null, + ?TableGatewayEvent $tableGatewayEvent = null ) { - $this->eventManager = ($eventManager instanceof EventManagerInterface) - ? $eventManager - : new EventManager; + $this->eventManager = $eventManager ?? new EventManager; $this->eventManager->addIdentifiers([ TableGateway::class, ]); - $this->event = $tableGatewayEvent ?: new EventFeature\TableGatewayEvent(); + $this->event = $tableGatewayEvent ?: new TableGatewayEvent(); } - /** - * Retrieve composed event manager instance - * - * @return EventManagerInterface - */ public function getEventManager() : EventManagerInterface { return $this->eventManager; } - /** - * Retrieve composed event instance - * - * @return EventFeature\TableGatewayEvent - */ - public function getEvent() : EventFeature\TableGatewayEvent + public function getEvent() : TableGatewayEvent { return $this->event; } @@ -90,11 +75,6 @@ public function preInitialize() : void $this->eventManager->triggerEvent($this->event); } - /** - * Trigger the "postInitialize" event - * - * @return void - */ public function postInitialize() : void { $this->event->setName(static::EVENT_POST_INITIALIZE); From 42b3f89f633d7fed7e68bccf65a6383aae97ba8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Thu, 14 Mar 2019 14:26:07 +0100 Subject: [PATCH 20/33] Added/updated argument and return type declarations, removed unnecessary method comments --- src/TableGateway/Feature/FeatureSet.php | 50 +++++-------------------- 1 file changed, 9 insertions(+), 41 deletions(-) diff --git a/src/TableGateway/Feature/FeatureSet.php b/src/TableGateway/Feature/FeatureSet.php index 2f85ab5e68..bff02d0dd9 100644 --- a/src/TableGateway/Feature/FeatureSet.php +++ b/src/TableGateway/Feature/FeatureSet.php @@ -16,7 +16,8 @@ class FeatureSet { public const APPLY_HALT = 'halt'; - protected $tableGateway = null; + /** @var AbstractTableGateway */ + protected $tableGateway; /** @var AbstractFeature[] */ protected $features = []; @@ -31,10 +32,6 @@ public function __construct(array $features = []) } } - /** - * @param AbstractTableGateway $tableGateway - * @return self Provides a fluent interface - */ public function setTableGateway(AbstractTableGateway $tableGateway) : self { $this->tableGateway = $tableGateway; @@ -57,7 +54,7 @@ public function getFeatureByClassName($featureClassName) } /** - * @param array $features + * @param AbstractFeature[] $features * @return self Provides a fluent interface */ public function addFeatures(array $features) : self @@ -68,10 +65,6 @@ public function addFeatures(array $features) : self return $this; } - /** - * @param AbstractFeature $feature - * @return self Provides a fluent interface - */ public function addFeature(AbstractFeature $feature) : self { if ($this->tableGateway instanceof TableGatewayInterface) { @@ -93,41 +86,22 @@ public function apply($method, $args) : void } } - /** - * @param string $property - * @return bool - */ - public function canCallMagicGet($property) : bool + public function canCallMagicGet(string $property) : bool { return false; } - /** - * @param string $property - * @return mixed - */ - public function callMagicGet($property) + public function callMagicGet(string $property) : void { - return null; } - /** - * @param string $property - * @return bool - */ - public function canCallMagicSet($property) : bool + public function canCallMagicSet(string $property) : bool { return false; } - /** - * @param $property - * @param $value - * @return mixed - */ - public function callMagicSet($property, $value) + public function callMagicSet(string $property, $value) : void { - return null; } /** @@ -135,7 +109,7 @@ public function callMagicSet($property, $value) * @param string $method * @return bool */ - public function canCallMagicCall($method) : bool + public function canCallMagicCall(string $method) : bool { if (! empty($this->features)) { foreach ($this->features as $feature) { @@ -147,13 +121,7 @@ public function canCallMagicCall($method) : bool return false; } - /** - * Call method of on added feature as though it were a local method - * @param string $method - * @param array $arguments - * @return mixed - */ - public function callMagicCall($method, $arguments) + public function callMagicCall(string $method, array $arguments) { foreach ($this->features as $feature) { if (method_exists($feature, $method)) { From 4e8996bc8315e58dd873a325d1dd1f21fc0b027b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Thu, 14 Mar 2019 14:27:04 +0100 Subject: [PATCH 21/33] Removed unnecessary comments --- src/TableGateway/Feature/GlobalAdapterFeature.php | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/TableGateway/Feature/GlobalAdapterFeature.php b/src/TableGateway/Feature/GlobalAdapterFeature.php index 94607b6447..87d79b3021 100644 --- a/src/TableGateway/Feature/GlobalAdapterFeature.php +++ b/src/TableGateway/Feature/GlobalAdapterFeature.php @@ -17,11 +17,6 @@ class GlobalAdapterFeature extends AbstractFeature /** @var Adapter[] */ protected static $staticAdapters = []; - /** - * Set static adapter - * - * @param Adapter $adapter - */ public static function setStaticAdapter(Adapter $adapter) : void { $class = static::class; @@ -32,12 +27,6 @@ public static function setStaticAdapter(Adapter $adapter) : void } } - /** - * Get static adapter - * - * @throws Exception\RuntimeException - * @return Adapter - */ public static function getStaticAdapter() : Adapter { $class = static::class; From e7c1ca31266d85c93af9d8e0156065c62c26aa70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Thu, 14 Mar 2019 14:30:18 +0100 Subject: [PATCH 22/33] Nullable and optional arguments, which are marked as = null, must have the ? symbol present --- src/TableGateway/Feature/MetadataFeature.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TableGateway/Feature/MetadataFeature.php b/src/TableGateway/Feature/MetadataFeature.php index 1e1410d65d..cf44bbde6c 100644 --- a/src/TableGateway/Feature/MetadataFeature.php +++ b/src/TableGateway/Feature/MetadataFeature.php @@ -24,7 +24,7 @@ class MetadataFeature extends AbstractFeature * * @param MetadataInterface $metadata */ - public function __construct(MetadataInterface $metadata = null) + public function __construct(?MetadataInterface $metadata = null) { if ($metadata) { $this->metadata = $metadata; From f6b2c1c706be9939fe366639d84bf97d8695885d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Thu, 14 Mar 2019 14:31:25 +0100 Subject: [PATCH 23/33] Removed null initializations, removed unnecessary comments --- src/TableGateway/AbstractTableGateway.php | 2 +- src/TableGateway/Feature/MasterSlaveFeature.php | 17 ++++------------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/TableGateway/AbstractTableGateway.php b/src/TableGateway/AbstractTableGateway.php index c2ab2640b3..45d8efb1e4 100644 --- a/src/TableGateway/AbstractTableGateway.php +++ b/src/TableGateway/AbstractTableGateway.php @@ -49,7 +49,7 @@ abstract class AbstractTableGateway implements TableGatewayInterface protected $resultSetPrototype = null; /** @var Sql */ - protected $sql = null; + protected $sql; /** @var int */ protected $lastInsertValue = null; diff --git a/src/TableGateway/Feature/MasterSlaveFeature.php b/src/TableGateway/Feature/MasterSlaveFeature.php index 4e04ab12a0..1cf8f3789d 100644 --- a/src/TableGateway/Feature/MasterSlaveFeature.php +++ b/src/TableGateway/Feature/MasterSlaveFeature.php @@ -15,21 +15,15 @@ class MasterSlaveFeature extends AbstractFeature { /** @var AdapterInterface */ - protected $slaveAdapter = null; + protected $slaveAdapter; /** @var Sql */ - protected $masterSql = null; + protected $masterSql; /** @var Sql */ - protected $slaveSql = null; + protected $slaveSql; - /** - * Constructor - * - * @param AdapterInterface $slaveAdapter - * @param Sql|null $slaveSql - */ - public function __construct(AdapterInterface $slaveAdapter, Sql $slaveSql = null) + public function __construct(AdapterInterface $slaveAdapter, ?Sql $slaveSql = null) { $this->slaveAdapter = $slaveAdapter; if ($slaveSql) { @@ -42,9 +36,6 @@ public function getSlaveAdapter() : AdapterInterface return $this->slaveAdapter; } - /** - * @return Sql - */ public function getSlaveSql() : Sql { return $this->slaveSql; From 7cc7a8145ba4d7b32dfe5a47a2f61b52686367ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Thu, 14 Mar 2019 14:32:39 +0100 Subject: [PATCH 24/33] Removed null initializations, removed unnecessary comments --- src/TableGateway/Feature/MetadataFeature.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/TableGateway/Feature/MetadataFeature.php b/src/TableGateway/Feature/MetadataFeature.php index cf44bbde6c..9cf1f7a43c 100644 --- a/src/TableGateway/Feature/MetadataFeature.php +++ b/src/TableGateway/Feature/MetadataFeature.php @@ -17,16 +17,11 @@ class MetadataFeature extends AbstractFeature { /** @var MetadataInterface */ - protected $metadata = null; + protected $metadata; - /** - * Constructor - * - * @param MetadataInterface $metadata - */ public function __construct(?MetadataInterface $metadata = null) { - if ($metadata) { + if ($metadata !== null) { $this->metadata = $metadata; } $this->sharedData['metadata'] = [ From 67d4518e42ae296eae243614a25ea7015613cd5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Thu, 14 Mar 2019 14:36:04 +0100 Subject: [PATCH 25/33] Declared argument types, removed unnecessary comments, updated return type hints in DocBlock --- src/TableGateway/Feature/SequenceFeature.php | 24 ++++---------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/src/TableGateway/Feature/SequenceFeature.php b/src/TableGateway/Feature/SequenceFeature.php index 1813427455..4220695b12 100644 --- a/src/TableGateway/Feature/SequenceFeature.php +++ b/src/TableGateway/Feature/SequenceFeature.php @@ -15,30 +15,20 @@ class SequenceFeature extends AbstractFeature { - /** @var string */ - protected $primaryKeyField; + protected $primaryKeyField = ''; - /** @var string */ - protected $sequenceName; + protected $sequenceName = ''; /** @var int */ protected $sequenceValue; - /** - * @param string $primaryKeyField - * @param string $sequenceName - */ - public function __construct($primaryKeyField, $sequenceName) + public function __construct(string $primaryKeyField, string $sequenceName) { $this->primaryKeyField = $primaryKeyField; $this->sequenceName = $sequenceName; } - /** - * @param Insert $insert - * @return Insert - */ public function preInsert(Insert $insert) : Insert { $columns = $insert->getRawState('columns'); @@ -58,10 +48,6 @@ public function preInsert(Insert $insert) : Insert return $insert; } - /** - * @param StatementInterface $statement - * @param ResultInterface $result - */ public function postInsert(StatementInterface $statement, ResultInterface $result) : void { if ($this->sequenceValue !== null) { @@ -71,7 +57,7 @@ public function postInsert(StatementInterface $statement, ResultInterface $resul /** * Generate a new value from the specified sequence in the database, and return it. - * @return int + * @return int|null */ public function nextSequenceId() : ?int { @@ -99,7 +85,7 @@ public function nextSequenceId() : ?int /** * Return the most recent value from the specified sequence in the database. - * @return int + * @return int|null */ public function lastSequenceId() : ?int { From c476b86a16f445a1f7c9f9481cfba0467c3945c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Thu, 14 Mar 2019 14:41:07 +0100 Subject: [PATCH 26/33] Removed unnecessary comments, declared argument types --- src/TableGateway/AbstractTableGateway.php | 111 ++-------------------- 1 file changed, 6 insertions(+), 105 deletions(-) diff --git a/src/TableGateway/AbstractTableGateway.php b/src/TableGateway/AbstractTableGateway.php index 45d8efb1e4..389cb678ec 100644 --- a/src/TableGateway/AbstractTableGateway.php +++ b/src/TableGateway/AbstractTableGateway.php @@ -54,20 +54,11 @@ abstract class AbstractTableGateway implements TableGatewayInterface /** @var int */ protected $lastInsertValue = null; - /** - * @return bool - */ public function isInitialized() : bool { return $this->isInitialized; } - /** - * Initialize - * - * @throws Exception\RuntimeException - * @return void - */ public function initialize() : void { if ($this->isInitialized) { @@ -102,55 +93,31 @@ public function initialize() : void $this->isInitialized = true; } - /** - * Get table name - * - * @return string - */ public function getTable() : string { return $this->table; } - /** - * Get adapter - * - * @return AdapterInterface - */ public function getAdapter() : AdapterInterface { return $this->adapter; } - /** - * @return array - */ public function getColumns() : array { return $this->columns; } - /** - * @return Feature\FeatureSet - */ public function getFeatureSet() : Feature\FeatureSet { return $this->featureSet; } - /** - * Get select result prototype - * - * @return ResultSetInterface - */ public function getResultSetPrototype() : ResultSetInterface { return $this->resultSetPrototype; } - /** - * @return Sql - */ public function getSql() : Sql { return $this->sql; @@ -179,10 +146,6 @@ public function select($where = null) : ResultSetInterface return $this->selectWith($select); } - /** - * @param Select $select - * @return ResultSetInterface - */ public function selectWith(Select $select) : ResultSetInterface { if (! $this->isInitialized) { @@ -191,11 +154,6 @@ public function selectWith(Select $select) : ResultSetInterface return $this->executeSelect($select); } - /** - * @param Select $select - * @return ResultSetInterface - * @throws Exception\RuntimeException - */ protected function executeSelect(Select $select) : ResultSetInterface { $selectState = $select->getRawState(); @@ -246,10 +204,6 @@ public function insert($set) : int return $this->executeInsert($insert); } - /** - * @param Insert $insert - * @return int - */ public function insertWith(Insert $insert) : int { if (! $this->isInitialized) { @@ -258,15 +212,9 @@ public function insertWith(Insert $insert) : int return $this->executeInsert($insert); } - /** - * @todo add $columns support - * - * @param Insert $insert - * @return int - * @throws Exception\RuntimeException - */ protected function executeInsert(Insert $insert) : int { + // @todo add $columns support $insertState = $insert->getRawState(); if ($insertState['table'] != $this->table) { throw new Exception\RuntimeException( @@ -331,10 +279,6 @@ public function update($set, $where = null, array $joins = null) : int return $this->executeUpdate($update); } - /** - * @param \Zend\Db\Sql\Update $update - * @return int - */ public function updateWith(Update $update) : int { if (! $this->isInitialized) { @@ -343,15 +287,9 @@ public function updateWith(Update $update) : int return $this->executeUpdate($update); } - /** - * @todo add $columns support - * - * @param Update $update - * @return int - * @throws Exception\RuntimeException - */ protected function executeUpdate(Update $update) : int { + // @todo add $columns support $updateState = $update->getRawState(); if ($updateState['table'] != $this->table) { throw new Exception\RuntimeException( @@ -403,25 +341,15 @@ public function delete($where) : int return $this->executeDelete($delete); } - /** - * @param Delete $delete - * @return int - */ public function deleteWith(Delete $delete) : int { $this->initialize(); return $this->executeDelete($delete); } - /** - * @todo add $columns support - * - * @param Delete $delete - * @return int - * @throws Exception\RuntimeException - */ protected function executeDelete(Delete $delete) : int { + // @todo add $columns support $deleteState = $delete->getRawState(); if ($deleteState['table'] != $this->table) { throw new Exception\RuntimeException( @@ -441,24 +369,12 @@ protected function executeDelete(Delete $delete) : int return $result->getAffectedRows(); } - /** - * Get last insert value - * - * @return int - */ public function getLastInsertValue() : int { return $this->lastInsertValue; } - /** - * __get - * - * @param string $property - * @throws Exception\InvalidArgumentException - * @return mixed - */ - public function __get($property) + public function __get(string $property) { switch (strtolower($property)) { case 'lastinsertvalue': @@ -474,13 +390,7 @@ public function __get($property) throw new Exception\InvalidArgumentException('Invalid magic property access in ' . __CLASS__ . '::__get()'); } - /** - * @param string $property - * @param mixed $value - * @return mixed - * @throws Exception\InvalidArgumentException - */ - public function __set($property, $value) + public function __set(string $property, $value) { if ($this->featureSet->canCallMagicSet($property)) { return $this->featureSet->callMagicSet($property, $value); @@ -488,13 +398,7 @@ public function __set($property, $value) throw new Exception\InvalidArgumentException('Invalid magic property access in ' . __CLASS__ . '::__set()'); } - /** - * @param $method - * @param $arguments - * @return mixed - * @throws Exception\InvalidArgumentException - */ - public function __call($method, $arguments) + public function __call(string $method, array $arguments) { if ($this->featureSet->canCallMagicCall($method)) { return $this->featureSet->callMagicCall($method, $arguments); @@ -506,9 +410,6 @@ public function __call($method, $arguments) )); } - /** - * __clone - */ public function __clone() { $this->resultSetPrototype = isset($this->resultSetPrototype) ? clone $this->resultSetPrototype : null; From 8c29ecd77e63fd669e233915c6a85b417aeefc26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Thu, 14 Mar 2019 14:41:31 +0100 Subject: [PATCH 27/33] Removed empty line --- src/TableGateway/AbstractTableGateway.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/TableGateway/AbstractTableGateway.php b/src/TableGateway/AbstractTableGateway.php index 389cb678ec..a539a3f8d8 100644 --- a/src/TableGateway/AbstractTableGateway.php +++ b/src/TableGateway/AbstractTableGateway.php @@ -23,7 +23,6 @@ use Zend\Db\TableGateway\Feature\EventFeatureEventsInterface; /** - * * @property AdapterInterface $adapter * @property int $lastInsertValue * @property string $table From 3b1c803bcb7da1702413c42226d2327201468269 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Thu, 14 Mar 2019 14:43:02 +0100 Subject: [PATCH 28/33] Comment tags @param, @throws and @return should not be aligned or contain multiple spaces between the tag, type and description --- src/TableGateway/AbstractTableGateway.php | 10 +++---- src/TableGateway/Feature/EventFeature.php | 26 +++++++++---------- .../EventFeature/TableGatewayEvent.php | 14 +++++----- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/TableGateway/AbstractTableGateway.php b/src/TableGateway/AbstractTableGateway.php index a539a3f8d8..0382d58bf1 100644 --- a/src/TableGateway/AbstractTableGateway.php +++ b/src/TableGateway/AbstractTableGateway.php @@ -190,7 +190,7 @@ protected function executeSelect(Select $select) : ResultSetInterface /** * Insert * - * @param array $set + * @param array $set * @return int */ public function insert($set) : int @@ -251,9 +251,9 @@ protected function executeInsert(Insert $insert) : int /** * Update * - * @param array $set - * @param string|array|\Closure $where - * @param null|array $joins + * @param array $set + * @param string|array|\Closure $where + * @param null|array $joins * @return int */ public function update($set, $where = null, array $joins = null) : int @@ -323,7 +323,7 @@ protected function executeUpdate(Update $update) : int /** * Delete * - * @param Where|\Closure|string|array $where + * @param Where|\Closure|string|array $where * @return int */ public function delete($where) : int diff --git a/src/TableGateway/Feature/EventFeature.php b/src/TableGateway/Feature/EventFeature.php index 90f210c11c..21fa081ad0 100644 --- a/src/TableGateway/Feature/EventFeature.php +++ b/src/TableGateway/Feature/EventFeature.php @@ -87,7 +87,7 @@ public function postInitialize() : void * Triggers the "preSelect" event mapping the following parameters: * - $select as "select" * - * @param Select $select + * @param Select $select * @return void */ public function preSelect(Select $select) : void @@ -105,9 +105,9 @@ public function preSelect(Select $select) : void * - $result as "result" * - $resultSet as "result_set" * - * @param StatementInterface $statement - * @param ResultInterface $result - * @param ResultSetInterface $resultSet + * @param StatementInterface $statement + * @param ResultInterface $result + * @param ResultSetInterface $resultSet * @return void */ public function postSelect(StatementInterface $statement, ResultInterface $result, ResultSetInterface $resultSet) : void @@ -127,7 +127,7 @@ public function postSelect(StatementInterface $statement, ResultInterface $resul * Triggers the "preInsert" event mapping the following parameters: * - $insert as "insert" * - * @param Insert $insert + * @param Insert $insert * @return void */ public function preInsert(Insert $insert) : void @@ -144,8 +144,8 @@ public function preInsert(Insert $insert) : void * - $statement as "statement" * - $result as "result" * - * @param StatementInterface $statement - * @param ResultInterface $result + * @param StatementInterface $statement + * @param ResultInterface $result * @return void */ public function postInsert(StatementInterface $statement, ResultInterface $result) : void @@ -161,7 +161,7 @@ public function postInsert(StatementInterface $statement, ResultInterface $resul * Triggers the "preUpdate" event mapping the following parameters: * - $update as "update" * - * @param Update $update + * @param Update $update * @return void */ public function preUpdate(Update $update) : void @@ -178,8 +178,8 @@ public function preUpdate(Update $update) : void * - $statement as "statement" * - $result as "result" * - * @param StatementInterface $statement - * @param ResultInterface $result + * @param StatementInterface $statement + * @param ResultInterface $result * @return void */ public function postUpdate(StatementInterface $statement, ResultInterface $result) : void @@ -195,7 +195,7 @@ public function postUpdate(StatementInterface $statement, ResultInterface $resul * Triggers the "preDelete" event mapping the following parameters: * - $delete as "delete" * - * @param Delete $delete + * @param Delete $delete * @return void */ public function preDelete(Delete $delete) : void @@ -212,8 +212,8 @@ public function preDelete(Delete $delete) : void * - $statement as "statement" * - $result as "result" * - * @param StatementInterface $statement - * @param ResultInterface $result + * @param StatementInterface $statement + * @param ResultInterface $result * @return void */ public function postDelete(StatementInterface $statement, ResultInterface $result) : void diff --git a/src/TableGateway/Feature/EventFeature/TableGatewayEvent.php b/src/TableGateway/Feature/EventFeature/TableGatewayEvent.php index 085ee88ff8..a18425f7e9 100644 --- a/src/TableGateway/Feature/EventFeature/TableGatewayEvent.php +++ b/src/TableGateway/Feature/EventFeature/TableGatewayEvent.php @@ -51,8 +51,8 @@ public function getParams() /** * Get a single parameter by name * - * @param string $name - * @param mixed $default Default value to return if parameter does not exist + * @param string $name + * @param mixed $default Default value to return if parameter does not exist * @return mixed */ public function getParam($name, $default = null) @@ -63,7 +63,7 @@ public function getParam($name, $default = null) /** * Set the event name * - * @param string $name + * @param string $name * @return void */ public function setName($name) : void @@ -85,7 +85,7 @@ public function setTarget($target) : void /** * Set event parameters * - * @param string $params + * @param string $params * @return void */ public function setParams($params) : void @@ -96,8 +96,8 @@ public function setParams($params) : void /** * Set a single parameter by key * - * @param string $name - * @param mixed $value + * @param string $name + * @param mixed $value * @return void */ public function setParam($name, $value) : void @@ -108,7 +108,7 @@ public function setParam($name, $value) : void /** * Indicate whether or not the parent EventManagerInterface should stop propagating events * - * @param bool $flag + * @param bool $flag * @return void */ public function stopPropagation($flag = true) : void From e45af7c18610af9856409944c2377e5bdd6f8344 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Thu, 14 Mar 2019 14:45:02 +0100 Subject: [PATCH 29/33] Removed null initializations --- src/TableGateway/AbstractTableGateway.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/TableGateway/AbstractTableGateway.php b/src/TableGateway/AbstractTableGateway.php index 0382d58bf1..ed968354bb 100644 --- a/src/TableGateway/AbstractTableGateway.php +++ b/src/TableGateway/AbstractTableGateway.php @@ -33,25 +33,25 @@ abstract class AbstractTableGateway implements TableGatewayInterface protected $isInitialized = false; /** @var AdapterInterface */ - protected $adapter = null; + protected $adapter; /** @var string|array|TableIdentifier */ - protected $table = null; + protected $table; /** @var array */ protected $columns = []; /** @var Feature\FeatureSet */ - protected $featureSet = null; + protected $featureSet; /** @var ResultSetInterface */ - protected $resultSetPrototype = null; + protected $resultSetPrototype; /** @var Sql */ protected $sql; /** @var int */ - protected $lastInsertValue = null; + protected $lastInsertValue; public function isInitialized() : bool { From d4b0340d35636a10e3065b5f746a889a3b9afe0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Thu, 14 Mar 2019 14:48:11 +0100 Subject: [PATCH 30/33] Apply strict comparison --- src/TableGateway/Feature/EventFeature.php | 2 +- src/TableGateway/Feature/MetadataFeature.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/TableGateway/Feature/EventFeature.php b/src/TableGateway/Feature/EventFeature.php index 21fa081ad0..6a752cab90 100644 --- a/src/TableGateway/Feature/EventFeature.php +++ b/src/TableGateway/Feature/EventFeature.php @@ -66,7 +66,7 @@ public function getEvent() : TableGatewayEvent */ public function preInitialize() : void { - if (get_class($this->tableGateway) != 'Zend\Db\TableGateway\TableGateway') { + if (get_class($this->tableGateway) !== 'Zend\Db\TableGateway\TableGateway') { $this->eventManager->addIdentifiers([get_class($this->tableGateway)]); } diff --git a/src/TableGateway/Feature/MetadataFeature.php b/src/TableGateway/Feature/MetadataFeature.php index 9cf1f7a43c..d5f8afd72f 100644 --- a/src/TableGateway/Feature/MetadataFeature.php +++ b/src/TableGateway/Feature/MetadataFeature.php @@ -56,7 +56,7 @@ public function postInitialize() : void foreach ($m->getConstraints($t->table) as $constraint) { /** @var $constraint \Zend\Db\Metadata\Object\ConstraintObject */ - if ($constraint->getType() == 'PRIMARY KEY') { + if ($constraint->getType() === 'PRIMARY KEY') { $pkc = $constraint; break; } From 8dd0cc1875506999bb5ed6f2c736fe68e935e36e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Thu, 14 Mar 2019 14:50:34 +0100 Subject: [PATCH 31/33] Use instanceof operator --- src/TableGateway/Feature/EventFeature.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TableGateway/Feature/EventFeature.php b/src/TableGateway/Feature/EventFeature.php index 6a752cab90..f7fa007c28 100644 --- a/src/TableGateway/Feature/EventFeature.php +++ b/src/TableGateway/Feature/EventFeature.php @@ -66,7 +66,7 @@ public function getEvent() : TableGatewayEvent */ public function preInitialize() : void { - if (get_class($this->tableGateway) !== 'Zend\Db\TableGateway\TableGateway') { + if (!$this->tableGateway instanceof TableGateway) { $this->eventManager->addIdentifiers([get_class($this->tableGateway)]); } From e4f8dffcd78051d69b6996f9b6e6f7b076b5a0ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Thu, 14 Mar 2019 14:54:06 +0100 Subject: [PATCH 32/33] Added single space after NOT operator, break line before 120 characters --- src/TableGateway/Feature/EventFeature.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/TableGateway/Feature/EventFeature.php b/src/TableGateway/Feature/EventFeature.php index f7fa007c28..dfa23d52f5 100644 --- a/src/TableGateway/Feature/EventFeature.php +++ b/src/TableGateway/Feature/EventFeature.php @@ -66,7 +66,7 @@ public function getEvent() : TableGatewayEvent */ public function preInitialize() : void { - if (!$this->tableGateway instanceof TableGateway) { + if (! $this->tableGateway instanceof TableGateway) { $this->eventManager->addIdentifiers([get_class($this->tableGateway)]); } @@ -110,8 +110,11 @@ public function preSelect(Select $select) : void * @param ResultSetInterface $resultSet * @return void */ - public function postSelect(StatementInterface $statement, ResultInterface $result, ResultSetInterface $resultSet) : void - { + public function postSelect( + StatementInterface $statement, + ResultInterface $result, + ResultSetInterface $resultSet + ) : void { $this->event->setName(static::EVENT_POST_SELECT); $this->event->setParams([ 'statement' => $statement, From d21616ff3e374e9ad2d103c77e707f001df498a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Thu, 14 Mar 2019 14:59:39 +0100 Subject: [PATCH 33/33] Updated argument type hint --- src/TableGateway/Feature/EventFeature/TableGatewayEvent.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TableGateway/Feature/EventFeature/TableGatewayEvent.php b/src/TableGateway/Feature/EventFeature/TableGatewayEvent.php index a18425f7e9..9f38cfa203 100644 --- a/src/TableGateway/Feature/EventFeature/TableGatewayEvent.php +++ b/src/TableGateway/Feature/EventFeature/TableGatewayEvent.php @@ -85,7 +85,7 @@ public function setTarget($target) : void /** * Set event parameters * - * @param string $params + * @param array|ArrayAccess $params * @return void */ public function setParams($params) : void