From 005ca4ecc976f2e7efe7a9d20e135ac1f37f24ae Mon Sep 17 00:00:00 2001 From: Mark Story Date: Tue, 12 Mar 2024 13:35:43 -0400 Subject: [PATCH] Fix mysql tests, phpcs and phpstan/psalm --- src/Db/Adapter/AdapterInterface.php | 10 ++++++++-- src/Db/Adapter/AdapterWrapper.php | 6 +++--- src/Db/Adapter/PhinxAdapter.php | 14 +++++++++++--- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/Db/Adapter/AdapterInterface.php b/src/Db/Adapter/AdapterInterface.php index 742373e6..96d4f538 100644 --- a/src/Db/Adapter/AdapterInterface.php +++ b/src/Db/Adapter/AdapterInterface.php @@ -9,6 +9,7 @@ namespace Migrations\Db\Adapter; use Cake\Console\ConsoleIo; +use Cake\Database\Connection; use Cake\Database\Query; use Cake\Database\Query\DeleteQuery; use Cake\Database\Query\InsertQuery; @@ -21,8 +22,6 @@ /** * Adapter Interface. - * - * @method \PDO getConnection() */ interface AdapterInterface { @@ -520,4 +519,11 @@ public function setIo(ConsoleIo $io); * @return \Cake\Console\ConsoleIo $io The io instance to use */ public function getIo(): ?ConsoleIo; + + /** + * Get the Connection for this adapter. + * + * @return \Cake\Database\Connection The connection + */ + public function getConnection(): Connection; } diff --git a/src/Db/Adapter/AdapterWrapper.php b/src/Db/Adapter/AdapterWrapper.php index e9b77aef..42e4f83e 100644 --- a/src/Db/Adapter/AdapterWrapper.php +++ b/src/Db/Adapter/AdapterWrapper.php @@ -9,6 +9,7 @@ namespace Migrations\Db\Adapter; use Cake\Console\ConsoleIo; +use Cake\Database\Connection; use Cake\Database\Query; use Cake\Database\Query\DeleteQuery; use Cake\Database\Query\InsertQuery; @@ -17,7 +18,6 @@ use Migrations\Db\Literal; use Migrations\Db\Table\Column; use Migrations\Db\Table\Table; -use PDO; use Phinx\Migration\MigrationInterface; /** @@ -430,9 +430,9 @@ public function castToBool($value): mixed } /** - * @return \PDO + * @return \Cake\Database\Connection */ - public function getConnection(): PDO + public function getConnection(): Connection { return $this->getAdapter()->getConnection(); } diff --git a/src/Db/Adapter/PhinxAdapter.php b/src/Db/Adapter/PhinxAdapter.php index e4a33d85..f3cf451d 100644 --- a/src/Db/Adapter/PhinxAdapter.php +++ b/src/Db/Adapter/PhinxAdapter.php @@ -8,6 +8,7 @@ namespace Migrations\Db\Adapter; +use Cake\Database\Connection; use Cake\Database\Query; use Cake\Database\Query\DeleteQuery; use Cake\Database\Query\InsertQuery; @@ -32,7 +33,6 @@ use Migrations\Db\Table\ForeignKey; use Migrations\Db\Table\Index; use Migrations\Db\Table\Table; -use PDO; use Phinx\Db\Action\Action as PhinxAction; use Phinx\Db\Action\AddColumn as PhinxAddColumn; use Phinx\Db\Action\AddForeignKey as PhinxAddForeignKey; @@ -747,9 +747,9 @@ public function castToBool($value): mixed } /** - * @return \PDO + * @return \Cake\Database\Connection */ - public function getConnection(): PDO + public function getConnection(): Connection { return $this->adapter->getConnection(); } @@ -812,4 +812,12 @@ public function getDeleteBuilder(): DeleteQuery { return $this->adapter->getDeleteBuilder(); } + + /** + * @inheritDoc + */ + public function getCakeConnection(): Connection + { + return $this->adapter->getConnection(); + } }