Skip to content

Add template types to PreparedQuery #6708

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
35 changes: 0 additions & 35 deletions phpstan-baseline.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -200,26 +200,6 @@ parameters:
count: 3
path: system/Database/MySQLi/PreparedQuery.php

-
message: "#^Cannot call method bind_param\\(\\) on object\\|resource\\.$#"
count: 1
path: system/Database/MySQLi/PreparedQuery.php

-
message: "#^Cannot call method execute\\(\\) on object\\|resource\\.$#"
count: 1
path: system/Database/MySQLi/PreparedQuery.php

-
message: "#^Cannot call method get_result\\(\\) on object\\|resource\\.$#"
count: 1
path: system/Database/MySQLi/PreparedQuery.php

-
message: "#^Cannot call method close\\(\\) on object\\|resource\\.$#"
count: 1
path: system/Database/MySQLi/PreparedQuery.php

-
message: "#^Cannot access property \\$field_count on object\\|resource\\|false\\.$#"
count: 1
Expand Down Expand Up @@ -315,16 +295,6 @@ parameters:
count: 1
path: system/Database/SQLite3/Connection.php

-
message: "#^Cannot call method bindValue\\(\\) on object\\|resource\\.$#"
count: 1
path: system/Database/SQLite3/PreparedQuery.php

-
message: "#^Cannot call method execute\\(\\) on object\\|resource\\.$#"
count: 1
path: system/Database/SQLite3/PreparedQuery.php

-
message: "#^Cannot call method lastErrorCode\\(\\) on bool\\|object\\|resource\\.$#"
count: 1
Expand All @@ -340,11 +310,6 @@ parameters:
count: 1
path: system/Database/SQLite3/PreparedQuery.php

-
message: "#^Cannot call method close\\(\\) on object\\|resource\\.$#"
count: 1
path: system/Database/SQLite3/PreparedQuery.php

-
message: "#^Cannot call method columnName\\(\\) on object\\|resource\\|false\\.$#"
count: 2
Expand Down
5 changes: 5 additions & 0 deletions system/Database/BasePreparedQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,18 @@

/**
* Base prepared query
*
* @template TStatement of object|resource
*
* @implements PreparedQueryInterface<TStatement>
*/
abstract class BasePreparedQuery implements PreparedQueryInterface
{
/**
* The prepared statement itself.
*
* @var object|resource|null
* @phpstan-var TStatement|null
*/
protected $statement;

Expand Down
3 changes: 3 additions & 0 deletions system/Database/MySQLi/PreparedQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@
use BadMethodCallException;
use CodeIgniter\Database\BasePreparedQuery;
use CodeIgniter\Database\Exceptions\DatabaseException;
use mysqli_stmt;

/**
* Prepared query for MySQLi
*
* @extends BasePreparedQuery<mysqli_stmt>
*/
class PreparedQuery extends BasePreparedQuery
{
Expand Down
2 changes: 2 additions & 0 deletions system/Database/OCI8/PreparedQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

/**
* Prepared query for OCI8
*
* @extends BasePreparedQuery<resource>
*/
class PreparedQuery extends BasePreparedQuery implements PreparedQueryInterface
{
Expand Down
2 changes: 2 additions & 0 deletions system/Database/Postgre/PreparedQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

/**
* Prepared query for Postgre
*
* @extends BasePreparedQuery<\PgSql\Result>
*/
class PreparedQuery extends BasePreparedQuery
{
Expand Down
2 changes: 2 additions & 0 deletions system/Database/PreparedQueryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

/**
* Prepared query interface
*
* @template TStatement of object|resource
*/
interface PreparedQueryInterface
{
Expand Down
2 changes: 2 additions & 0 deletions system/Database/SQLSRV/PreparedQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

/**
* Prepared query for Postgre
*
* @extends BasePreparedQuery<resource>
*/
class PreparedQuery extends BasePreparedQuery
{
Expand Down
3 changes: 3 additions & 0 deletions system/Database/SQLite3/PreparedQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@
use BadMethodCallException;
use CodeIgniter\Database\BasePreparedQuery;
use CodeIgniter\Database\Exceptions\DatabaseException;
use SQLite3Stmt;

/**
* Prepared query for SQLite3
*
* @extends BasePreparedQuery<SQLite3Stmt>
*/
class PreparedQuery extends BasePreparedQuery
{
Expand Down