From 880fb2152019e808195c38463249ff5c25607545 Mon Sep 17 00:00:00 2001 From: Simon Mundy Date: Wed, 18 Nov 2026 09:59:12 +1100 Subject: [PATCH 1/2] Bring Mago back to green against phpdb 0.6.x Driver::createStatement() documented $sqlOrResource as mysqli|mysqli_stmt|string, which is narrower than the resource|string that DriverInterface declares, so the analyzer reported an incompatible parameter type. The method wraps a mysqli_stmt, prepares a string and ignores anything else, so it is now documented as mixed. The baseline entry for the old message is removed. ColumnOptionTrait's fall-through comments are indented to match the statements they follow, as the formatter requires. --- analysis-baseline.toml | 6 ------ src/Driver.php | 2 +- src/Sql/Ddl/ColumnOptionTrait.php | 4 ++-- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/analysis-baseline.toml b/analysis-baseline.toml index 6c710f0..a922f11 100644 --- a/analysis-baseline.toml +++ b/analysis-baseline.toml @@ -252,12 +252,6 @@ code = "incompatible-parameter-type" message = 'Parameter `$resource` of `PhpDb\Mysql\Driver::createresult()` expects type `mysqli|mysqli_result|mysqli_stmt` but parent `PhpDb\Adapter\Driver\DriverInterface::createresult()` expects type `resource`' count = 1 -[[issues]] -file = "src/Driver.php" -code = "incompatible-parameter-type" -message = 'Parameter `$sqlOrResource` of `PhpDb\Mysql\Driver::createstatement()` expects type `mysqli|mysqli_stmt|string` but parent `PhpDb\Adapter\Driver\DriverInterface::createstatement()` expects type `resource|string`' -count = 1 - [[issues]] file = "src/Metadata/Source.php" code = "impossible-condition" diff --git a/src/Driver.php b/src/Driver.php index 1dae818..606da4f 100644 --- a/src/Driver.php +++ b/src/Driver.php @@ -78,7 +78,7 @@ public function createResult($resource, ?bool $isBuffered = null): ResultInterfa /** * Create statement * - * @param mysqli|mysqli_stmt|string $sqlOrResource + * @param mixed $sqlOrResource A prepared mysqli_stmt to wrap, or the SQL to prepare * * @throws PhpDbExceptionInterface */ diff --git a/src/Sql/Ddl/ColumnOptionTrait.php b/src/Sql/Ddl/ColumnOptionTrait.php index 770dfd5..1aa9fba 100644 --- a/src/Sql/Ddl/ColumnOptionTrait.php +++ b/src/Sql/Ddl/ColumnOptionTrait.php @@ -90,11 +90,11 @@ protected function getSqlInsertOffsets(string $sql): array switch ($needle) { case 'REFERENCES': $insertStart[2] ??= $insertPos; - // no break + // no break case 'PRIMARY': case 'UNIQUE': $insertStart[1] ??= $insertPos; - // no break + // no break default: $insertStart[0] ??= $insertPos; } From 32030a5d8869ffccd3c592c7f9bb24313face49b Mon Sep 17 00:00:00 2001 From: Simon Mundy Date: Wed, 25 Nov 2026 09:50:02 +1100 Subject: [PATCH 2/2] Restore concrete createStatement() parameter type Documenting $sqlOrResource as mixed hid the real contract. It is now mysqli_stmt|string|null, matching what the method handles, and the incompatible-parameter-type report against DriverInterface's resource|string is baselined alongside createResult(), pending php-db/phpdb#170 introducing @template generics on the interface. --- analysis-baseline.toml | 6 ++++++ src/Driver.php | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/analysis-baseline.toml b/analysis-baseline.toml index a922f11..b637988 100644 --- a/analysis-baseline.toml +++ b/analysis-baseline.toml @@ -252,6 +252,12 @@ code = "incompatible-parameter-type" message = 'Parameter `$resource` of `PhpDb\Mysql\Driver::createresult()` expects type `mysqli|mysqli_result|mysqli_stmt` but parent `PhpDb\Adapter\Driver\DriverInterface::createresult()` expects type `resource`' count = 1 +[[issues]] +file = "src/Driver.php" +code = "incompatible-parameter-type" +message = 'Parameter `$sqlOrResource` of `PhpDb\Mysql\Driver::createstatement()` expects type `mysqli_stmt|null|string` but parent `PhpDb\Adapter\Driver\DriverInterface::createstatement()` expects type `null|resource|string`' +count = 1 + [[issues]] file = "src/Metadata/Source.php" code = "impossible-condition" diff --git a/src/Driver.php b/src/Driver.php index 606da4f..ab434ba 100644 --- a/src/Driver.php +++ b/src/Driver.php @@ -78,7 +78,7 @@ public function createResult($resource, ?bool $isBuffered = null): ResultInterfa /** * Create statement * - * @param mixed $sqlOrResource A prepared mysqli_stmt to wrap, or the SQL to prepare + * @param mysqli_stmt|string|null $sqlOrResource A prepared mysqli_stmt to wrap, or the SQL to prepare * * @throws PhpDbExceptionInterface */