Skip to content
Closed
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
10 changes: 0 additions & 10 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,6 @@ parameters:
count: 1
path: src/Connection.php

-
message: "#^Parameter \\#1 \\$callback of function call_user_func_array expects callable\\(\\)\\: mixed, array\\{PDO\\|null, string\\} given\\.$#"
count: 1
path: src/Connection.php

-
message: "#^Parameter \\#1 \\$condition of method ipl\\\\Sql\\\\Delete\\:\\:where\\(\\) expects array\\|ipl\\\\Sql\\\\ExpressionInterface\\|ipl\\\\Sql\\\\Select\\|string, mixed given\\.$#"
count: 1
Expand All @@ -260,11 +255,6 @@ parameters:
count: 1
path: src/Connection.php

-
message: "#^Parameter \\#1 \\$object_or_class of function method_exists expects object\\|string, PDO\\|null given\\.$#"
count: 1
path: src/Connection.php

-
message: "#^Parameter \\#2 \\$className of method PDOStatement\\:\\:setFetchMode\\(\\) expects int\\|object\\|string, mixed given\\.$#"
count: 1
Expand Down
15 changes: 10 additions & 5 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,19 @@ public function __call($name, array $arguments)
{
$this->connect();

if (! method_exists($this->pdo, $name)) {
/** @var PDO $pdo */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you have to use mixins here instead. Check https://phpstan.org/writing-php-code/phpdocs-basics#mixins

$pdo = $this->pdo;
if (! method_exists($pdo, $name)) {
$class = get_class($this);
$message = "Call to undefined method $class::$name";

throw new BadMethodCallException($message);
}

return call_user_func_array([$this->pdo, $name], $arguments);
/** @var callable $callback */
$callback = [$this->pdo, $name];

return call_user_func_array($callback, $arguments);
}

/**
Expand Down Expand Up @@ -211,7 +216,7 @@ public function ping($reconnect = true)
* @param Select|string $stmt The SQL statement to prepare and execute.
* @param array $values Values to bind to the statement
*
* @return array
* @return array|false
*/
public function fetchAll($stmt, array $values = null)
{
Expand All @@ -225,7 +230,7 @@ public function fetchAll($stmt, array $values = null)
* @param Select|string $stmt The SQL statement to prepare and execute.
* @param array $values Values to bind to the statement
*
* @return array
* @return array|false
*/
public function fetchCol($stmt, array $values = null)
{
Expand Down Expand Up @@ -264,7 +269,7 @@ public function fetchRow($stmt, array $values = null)
* @param Select|string $stmt The SQL statement to prepare and execute.
* @param array $values Values to bind to the statement
*
* @return array
* @return array|false
*/
public function fetchPairs($stmt, array $values = null)
{
Expand Down