Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions system/Database/BaseBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
* Provides the core Query Builder methods.
* Database-specific Builders might need to override
* certain methods to make them work.
*
* @template TDb of BaseConnection
*/
class BaseBuilder
{
Expand Down Expand Up @@ -183,7 +185,7 @@ class BaseBuilder
/**
* A reference to the database connection.
*
* @var BaseConnection
* @var TDb
*/
protected $db;

Expand Down Expand Up @@ -310,7 +312,7 @@ public function __construct($tableName, ConnectionInterface $db, ?array $options
throw new DatabaseException('A table must be specified when creating a new Query Builder.');
}

/** @var BaseConnection $db */
/** @var TDb $db */
$this->db = $db;

if ($tableName instanceof TableName) {
Expand Down
3 changes: 2 additions & 1 deletion system/Database/BasePreparedQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* @template TConnection
* @template TStatement
* @template TResult
* @template TDb of BaseConnection
*
* @implements PreparedQueryInterface<TConnection, TStatement, TResult>
*/
Expand Down Expand Up @@ -60,7 +61,7 @@ abstract class BasePreparedQuery implements PreparedQueryInterface
/**
* A reference to the db connection to use.
*
* @var BaseConnection<TConnection, TResult>
* @var TDb
*/
protected $db;

Expand Down
6 changes: 5 additions & 1 deletion system/Database/Forge.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@
/**
* The Forge class transforms migrations to executable
* SQL statements.
*
* @template TDb of BaseConnection
*/
class Forge
{
/**
* The active database connection.
*
* @var BaseConnection
* @var TDb
*/
protected $db;

Expand Down Expand Up @@ -187,6 +189,8 @@ class Forge

/**
* Constructor.
*
* @param TDb $db
*/
public function __construct(BaseConnection $db)
{
Expand Down
2 changes: 2 additions & 0 deletions system/Database/MySQLi/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

/**
* Builder for MySQLi
*
* @extends BaseBuilder<Connection>
*/
class Builder extends BaseBuilder
{
Expand Down
2 changes: 2 additions & 0 deletions system/Database/MySQLi/Forge.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

/**
* Forge for MySQLi
*
* @extends BaseForge<Connection>
*/
class Forge extends BaseForge
{
Expand Down
2 changes: 1 addition & 1 deletion system/Database/MySQLi/PreparedQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/**
* Prepared query for MySQLi
*
* @extends BasePreparedQuery<mysqli, mysqli_stmt, mysqli_result>
* @extends BasePreparedQuery<mysqli, mysqli_stmt, mysqli_result, Connection>
*/
class PreparedQuery extends BasePreparedQuery
{
Expand Down
9 changes: 2 additions & 7 deletions system/Database/OCI8/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

/**
* Builder for OCI8
*
* @extends BaseBuilder<Connection>
*/
class Builder extends BaseBuilder
{
Expand Down Expand Up @@ -48,13 +50,6 @@ class Builder extends BaseBuilder
*/
protected $countString = 'SELECT COUNT(1) ';

/**
* A reference to the database connection.
*
* @var Connection
*/
protected $db;

/**
* Generates a platform-specific insert string from the supplied data.
*/
Expand Down
2 changes: 2 additions & 0 deletions system/Database/OCI8/Forge.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

/**
* Forge for OCI8
*
* @extends BaseForge<Connection>
*/
class Forge extends BaseForge
{
Expand Down
9 changes: 1 addition & 8 deletions system/Database/OCI8/PreparedQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,10 @@
/**
* Prepared query for OCI8
*
* @extends BasePreparedQuery<resource, resource, resource>
* @extends BasePreparedQuery<resource, resource, resource, Connection>
*/
class PreparedQuery extends BasePreparedQuery
{
/**
* A reference to the db connection to use.
*
* @var Connection
*/
protected $db;

/**
* Latest inserted table name.
*/
Expand Down
2 changes: 2 additions & 0 deletions system/Database/Postgre/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

/**
* Builder for Postgre
*
* @extends BaseBuilder<Connection>
*/
class Builder extends BaseBuilder
{
Expand Down
7 changes: 2 additions & 5 deletions system/Database/Postgre/Forge.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

/**
* Forge for Postgre
*
* @extends BaseForge<Connection>
*/
class Forge extends BaseForge
{
Expand Down Expand Up @@ -67,11 +69,6 @@ class Forge extends BaseForge
*/
protected $null = 'NULL';

/**
* @var Connection
*/
protected $db;

/**
* CREATE TABLE attributes
*
Expand Down
2 changes: 1 addition & 1 deletion system/Database/Postgre/PreparedQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/**
* Prepared query for Postgre
*
* @extends BasePreparedQuery<PgSqlConnection, PgSqlResult, PgSqlResult>
* @extends BasePreparedQuery<PgSqlConnection, PgSqlResult, PgSqlResult, Connection>
*/
class PreparedQuery extends BasePreparedQuery
{
Expand Down
2 changes: 2 additions & 0 deletions system/Database/SQLSRV/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
* @todo auto check for TextCastToInt
* @todo auto check for InsertIndexValue
* @todo replace: delete index entries before insert
*
* @extends BaseBuilder<Connection>
*/
class Builder extends BaseBuilder
{
Expand Down
2 changes: 2 additions & 0 deletions system/Database/SQLSRV/Forge.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

/**
* Forge for SQLSRV
*
* @extends BaseForge<Connection>
*/
class Forge extends BaseForge
{
Expand Down
9 changes: 1 addition & 8 deletions system/Database/SQLSRV/PreparedQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
/**
* Prepared query for Postgre
*
* @extends BasePreparedQuery<resource, resource, resource>
* @extends BasePreparedQuery<resource, resource, resource, Connection>
*/
class PreparedQuery extends BasePreparedQuery
{
Expand All @@ -31,13 +31,6 @@ class PreparedQuery extends BasePreparedQuery
*/
protected $parameters = [];

/**
* A reference to the db connection to use.
*
* @var Connection
*/
protected $db;

public function __construct(Connection $db)
{
parent::__construct($db);
Expand Down
2 changes: 2 additions & 0 deletions system/Database/SQLite3/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

/**
* Builder for SQLite3
*
* @extends BaseBuilder<Connection>
*/
class Builder extends BaseBuilder
{
Expand Down
7 changes: 2 additions & 5 deletions system/Database/SQLite3/Forge.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

/**
* Forge for SQLite3
*
* @extends BaseForge<Connection>
*/
class Forge extends BaseForge
{
Expand All @@ -29,11 +31,6 @@ class Forge extends BaseForge
*/
protected $dropIndexStr = 'DROP INDEX %s';

/**
* @var Connection
*/
protected $db;

/**
* UNSIGNED support
*
Expand Down
2 changes: 1 addition & 1 deletion system/Database/SQLite3/PreparedQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/**
* Prepared query for SQLite3
*
* @extends BasePreparedQuery<SQLite3, SQLite3Stmt, SQLite3Result>
* @extends BasePreparedQuery<SQLite3, SQLite3Stmt, SQLite3Result, Connection>
*/
class PreparedQuery extends BasePreparedQuery
{
Expand Down
3 changes: 3 additions & 0 deletions system/Test/Mock/MockBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

use CodeIgniter\Database\BaseBuilder;

/**
* @extends BaseBuilder<MockConnection>
*/
class MockBuilder extends BaseBuilder
{
/**
Expand Down
3 changes: 2 additions & 1 deletion tests/_support/Mock/MockPreparedQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
namespace Tests\Support\Mock;

use CodeIgniter\Database\BasePreparedQuery;
use CodeIgniter\Test\Mock\MockConnection;

/**
* @internal
*
* @extends BasePreparedQuery<object, object, object>
* @extends BasePreparedQuery<object, object, object, MockConnection>
*/
final class MockPreparedQuery extends BasePreparedQuery
{
Expand Down
2 changes: 1 addition & 1 deletion tests/system/Database/Forge/CreateTableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function testCreateTableWithDefaultRawSql(): void
->with($sql)
->willReturn(true);

$forge = new class ($dbMock) extends Forge {};
$forge = new Forge($dbMock);

$fields = [
'id' => [
Expand Down
10 changes: 5 additions & 5 deletions utils/phpstan-baseline/argument.type.neon
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ parameters:
path: ../../tests/system/Config/FactoriesTest.php

-
message: '#^Parameter \#1 \$from of method CodeIgniter\\Database\\BaseBuilder\:\:from\(\) expects array\|string, null given\.$#'
message: '#^Parameter \#1 \$from of method CodeIgniter\\Database\\BaseBuilder\<CodeIgniter\\Database\\BaseConnection\>\:\:from\(\) expects array\|string, null given\.$#'
count: 1
path: ../../tests/system/Database/Builder/FromTest.php

Expand All @@ -68,7 +68,7 @@ parameters:
path: ../../tests/system/Database/Builder/GetTest.php

-
message: '#^Parameter \#1 \$fields of method CodeIgniter\\Database\\Forge\:\:addField\(\) expects array\<string, array\|string\>\|string, array\<int, string\> given\.$#'
message: '#^Parameter \#1 \$fields of method CodeIgniter\\Database\\Forge\<CodeIgniter\\Database\\BaseConnection\>\:\:addField\(\) expects array\<string, array\|string\>\|string, array\<int, string\> given\.$#'
count: 2
path: ../../tests/system/Database/Live/ForgeTest.php

Expand All @@ -78,17 +78,17 @@ parameters:
path: ../../tests/system/Database/Live/SQLite3/AlterTableTest.php

-
message: '#^Parameter \#1 \$set of method CodeIgniter\\Database\\BaseBuilder\:\:updateFields\(\) expects list\<CodeIgniter\\Database\\RawSql\|string\>\|string, array\{0\: ''country'', updated_at\: CodeIgniter\\Database\\RawSql\} given\.$#'
message: '#^Parameter \#1 \$set of method CodeIgniter\\Database\\BaseBuilder\<CodeIgniter\\Database\\BaseConnection\>\:\:updateFields\(\) expects list\<CodeIgniter\\Database\\RawSql\|string\>\|string, array\{0\: ''country'', updated_at\: CodeIgniter\\Database\\RawSql\} given\.$#'
count: 2
path: ../../tests/system/Database/Live/UpdateTest.php

-
message: '#^Parameter \#1 \$set of method CodeIgniter\\Database\\BaseBuilder\:\:updateFields\(\) expects list\<CodeIgniter\\Database\\RawSql\|string\>\|string, array\{0\: ''name'', updated_at\: CodeIgniter\\Database\\RawSql\} given\.$#'
message: '#^Parameter \#1 \$set of method CodeIgniter\\Database\\BaseBuilder\<CodeIgniter\\Database\\BaseConnection\>\:\:updateFields\(\) expects list\<CodeIgniter\\Database\\RawSql\|string\>\|string, array\{0\: ''name'', updated_at\: CodeIgniter\\Database\\RawSql\} given\.$#'
count: 1
path: ../../tests/system/Database/Live/UpdateTest.php

-
message: '#^Parameter \#1 \$set of method CodeIgniter\\Database\\BaseBuilder\:\:updateFields\(\) expects list\<CodeIgniter\\Database\\RawSql\|string\>\|string, array\{updated_at\: CodeIgniter\\Database\\RawSql\} given\.$#'
message: '#^Parameter \#1 \$set of method CodeIgniter\\Database\\BaseBuilder\<CodeIgniter\\Database\\BaseConnection\>\:\:updateFields\(\) expects list\<CodeIgniter\\Database\\RawSql\|string\>\|string, array\{updated_at\: CodeIgniter\\Database\\RawSql\} given\.$#'
count: 2
path: ../../tests/system/Database/Live/UpsertTest.php

Expand Down
2 changes: 1 addition & 1 deletion utils/phpstan-baseline/loader.neon
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# total 1478 errors
# total 1454 errors

includes:
- argument.type.neon
Expand Down
17 changes: 1 addition & 16 deletions utils/phpstan-baseline/property.notFound.neon
Original file line number Diff line number Diff line change
@@ -1,22 +1,7 @@
# total 47 errors
# total 28 errors

parameters:
ignoreErrors:
-
message: '#^Access to an undefined property CodeIgniter\\Database\\BaseConnection\<mysqli, mysqli_result\>\:\:\$mysqli\.$#'
count: 3
path: ../../system/Database/MySQLi/PreparedQuery.php

-
message: '#^Access to an undefined property CodeIgniter\\Database\\BaseConnection\:\:\$schema\.$#'
count: 2
path: ../../system/Database/SQLSRV/Builder.php

-
message: '#^Access to an undefined property CodeIgniter\\Database\\BaseConnection\:\:\$schema\.$#'
count: 14
path: ../../system/Database/SQLSRV/Forge.php

-
message: '#^Access to an undefined property CodeIgniter\\Database\\BaseConnection\:\:\$mysqli\.$#'
count: 1
Expand Down
Loading
Loading