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
56 changes: 1 addition & 55 deletions analysis-baseline.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ code = "falsable-return-statement"
message = '''Function `PhpDb\Mysql\AdapterPlatform::quoteViaDriver` is declared to return `null|string` but possibly returns 'false' (inferred as `false|string`).'''
count = 1

[[issues]]
file = "src/AdapterPlatform.php"
code = "impossible-condition"
message = "This condition (type `false`) will always evaluate to false."
count = 1

[[issues]]
file = "src/AdapterPlatform.php"
code = "invalid-return-statement"
Expand All @@ -30,12 +24,6 @@ code = "possibly-invalid-argument"
message = 'Possible argument type mismatch for argument #1 of `PhpDb\Mysql\AdapterPlatform::quoteViaDriver`: expected `string`, but possibly received `bool|float|int|string`.'
count = 1

[[issues]]
file = "src/Connection.php"
code = "incompatible-property-type"
message = 'Property `PhpDb\Mysql\Connection::$resource` has an incompatible type declaration from docblock.'
count = 1

[[issues]]
file = "src/Connection.php"
code = "invalid-iterator"
Expand Down Expand Up @@ -135,7 +123,7 @@ count = 1
[[issues]]
file = "src/Connection.php"
code = "mixed-return-statement"
message = "Could not infer a precise return type for function `{closure:src/Connection.php:118:31}`. Saw type `nonnull`."
message = "Could not infer a precise return type for function `{closure:src/Connection.php:119:31}`. Saw type `nonnull`."
count = 1

[[issues]]
Expand Down Expand Up @@ -258,12 +246,6 @@ code = "mixed-argument"
message = 'Invalid argument type for argument #1 of `PhpDb\Mysql\Statement::__construct`: expected `bool`, but found `nonnull`.'
count = 1

[[issues]]
file = "src/Driver.php"
code = "docblock-type-mismatch"
message = "Docblock type mismatch for variable `$resource`."
count = 1

[[issues]]
file = "src/Driver.php"
code = "incompatible-parameter-type"
Expand Down Expand Up @@ -456,42 +438,6 @@ code = "unused-property"
message = "Property `$numberOfRows` is never used."
count = 1

[[issues]]
file = "src/Sql/SelectDecorator.php"
code = "invalid-property-assignment-value"
message = "Invalid type for property `$specifications`: expected `array<array-key, array<array-key, mixed>>|array<array-key, string>`, but got `array{'limit': string('LIMIT 18446744073709551615'), ...<array-key, array<array-key, mixed>>}|array{'limit': string('LIMIT 18446744073709551615'), ...<array-key, string>}`."
count = 1

[[issues]]
file = "src/Sql/SelectDecorator.php"
code = "invalid-return-statement"
message = 'Invalid return type for function `PhpDb\Mysql\Sql\SelectDecorator::processLimit`: expected `array<array-key, string>|null`, but found `list{int|string}`.'
count = 1

[[issues]]
file = "src/Sql/SelectDecorator.php"
code = "invalid-return-statement"
message = 'Invalid return type for function `PhpDb\Mysql\Sql\SelectDecorator::processOffset`: expected `array<array-key, string>|null`, but found `list{int|string}`.'
count = 1

[[issues]]
file = "src/Sql/SelectDecorator.php"
code = "less-specific-nested-return-statement"
message = '''Returned type `list{mixed}` is less specific than the declared return type `array<array-key, string>|null` for function `PhpDb\Mysql\Sql\SelectDecorator::processLimit` due to nested 'mixed'.'''
count = 1

[[issues]]
file = "src/Sql/SelectDecorator.php"
code = "less-specific-nested-return-statement"
message = '''Returned type `list{mixed}` is less specific than the declared return type `array<array-key, string>|null` for function `PhpDb\Mysql\Sql\SelectDecorator::processOffset` due to nested 'mixed'.'''
count = 1

[[issues]]
file = "src/Sql/SelectDecorator.php"
code = "possible-method-access-on-null"
message = "Attempting to call a method on `null`."
count = 2

[[issues]]
file = "src/Sql/SelectDecorator.php"
code = "write-only-property"
Expand Down
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use PhpDb\Adapter\Driver\ResultInterface;
use PhpDb\Adapter\Exception;
use PhpDb\Adapter\Exception\InvalidArgumentException;
use PhpDb\Exception\ExceptionInterface as PhpDbExceptionInterface;

use function constant;
use function defined;
Expand Down Expand Up @@ -64,7 +65,7 @@ public function __construct(
/**
* @inheritDoc
*
* @throws Exception\ExceptionInterface
* @throws PhpDbExceptionInterface
*/
#[Override]
public function beginTransaction(): ConnectionInterface
Expand All @@ -82,7 +83,7 @@ public function beginTransaction(): ConnectionInterface
/**
* @inheritDoc
*
* @throws Exception\ExceptionInterface
* @throws PhpDbExceptionInterface
*/
#[Override]
public function commit(): ConnectionInterface
Expand All @@ -101,7 +102,7 @@ public function commit(): ConnectionInterface
/**
* @inheritDoc
*
* @throws Exception\ExceptionInterface
* @throws PhpDbExceptionInterface
*/
// @mago-expect lint:halstead
#[Override]
Expand Down Expand Up @@ -207,7 +208,7 @@ public function disconnect(): ConnectionInterface
/**
* {@inheritDoc}
*
* @throws Exception\ExceptionInterface
* @throws PhpDbExceptionInterface
*/
#[Override]
public function execute(string $sql): ?ResultInterface
Expand Down Expand Up @@ -241,7 +242,7 @@ public function execute(string $sql): ?ResultInterface
/**
* @inheritDoc
*
* @throws Exception\ExceptionInterface
* @throws PhpDbExceptionInterface
*/
#[Override]
public function getCurrentSchema(): string|false
Expand Down Expand Up @@ -287,7 +288,7 @@ public function isConnected(): bool
/**
* @inheritDoc
*
* @throws Exception\ExceptionInterface
* @throws PhpDbExceptionInterface
*/
#[Override]
public function rollback(): ConnectionInterface
Expand Down
3 changes: 2 additions & 1 deletion src/Container/ConnectionInterfaceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use PhpDb\Adapter\Driver\ConnectionInterface;
use PhpDb\Adapter\Exception\InvalidConnectionParametersException;
use PhpDb\Exception\ExceptionInterface as PhpDbExceptionInterface;
use PhpDb\Mysql\Connection;
use Psr\Container\ContainerInterface;

Expand All @@ -16,7 +17,7 @@ final class ConnectionInterfaceFactory
/**
* @param array<string, mixed>|null $options
*
* @throws \PhpDb\Adapter\Exception\ExceptionInterface
* @throws PhpDbExceptionInterface
*
* @mago-expect analysis:unused-parameter
*/
Expand Down
3 changes: 2 additions & 1 deletion src/Container/DriverInterfaceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use PhpDb\Adapter\Driver\DriverInterface;
use PhpDb\Adapter\Driver\ResultInterface;
use PhpDb\Exception\ContainerException;
use PhpDb\Exception\ExceptionInterface as PhpDbExceptionInterface;
use PhpDb\Mysql\Connection;
use PhpDb\Mysql\Driver;
use PhpDb\Mysql\Result;
Expand All @@ -24,7 +25,7 @@
* @throws \Laminas\ServiceManager\Exception\ExceptionInterface
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws \PhpDb\Exception\ExceptionInterface
* @throws PhpDbExceptionInterface
*
* @mago-expect analysis:unused-parameter
*/
Expand All @@ -45,7 +46,7 @@

$statementInstance = $container->build(
Statement::class,
$options['options'] ?? [],

Check warning on line 49 in src/Container/DriverInterfaceFactory.php

View workflow job for this annotation

GitHub Actions / qa / Mutation testing

Escaped Mutant for Mutator "Coalesce": @@ @@ $statementInstance = $container->build( Statement::class, - $options['options'] ?? [], + [] ?? $options['options'], ); /** @var ResultInterface&Result $resultInstance */
);

/** @var ResultInterface&Result $resultInstance */
Expand Down
3 changes: 2 additions & 1 deletion src/Container/PdoConnectionInterfaceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use PhpDb\Adapter\Driver\PdoConnectionInterface;
use PhpDb\Adapter\Exception\InvalidConnectionParametersException;
use PhpDb\Exception\ExceptionInterface as PhpDbExceptionInterface;
use PhpDb\Mysql\Pdo\Connection;
use Psr\Container\ContainerInterface;

Expand All @@ -16,7 +17,7 @@ final class PdoConnectionInterfaceFactory
/**
* @param array<string, mixed>|null $options
*
* @throws \PhpDb\Adapter\Exception\ExceptionInterface
* @throws PhpDbExceptionInterface
*
* @mago-expect analysis:unused-parameter
*/
Expand Down
5 changes: 3 additions & 2 deletions src/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use PhpDb\Adapter\Exception;
use PhpDb\Adapter\Profiler\ProfilerAwareInterface;
use PhpDb\Adapter\Profiler\ProfilerInterface;
use PhpDb\Exception\ExceptionInterface as PhpDbExceptionInterface;

use function array_intersect_key;
use function extension_loaded;
Expand All @@ -32,7 +33,7 @@ final class Driver implements DriverInterface, ProfilerAwareInterface
/**
* @param array<string, mixed> $options
*
* @throws \PhpDb\Exception\ExceptionInterface
* @throws PhpDbExceptionInterface
*/
public function __construct(
protected readonly ConnectionInterface&Connection $connection,
Expand Down Expand Up @@ -79,7 +80,7 @@ public function createResult($resource, ?bool $isBuffered = null): ResultInterfa
*
* @param mysqli|mysqli_stmt|string $sqlOrResource
*
* @throws Exception\ExceptionInterface
* @throws PhpDbExceptionInterface
*/
#[Override]
public function createStatement($sqlOrResource = null): StatementInterface&Statement
Expand Down
5 changes: 3 additions & 2 deletions src/Pdo/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use PhpDb\Adapter\Driver\ConnectionInterface;
use PhpDb\Adapter\Driver\Pdo\AbstractPdoConnection;
use PhpDb\Adapter\Exception;
use PhpDb\Exception\ExceptionInterface as PhpDbExceptionInterface;

use function array_diff_key;
use function implode;
Expand Down Expand Up @@ -143,7 +144,7 @@ public function connect(): ConnectionInterface
/**
* {@inheritDoc}
*
* @throws Exception\ExceptionInterface
* @throws PhpDbExceptionInterface
* @throws PDOException
*/
#[Override]
Expand Down Expand Up @@ -187,7 +188,7 @@ public function getLastGeneratedValue(?string $name = null): string|int|false|nu
* Return a value that is safe to interpolate into a generated DSN.
*
* @todo Promote to AbstractPdoConnection in php-db/phpdb as a protected method once a second
* PDO driver package needs it — the validation is generic to all semicolon-delimited
* PDO driver package needs it; the validation is generic to all semicolon-delimited
* PDO DSN formats and has no MySQL-specific dependencies.
*
* @throws Exception\InvalidConnectionParametersException If the value contains DSN control characters.
Expand Down
5 changes: 3 additions & 2 deletions src/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Override;
use PhpDb\Adapter\Driver\ResultInterface;
use PhpDb\Adapter\Exception;
use PhpDb\Exception\ExceptionInterface as PhpDbExceptionInterface;
use PhpDb\ResultSet\ResultSet;
use PhpDb\ResultSet\ResultSetInterface;
// phpcs:ignore SlevomatCodingStandard.Namespaces.UnusedUses.UnusedUse
Expand Down Expand Up @@ -91,7 +92,7 @@ public function count()
/**
* Current
*
* @throws Exception\ExceptionInterface
* @throws PhpDbExceptionInterface
*
* @return array<array-key, mixed>|null
*/
Expand Down Expand Up @@ -277,7 +278,7 @@ public function rewind()
/**
* Valid
*
* @throws Exception\ExceptionInterface
* @throws PhpDbExceptionInterface
*
* @return bool
*/
Expand Down
9 changes: 3 additions & 6 deletions src/Sql/Ddl/AlterTableDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function setSubject(
}

/**
* @return array<int, array<int|string, string>>
* @return array{0: list<string>}
*/
#[Override]
protected function processAddColumns(?PlatformInterface $adapterPlatform = null): array
Expand All @@ -43,11 +43,10 @@ protected function processAddColumns(?PlatformInterface $adapterPlatform = null)
/** @var array<array-key, ColumnInterface> $addColumns */
$addColumns = $this->addColumns;

foreach ($addColumns as $i => $column) {
/** @var array<string, mixed> $options */
foreach ($addColumns as $column) {
$options = $column->getOptions();

$sqls[$i] = $this->processColumnOptions(
$sqls[] = $this->processColumnOptions(
$this->processExpression($column, $platform),
$options,
$platform,
Expand All @@ -69,11 +68,9 @@ protected function processChangeColumns(?PlatformInterface $adapterPlatform = nu

$sqls = [];

/** @var array<string, ColumnInterface> $changeColumns */
$changeColumns = $this->changeColumns;

foreach ($changeColumns as $name => $column) {
/** @var array<string, mixed> $options */
$options = $column->getOptions();

$sqls[] = [
Expand Down
1 change: 0 additions & 1 deletion src/Sql/Ddl/CreateTableDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ protected function processColumns(?PlatformInterface $adapterPlatform = null): ?
$columns = $this->columns;

foreach ($columns as $i => $column) {
/** @var array<string, mixed> $options */
$options = $column->getOptions();

$sqls[$i] = $this->processColumnOptions(
Expand Down
Loading
Loading