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`. diff --git a/src/TableGateway/AbstractTableGateway.php b/src/TableGateway/AbstractTableGateway.php index b97a0dc293..ed968354bb 100644 --- a/src/TableGateway/AbstractTableGateway.php +++ b/src/TableGateway/AbstractTableGateway.php @@ -1,12 +1,12 @@ isInitialized; } - /** - * Initialize - * - * @throws Exception\RuntimeException - * @return null - */ - public function initialize() + public function initialize() : void { if ($this->isInitialized) { return; @@ -119,56 +92,32 @@ public function initialize() $this->isInitialized = true; } - /** - * Get table name - * - * @return string - */ - public function getTable() + public function getTable() : string { return $this->table; } - /** - * Get adapter - * - * @return AdapterInterface - */ - public function getAdapter() + public function getAdapter() : AdapterInterface { return $this->adapter; } - /** - * @return array - */ - public function getColumns() + public function getColumns() : array { return $this->columns; } - /** - * @return Feature\FeatureSet - */ - public function getFeatureSet() + public function getFeatureSet() : Feature\FeatureSet { return $this->featureSet; } - /** - * Get select result prototype - * - * @return ResultSetInterface - */ - public function getResultSetPrototype() + public function getResultSetPrototype() : ResultSetInterface { return $this->resultSetPrototype; } - /** - * @return Sql - */ - public function getSql() + public function getSql() : Sql { return $this->sql; } @@ -179,7 +128,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(); @@ -196,11 +145,7 @@ public function select($where = null) return $this->selectWith($select); } - /** - * @param Select $select - * @return ResultSetInterface - */ - public function selectWith(Select $select) + public function selectWith(Select $select) : ResultSetInterface { if (! $this->isInitialized) { $this->initialize(); @@ -208,12 +153,7 @@ public function selectWith(Select $select) return $this->executeSelect($select); } - /** - * @param 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 @@ -250,10 +190,10 @@ protected function executeSelect(Select $select) /** * Insert * - * @param array $set + * @param array $set * @return int */ - public function insert($set) + public function insert($set) : int { if (! $this->isInitialized) { $this->initialize(); @@ -263,11 +203,7 @@ public function insert($set) return $this->executeInsert($insert); } - /** - * @param Insert $insert - * @return int - */ - public function insertWith(Insert $insert) + public function insertWith(Insert $insert) : int { if (! $this->isInitialized) { $this->initialize(); @@ -275,15 +211,9 @@ public function insertWith(Insert $insert) return $this->executeInsert($insert); } - /** - * @todo add $columns support - * - * @param Insert $insert - * @return int - * @throws Exception\RuntimeException - */ - protected function executeInsert(Insert $insert) + protected function executeInsert(Insert $insert) : int { + // @todo add $columns support $insertState = $insert->getRawState(); if ($insertState['table'] != $this->table) { throw new Exception\RuntimeException( @@ -321,12 +251,12 @@ protected function executeInsert(Insert $insert) /** * 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) + public function update($set, $where = null, array $joins = null) : int { if (! $this->isInitialized) { $this->initialize(); @@ -348,11 +278,7 @@ public function update($set, $where = null, array $joins = null) return $this->executeUpdate($update); } - /** - * @param \Zend\Db\Sql\Update $update - * @return int - */ - public function updateWith(Update $update) + public function updateWith(Update $update) : int { if (! $this->isInitialized) { $this->initialize(); @@ -360,15 +286,9 @@ public function updateWith(Update $update) return $this->executeUpdate($update); } - /** - * @todo add $columns support - * - * @param Update $update - * @return int - * @throws Exception\RuntimeException - */ - protected function executeUpdate(Update $update) + protected function executeUpdate(Update $update) : int { + // @todo add $columns support $updateState = $update->getRawState(); if ($updateState['table'] != $this->table) { throw new Exception\RuntimeException( @@ -403,10 +323,10 @@ protected function executeUpdate(Update $update) /** * Delete * - * @param Where|\Closure|string|array $where + * @param Where|\Closure|string|array $where * @return int */ - public function delete($where) + public function delete($where) : int { if (! $this->isInitialized) { $this->initialize(); @@ -420,25 +340,15 @@ public function delete($where) return $this->executeDelete($delete); } - /** - * @param Delete $delete - * @return int - */ - public function deleteWith(Delete $delete) + 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) + protected function executeDelete(Delete $delete) : int { + // @todo add $columns support $deleteState = $delete->getRawState(); if ($deleteState['table'] != $this->table) { throw new Exception\RuntimeException( @@ -458,24 +368,12 @@ protected function executeDelete(Delete $delete) return $result->getAffectedRows(); } - /** - * Get last insert value - * - * @return int - */ - public function getLastInsertValue() + 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': @@ -491,13 +389,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); @@ -505,13 +397,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); @@ -523,12 +409,9 @@ public function __call($method, $arguments) )); } - /** - * __clone - */ 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/Exception/ExceptionInterface.php b/src/TableGateway/Exception/ExceptionInterface.php index 7410e597cf..af04143ecf 100644 --- a/src/TableGateway/Exception/ExceptionInterface.php +++ b/src/TableGateway/Exception/ExceptionInterface.php @@ -1,12 +1,12 @@ 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 { 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); - */ } diff --git a/src/TableGateway/Feature/EventFeature.php b/src/TableGateway/Feature/EventFeature.php index ea3c70e4ff..dfa23d52f5 100644 --- a/src/TableGateway/Feature/EventFeature.php +++ b/src/TableGateway/Feature/EventFeature.php @@ -1,12 +1,12 @@ eventManager = ($eventManager instanceof EventManagerInterface) - ? $eventManager - : new EventManager; + $this->eventManager = $eventManager ?? new EventManager; $this->eventManager->addIdentifiers([ - 'Zend\Db\TableGateway\TableGateway', + TableGateway::class, ]); - $this->event = ($tableGatewayEvent) ?: new EventFeature\TableGatewayEvent(); + $this->event = $tableGatewayEvent ?: new TableGatewayEvent(); } - /** - * Retrieve composed event manager instance - * - * @return EventManagerInterface - */ - public function getEventManager() + public function getEventManager() : EventManagerInterface { return $this->eventManager; } - /** - * Retrieve composed event instance - * - * @return EventFeature\TableGatewayEvent - */ - public function getEvent() + public function getEvent() : TableGatewayEvent { return $this->event; } @@ -82,9 +64,9 @@ public function getEvent() * * @return void */ - public function preInitialize() + 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)]); } @@ -93,12 +75,7 @@ public function preInitialize() $this->eventManager->triggerEvent($this->event); } - /** - * Trigger the "postInitialize" event - * - * @return void - */ - public function postInitialize() + public function postInitialize() : void { $this->event->setName(static::EVENT_POST_INITIALIZE); $this->eventManager->triggerEvent($this->event); @@ -110,10 +87,10 @@ public function postInitialize() * Triggers the "preSelect" event mapping the following parameters: * - $select as "select" * - * @param Select $select + * @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]); @@ -128,13 +105,16 @@ public function preSelect(Select $select) * - $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) - { + public function postSelect( + StatementInterface $statement, + ResultInterface $result, + ResultSetInterface $resultSet + ) : void { $this->event->setName(static::EVENT_POST_SELECT); $this->event->setParams([ 'statement' => $statement, @@ -150,10 +130,10 @@ 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) + public function preInsert(Insert $insert) : void { $this->event->setName(static::EVENT_PRE_INSERT); $this->event->setParams(['insert' => $insert]); @@ -167,17 +147,14 @@ public function preInsert(Insert $insert) * - $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) + public function postInsert(StatementInterface $statement, ResultInterface $result) : void { $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); } @@ -187,10 +164,10 @@ 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) + public function preUpdate(Update $update) : void { $this->event->setName(static::EVENT_PRE_UPDATE); $this->event->setParams(['update' => $update]); @@ -204,17 +181,14 @@ public function preUpdate(Update $update) * - $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) + public function postUpdate(StatementInterface $statement, ResultInterface $result) : void { $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); } @@ -224,10 +198,10 @@ 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) + public function preDelete(Delete $delete) : void { $this->event->setName(static::EVENT_PRE_DELETE); $this->event->setParams(['delete' => $delete]); @@ -241,17 +215,14 @@ public function preDelete(Delete $delete) * - $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) + public function postDelete(StatementInterface $statement, ResultInterface $result) : void { $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); } } diff --git a/src/TableGateway/Feature/EventFeature/TableGatewayEvent.php b/src/TableGateway/Feature/EventFeature/TableGatewayEvent.php index f014faa485..9f38cfa203 100644 --- a/src/TableGateway/Feature/EventFeature/TableGatewayEvent.php +++ b/src/TableGateway/Feature/EventFeature/TableGatewayEvent.php @@ -1,40 +1,29 @@ name; } @@ -42,7 +31,7 @@ public function getName() /** * Get target/context from which event was triggered * - * @return null|string|object + * @return null|string|object|AbstractTableGateway */ public function getTarget() { @@ -52,7 +41,7 @@ public function getTarget() /** * Get parameters passed to the event * - * @return array|\ArrayAccess + * @return array|ArrayAccess */ public function getParams() { @@ -62,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) @@ -74,10 +63,10 @@ public function getParam($name, $default = null) /** * Set the event name * - * @param string $name + * @param string $name * @return void */ - public function setName($name) + public function setName($name) : void { $this->name = $name; } @@ -85,10 +74,10 @@ public function setName($name) /** * Set the event target/context * - * @param null|string|object $target + * @param null|string|object|AbstractTableGateway $target * @return void */ - public function setTarget($target) + public function setTarget($target) : void { $this->target = $target; } @@ -96,10 +85,10 @@ public function setTarget($target) /** * Set event parameters * - * @param string $params + * @param array|ArrayAccess $params * @return void */ - public function setParams($params) + public function setParams($params) : void { $this->params = $params; } @@ -107,11 +96,11 @@ public function setParams($params) /** * 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) + public function setParam($name, $value) : void { $this->params[$name] = $value; } @@ -119,12 +108,11 @@ public function setParam($name, $value) /** * Indicate whether or not the parent EventManagerInterface should stop propagating events * - * @param bool $flag + * @param bool $flag * @return void */ - public function stopPropagation($flag = true) + public function stopPropagation($flag = true) : void { - return; } /** @@ -132,7 +120,7 @@ public function stopPropagation($flag = true) * * @return bool */ - public function propagationIsStopped() + public function propagationIsStopped() : bool { return false; } diff --git a/src/TableGateway/Feature/EventFeatureEventsInterface.php b/src/TableGateway/Feature/EventFeatureEventsInterface.php index 291ebcd0aa..d4ce8ede95 100644 --- a/src/TableGateway/Feature/EventFeatureEventsInterface.php +++ b/src/TableGateway/Feature/EventFeatureEventsInterface.php @@ -1,12 +1,12 @@ tableGateway = $tableGateway; foreach ($this->features as $feature) { @@ -61,10 +54,10 @@ public function getFeatureByClassName($featureClassName) } /** - * @param array $features + * @param AbstractFeature[] $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); @@ -72,11 +65,7 @@ public function addFeatures(array $features) return $this; } - /** - * @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 +74,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)) { @@ -97,43 +86,22 @@ public function apply($method, $args) } } - /** - * @param string $property - * @return bool - */ - public function canCallMagicGet($property) + 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; - return $return; } - /** - * @param string $property - * @return bool - */ - public function canCallMagicSet($property) + 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; - return $return; } /** @@ -141,7 +109,7 @@ public function callMagicSet($property, $value) * @param string $method * @return bool */ - public function canCallMagicCall($method) + public function canCallMagicCall(string $method) : bool { if (! empty($this->features)) { foreach ($this->features as $feature) { @@ -153,20 +121,12 @@ public function canCallMagicCall($method) 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)) { return $feature->$method($arguments); } } - - return; } } diff --git a/src/TableGateway/Feature/GlobalAdapterFeature.php b/src/TableGateway/Feature/GlobalAdapterFeature.php index 7eccdcb207..87d79b3021 100644 --- a/src/TableGateway/Feature/GlobalAdapterFeature.php +++ b/src/TableGateway/Feature/GlobalAdapterFeature.php @@ -1,12 +1,12 @@ tableGateway->adapter = self::getStaticAdapter(); } diff --git a/src/TableGateway/Feature/MasterSlaveFeature.php b/src/TableGateway/Feature/MasterSlaveFeature.php index 07d36f954d..1cf8f3789d 100644 --- a/src/TableGateway/Feature/MasterSlaveFeature.php +++ b/src/TableGateway/Feature/MasterSlaveFeature.php @@ -1,12 +1,12 @@ slaveAdapter = $slaveAdapter; if ($slaveSql) { @@ -43,15 +31,12 @@ public function __construct(AdapterInterface $slaveAdapter, Sql $slaveSql = null } } - public function getSlaveAdapter() + public function getSlaveAdapter() : AdapterInterface { return $this->slaveAdapter; } - /** - * @return Sql - */ - public function getSlaveSql() + public function getSlaveSql() : Sql { return $this->slaveSql; } @@ -59,7 +44,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 +60,7 @@ public function postInitialize() * preSelect() * Replace adapter with slave temporarily */ - public function preSelect() + public function preSelect() : void { $this->tableGateway->sql = $this->slaveSql; } @@ -84,7 +69,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 9a78f60a90..d5f8afd72f 100644 --- a/src/TableGateway/Feature/MetadataFeature.php +++ b/src/TableGateway/Feature/MetadataFeature.php @@ -1,12 +1,12 @@ metadata = $metadata; } $this->sharedData['metadata'] = [ @@ -37,7 +30,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); @@ -63,7 +56,7 @@ public function postInitialize() 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; } diff --git a/src/TableGateway/Feature/RowGatewayFeature.php b/src/TableGateway/Feature/RowGatewayFeature.php index a1482922ef..22cfbda985 100644 --- a/src/TableGateway/Feature/RowGatewayFeature.php +++ b/src/TableGateway/Feature/RowGatewayFeature.php @@ -1,35 +1,31 @@ constructorArguments = func_get_args(); } - public function postInitialize() + public function postInitialize() : void { $args = $this->constructorArguments; @@ -58,7 +54,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( diff --git a/src/TableGateway/Feature/SequenceFeature.php b/src/TableGateway/Feature/SequenceFeature.php index 014171c24a..4220695b12 100644 --- a/src/TableGateway/Feature/SequenceFeature.php +++ b/src/TableGateway/Feature/SequenceFeature.php @@ -1,12 +1,12 @@ primaryKeyField = $primaryKeyField; $this->sequenceName = $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'); @@ -64,11 +48,7 @@ public function preInsert(Insert $insert) return $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; @@ -77,9 +57,9 @@ 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() + public function nextSequenceId() : ?int { $platform = $this->tableGateway->adapter->getPlatform(); $platformName = $platform->getName(); @@ -92,7 +72,7 @@ public function nextSequenceId() $sql = 'SELECT NEXTVAL(\'"' . $this->sequenceName . '"\')'; break; default: - return; + return null; } $statement = $this->tableGateway->adapter->createStatement(); @@ -105,9 +85,9 @@ public function nextSequenceId() /** * Return the most recent value from the specified sequence in the database. - * @return int + * @return int|null */ - public function lastSequenceId() + public function lastSequenceId() : ?int { $platform = $this->tableGateway->adapter->getPlatform(); $platformName = $platform->getName(); @@ -120,7 +100,7 @@ public function lastSequenceId() $sql = 'SELECT CURRVAL(\'' . $this->sequenceName . '\')'; break; default: - return; + return null; } $statement = $this->tableGateway->adapter->createStatement(); diff --git a/src/TableGateway/TableGateway.php b/src/TableGateway/TableGateway.php index 3bfbf213ba..6e869eca98 100644 --- a/src/TableGateway/TableGateway.php +++ b/src/TableGateway/TableGateway.php @@ -1,12 +1,12 @@ 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) { diff --git a/src/TableGateway/TableGatewayInterface.php b/src/TableGateway/TableGatewayInterface.php index 58c7759c3f..4df303101d 100644 --- a/src/TableGateway/TableGatewayInterface.php +++ b/src/TableGateway/TableGatewayInterface.php @@ -1,12 +1,12 @@