From efbfc4c4066710fd6de4814df10a8e0b6c7428ad Mon Sep 17 00:00:00 2001 From: Dennis de Greef Date: Fri, 24 Oct 2014 01:24:09 +0200 Subject: [PATCH 1/4] Fixed annotations on Zend\Db parts --- library/Zend/Db/Adapter/Adapter.php | 1 + library/Zend/Db/Adapter/AdapterInterface.php | 14 +++++++++++++ library/Zend/Db/Sql/Ddl/Column/Blob.php | 10 +++++----- .../Db/Sql/Ddl/Column/ColumnInterface.php | 20 +++++++++++++++++++ .../Zend/Db/Sql/Ddl/Constraint/UniqueKey.php | 6 +++--- 5 files changed, 43 insertions(+), 8 deletions(-) diff --git a/library/Zend/Db/Adapter/Adapter.php b/library/Zend/Db/Adapter/Adapter.php index b4c7edffffd..6cea6bbe9a2 100644 --- a/library/Zend/Db/Adapter/Adapter.php +++ b/library/Zend/Db/Adapter/Adapter.php @@ -160,6 +160,7 @@ public function getCurrentSchema() * * @param string $sql * @param string|array|ParameterContainer $parametersOrQueryMode + * @param \Zend\Db\ResultSet\ResultSetInterface $resultPrototype * @throws Exception\InvalidArgumentException * @return Driver\StatementInterface|ResultSet\ResultSet */ diff --git a/library/Zend/Db/Adapter/AdapterInterface.php b/library/Zend/Db/Adapter/AdapterInterface.php index 57a6a73763c..054e3c35986 100644 --- a/library/Zend/Db/Adapter/AdapterInterface.php +++ b/library/Zend/Db/Adapter/AdapterInterface.php @@ -9,6 +9,8 @@ namespace Zend\Db\Adapter; +use Zend\Db\ResultSet; + /** * * @property Driver\DriverInterface $driver @@ -25,4 +27,16 @@ public function getDriver(); * @return Platform\PlatformInterface */ public function getPlatform(); + + /** + * query() is a convenience function + * + * @param string $sql + * @param string|array|ParameterContainer $parametersOrQueryMode + * @param \Zend\Db\ResultSet\ResultSetInterface $resultPrototype + * @throws Exception\InvalidArgumentException + * @return Driver\StatementInterface|ResultSet\ResultSet + */ + public function query($sql, $parametersOrQueryMode = self::QUERY_MODE_PREPARE, ResultSet\ResultSetInterface $resultPrototype = null) + } diff --git a/library/Zend/Db/Sql/Ddl/Column/Blob.php b/library/Zend/Db/Sql/Ddl/Column/Blob.php index 1892ca6039b..4c7dbd0c2a4 100644 --- a/library/Zend/Db/Sql/Ddl/Column/Blob.php +++ b/library/Zend/Db/Sql/Ddl/Column/Blob.php @@ -22,11 +22,11 @@ class Blob extends Column protected $type = 'BLOB'; /** - * @param null $name - * @param int $length - * @param bool $nullable - * @param null $default - * @param array $options + * @param string $name + * @param int $length + * @param bool $nullable + * @param null $default + * @param array $options */ public function __construct($name, $length, $nullable = false, $default = null, array $options = array()) { diff --git a/library/Zend/Db/Sql/Ddl/Column/ColumnInterface.php b/library/Zend/Db/Sql/Ddl/Column/ColumnInterface.php index 331e5254f44..282f44b4874 100644 --- a/library/Zend/Db/Sql/Ddl/Column/ColumnInterface.php +++ b/library/Zend/Db/Sql/Ddl/Column/ColumnInterface.php @@ -11,10 +11,30 @@ use Zend\Db\Sql\ExpressionInterface; +/** + * Interface ColumnInterface describes the protocol on how Column objects interact + * + * @package Zend\Db\Sql\Ddl\Column + */ interface ColumnInterface extends ExpressionInterface { + /** + * @return string + */ public function getName(); + + /** + * @return bool + */ public function isNullable(); + + /** + * @return null|string|int + */ public function getDefault(); + + /** + * @return array + */ public function getOptions(); } diff --git a/library/Zend/Db/Sql/Ddl/Constraint/UniqueKey.php b/library/Zend/Db/Sql/Ddl/Constraint/UniqueKey.php index 8d871054e18..43d0115c6d0 100644 --- a/library/Zend/Db/Sql/Ddl/Constraint/UniqueKey.php +++ b/library/Zend/Db/Sql/Ddl/Constraint/UniqueKey.php @@ -17,12 +17,12 @@ class UniqueKey extends AbstractConstraint protected $specification = 'CONSTRAINT UNIQUE KEY %s(...)'; /** - * @param string $column + * @param array $columns * @param null|string $name */ - public function __construct($column, $name = null) + public function __construct($columns, $name = null) { - $this->setColumns($column); + $this->setColumns($columns); $this->name = $name; } From 51291043be440cd963fb68db833e0da3dec78577 Mon Sep 17 00:00:00 2001 From: Dennis de Greef Date: Fri, 24 Oct 2014 01:30:06 +0200 Subject: [PATCH 2/4] Forgot a ; --- library/Zend/Db/Adapter/AdapterInterface.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/library/Zend/Db/Adapter/AdapterInterface.php b/library/Zend/Db/Adapter/AdapterInterface.php index 054e3c35986..ad6593da81b 100644 --- a/library/Zend/Db/Adapter/AdapterInterface.php +++ b/library/Zend/Db/Adapter/AdapterInterface.php @@ -37,6 +37,5 @@ public function getPlatform(); * @throws Exception\InvalidArgumentException * @return Driver\StatementInterface|ResultSet\ResultSet */ - public function query($sql, $parametersOrQueryMode = self::QUERY_MODE_PREPARE, ResultSet\ResultSetInterface $resultPrototype = null) - + public function query($sql, $parametersOrQueryMode = self::QUERY_MODE_PREPARE, ResultSet\ResultSetInterface $resultPrototype = null); } From 9935fdbe7c93fbdb36727cfe3afadd0023d95355 Mon Sep 17 00:00:00 2001 From: Dennis de Greef Date: Fri, 24 Oct 2014 01:36:13 +0200 Subject: [PATCH 3/4] Fix interface that cannot reference self, and creating mocks that expect certain set of methods --- tests/ZendTest/Db/TableGateway/Feature/FeatureSetTest.php | 4 ++-- .../Db/TableGateway/Feature/MasterSlaveFeatureTest.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/ZendTest/Db/TableGateway/Feature/FeatureSetTest.php b/tests/ZendTest/Db/TableGateway/Feature/FeatureSetTest.php index 5fb880491d8..9ae4ad36258 100644 --- a/tests/ZendTest/Db/TableGateway/Feature/FeatureSetTest.php +++ b/tests/ZendTest/Db/TableGateway/Feature/FeatureSetTest.php @@ -23,7 +23,7 @@ public function testAddFeatureThatFeatureDoesnotHasTableGatewayButFeatureSetHas( { $mockMasterAdapter = $this->getMock( 'Zend\Db\Adapter\AdapterInterface', - array('getDriver', 'getPlatform') + array('getDriver', 'getPlatform', 'query') ); $mockStatement = $this->getMock('Zend\Db\Adapter\Driver\StatementInterface'); @@ -36,7 +36,7 @@ public function testAddFeatureThatFeatureDoesnotHasTableGatewayButFeatureSetHas( $mockSlaveAdapter = $this->getMock( 'Zend\Db\Adapter\AdapterInterface', - array('getDriver', 'getPlatform') + array('getDriver', 'getPlatform', 'query') ); $mockStatement = $this->getMock('Zend\Db\Adapter\Driver\StatementInterface'); diff --git a/tests/ZendTest/Db/TableGateway/Feature/MasterSlaveFeatureTest.php b/tests/ZendTest/Db/TableGateway/Feature/MasterSlaveFeatureTest.php index 8dc9144d147..90419f8d77b 100644 --- a/tests/ZendTest/Db/TableGateway/Feature/MasterSlaveFeatureTest.php +++ b/tests/ZendTest/Db/TableGateway/Feature/MasterSlaveFeatureTest.php @@ -30,7 +30,7 @@ public function setup() { $this->mockMasterAdapter = $this->getMock( 'Zend\Db\Adapter\AdapterInterface', - array('getDriver', 'getPlatform') + array('getDriver', 'getPlatform', 'query') ); $mockStatement = $this->getMock('Zend\Db\Adapter\Driver\StatementInterface'); @@ -43,7 +43,7 @@ public function setup() $this->mockSlaveAdapter = $this->getMock( 'Zend\Db\Adapter\AdapterInterface', - array('getDriver', 'getPlatform') + array('getDriver', 'getPlatform', 'query') ); $mockStatement = $this->getMock('Zend\Db\Adapter\Driver\StatementInterface'); From b085ded9d83c05bc77097a61021a9a302e911415 Mon Sep 17 00:00:00 2001 From: Dennis de Greef Date: Fri, 24 Oct 2014 01:39:48 +0200 Subject: [PATCH 4/4] Fix interface that cannot reference to self --- library/Zend/Db/Adapter/AdapterInterface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Zend/Db/Adapter/AdapterInterface.php b/library/Zend/Db/Adapter/AdapterInterface.php index ad6593da81b..d9fdb561a7c 100644 --- a/library/Zend/Db/Adapter/AdapterInterface.php +++ b/library/Zend/Db/Adapter/AdapterInterface.php @@ -37,5 +37,5 @@ public function getPlatform(); * @throws Exception\InvalidArgumentException * @return Driver\StatementInterface|ResultSet\ResultSet */ - public function query($sql, $parametersOrQueryMode = self::QUERY_MODE_PREPARE, ResultSet\ResultSetInterface $resultPrototype = null); + public function query($sql, $parametersOrQueryMode, ResultSet\ResultSetInterface $resultPrototype = null); }