Skip to content

Commit

Permalink
Merge pull request #679 from cakephp/phinx-adapter
Browse files Browse the repository at this point in the history
Get started on PhinxAdapter
  • Loading branch information
markstory authored Jan 22, 2024
2 parents ee69f54 + 590be27 commit 424224e
Show file tree
Hide file tree
Showing 9 changed files with 2,696 additions and 28 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"php": ">=8.1",
"cakephp/cache": "^5.0",
"cakephp/orm": "^5.0",
"robmorgan/phinx": "^0.15.3"
"robmorgan/phinx": "0.x-dev#c35379620f23319329bb9ed17b82f4bdcce2a91e"
},
"require-dev": {
"cakephp/bake": "^3.0",
Expand Down
20 changes: 0 additions & 20 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,6 @@ parameters:
count: 1
path: src/Db/Adapter/AdapterFactory.php

-
message: "#^Call to an undefined method Migrations\\\\Db\\\\Adapter\\\\AdapterInterface\\:\\:getDeleteBuilder\\(\\)\\.$#"
count: 1
path: src/Db/Adapter/AdapterWrapper.php

-
message: "#^Call to an undefined method Migrations\\\\Db\\\\Adapter\\\\AdapterInterface\\:\\:getInsertBuilder\\(\\)\\.$#"
count: 1
path: src/Db/Adapter/AdapterWrapper.php

-
message: "#^Call to an undefined method Migrations\\\\Db\\\\Adapter\\\\AdapterInterface\\:\\:getSelectBuilder\\(\\)\\.$#"
count: 1
path: src/Db/Adapter/AdapterWrapper.php

-
message: "#^Call to an undefined method Migrations\\\\Db\\\\Adapter\\\\AdapterInterface\\:\\:getUpdateBuilder\\(\\)\\.$#"
count: 1
path: src/Db/Adapter/AdapterWrapper.php

-
message: "#^Offset 'id' on non\\-empty\\-array\\<string, mixed\\> in isset\\(\\) always exists and is not nullable\\.$#"
count: 2
Expand Down
14 changes: 8 additions & 6 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,27 @@
</RedundantPropertyInitializationCheck>
</file>
<file src="src/Db/Adapter/AdapterWrapper.php">
<DeprecatedMethod>
<code>getQueryBuilder</code>
</DeprecatedMethod>
<InvalidNullableReturnType>
<code>InputInterface</code>
</InvalidNullableReturnType>
<NullableReturnStatement>
<code><![CDATA[$this->adapter->getInput()]]></code>
</NullableReturnStatement>
<UndefinedInterfaceMethod>
<code>getDeleteBuilder</code>
<code>getInsertBuilder</code>
<code>getSelectBuilder</code>
<code>getUpdateBuilder</code>
</UndefinedInterfaceMethod>
</file>
<file src="src/Db/Adapter/MysqlAdapter.php">
<RedundantCondition>
<code>$opened</code>
<code>is_array($newColumns)</code>
</RedundantCondition>
</file>
<file src="src/Db/Adapter/PhinxAdapter.php">
<DeprecatedMethod>
<code>getQueryBuilder</code>
</DeprecatedMethod>
</file>
<file src="src/Db/Adapter/PostgresAdapter.php">
<NoValue>
<code><![CDATA[$options['primary_key']]]></code>
Expand Down
33 changes: 33 additions & 0 deletions src/Db/Adapter/AdapterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
namespace Migrations\Db\Adapter;

use Cake\Database\Query;
use Cake\Database\Query\DeleteQuery;
use Cake\Database\Query\InsertQuery;
use Cake\Database\Query\SelectQuery;
use Cake\Database\Query\UpdateQuery;
use Migrations\Db\Literal;
use Migrations\Db\Table\Column;
use Migrations\Db\Table\Table;
Expand Down Expand Up @@ -283,10 +287,39 @@ public function executeActions(Table $table, array $actions): void;
/**
* Returns a new Query object
*
* @deprecated 4.x Use getSelectBuilder, getInsertBuilder, getUpdateBuilder, getDeleteBuilder instead.
* @return \Cake\Database\Query
*/
public function getQueryBuilder(string $type): Query;

/**
* Return a new SelectQuery object
*
* @return \Cake\Database\Query\SelectQuery
*/
public function getSelectBuilder(): SelectQuery;

/**
* Return a new InsertQuery object
*
* @return \Cake\Database\Query\InsertQuery
*/
public function getInsertBuilder(): InsertQuery;

/**
* Return a new UpdateQuery object
*
* @return \Cake\Database\Query\UpdateQuery
*/
public function getUpdateBuilder(): UpdateQuery;

/**
* Return a new DeleteQuery object
*
* @return \Cake\Database\Query\DeleteQuery
*/
public function getDeleteBuilder(): DeleteQuery;

/**
* Executes a SQL statement.
*
Expand Down
36 changes: 36 additions & 0 deletions src/Db/Adapter/PdoAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
use BadMethodCallException;
use Cake\Database\Connection;
use Cake\Database\Query;
use Cake\Database\Query\DeleteQuery;
use Cake\Database\Query\InsertQuery;
use Cake\Database\Query\SelectQuery;
use Cake\Database\Query\UpdateQuery;
use InvalidArgumentException;
use Migrations\Db\Action\AddColumn;
use Migrations\Db\Action\AddForeignKey;
Expand Down Expand Up @@ -247,6 +251,38 @@ public function getQueryBuilder(string $type): Query
};
}

/**
* @inheritDoc
*/
public function getSelectBuilder(): SelectQuery
{
return $this->getDecoratedConnection()->selectQuery();
}

/**
* @inheritDoc
*/
public function getInsertBuilder(): InsertQuery
{
return $this->getDecoratedConnection()->insertQuery();
}

/**
* @inheritDoc
*/
public function getUpdateBuilder(): UpdateQuery
{
return $this->getDecoratedConnection()->updateQuery();
}

/**
* @inheritDoc
*/
public function getDeleteBuilder(): DeleteQuery
{
return $this->getDecoratedConnection()->deleteQuery();
}

/**
* Executes a query and returns PDOStatement.
*
Expand Down
Loading

0 comments on commit 424224e

Please sign in to comment.