Skip to content
Open
162 changes: 0 additions & 162 deletions analyzer-baseline.toml
Original file line number Diff line number Diff line change
@@ -1,131 +1,5 @@
variant = "loose"

[[issues]]
file = "src/Adapter/AdapterInterface.php"
code = "missing-return-type"
message = "Function `getHelpers` is missing a return type hint."
count = 1

[[issues]]
file = "src/Adapter/Driver/AbstractConnection.php"
code = "missing-property-type"
message = "Property `$resource` is missing a type hint."
count = 1

[[issues]]
file = "src/Adapter/Driver/AbstractConnection.php"
code = "mixed-return-statement"
message = 'Could not infer a precise return type for function `PhpDb\Adapter\Driver\AbstractConnection::getResource`. Saw type `mixed`.'
count = 1

[[issues]]
file = "src/Adapter/Driver/ConnectionInterface.php"
code = "missing-return-type"
message = "Function `getResource` is missing a return type hint."
count = 1

[[issues]]
file = "src/Adapter/Driver/Pdo/AbstractPdo.php"
code = "overly-wide-return-type"
message = 'Declared return type `PhpDb\Adapter\Driver\ResultInterface|null` for `getresultprototype` has unused branches: `null`.'
count = 1

[[issues]]
file = "src/Adapter/Driver/Pdo/Result.php"
code = "incompatible-return-type"
message = 'Return type `mixed` of `PhpDb\Adapter\Driver\Pdo\Result::next()` is incompatible with parent return type `void` of `Iterator::next()`'
count = 1

[[issues]]
file = "src/Adapter/Driver/Pdo/Result.php"
code = "missing-parameter-type"
message = "Parameter `$generatedValue` is missing a type hint."
count = 1

[[issues]]
file = "src/Adapter/Driver/Pdo/Result.php"
code = "missing-property-type"
message = "Property `$currentComplete` is missing a type hint."
count = 1

[[issues]]
file = "src/Adapter/Driver/Pdo/Result.php"
code = "missing-property-type"
message = "Property `$currentData` is missing a type hint."
count = 1

[[issues]]
file = "src/Adapter/Driver/Pdo/Result.php"
code = "missing-property-type"
message = "Property `$fetchMode` is missing a type hint."
count = 1

[[issues]]
file = "src/Adapter/Driver/Pdo/Result.php"
code = "missing-property-type"
message = "Property `$generatedValue` is missing a type hint."
count = 1

[[issues]]
file = "src/Adapter/Driver/Pdo/Result.php"
code = "missing-property-type"
message = "Property `$options` is missing a type hint."
count = 1

[[issues]]
file = "src/Adapter/Driver/Pdo/Result.php"
code = "missing-property-type"
message = "Property `$position` is missing a type hint."
count = 1

[[issues]]
file = "src/Adapter/Driver/Pdo/Result.php"
code = "missing-property-type"
message = "Property `$resource` is missing a type hint."
count = 1

[[issues]]
file = "src/Adapter/Driver/StatementInterface.php"
code = "missing-return-type"
message = "Function `getResource` is missing a return type hint."
count = 1

[[issues]]
file = "src/Adapter/ParameterContainer.php"
code = "incompatible-parameter-name"
message = 'Parameter #1 of `PhpDb\Adapter\ParameterContainer::offsetexists()` is named `$name` but parent `ArrayAccess::offsetexists()` names it `$offset`'
count = 1

[[issues]]
file = "src/Adapter/ParameterContainer.php"
code = "incompatible-parameter-name"
message = 'Parameter #1 of `PhpDb\Adapter\ParameterContainer::offsetget()` is named `$name` but parent `ArrayAccess::offsetget()` names it `$offset`'
count = 1

[[issues]]
file = "src/Adapter/ParameterContainer.php"
code = "incompatible-parameter-name"
message = 'Parameter #1 of `PhpDb\Adapter\ParameterContainer::offsetset()` is named `$name` but parent `ArrayAccess::offsetset()` names it `$offset`'
count = 1

[[issues]]
file = "src/Adapter/ParameterContainer.php"
code = "incompatible-parameter-name"
message = 'Parameter #1 of `PhpDb\Adapter\ParameterContainer::offsetunset()` is named `$name` but parent `ArrayAccess::offsetunset()` names it `$offset`'
count = 1

[[issues]]
file = "src/Adapter/Profiler/Profiler.php"
code = "missing-property-type"
message = "Property `$currentIndex` is missing a type hint."
count = 1

[[issues]]
file = "src/Adapter/Profiler/Profiler.php"
code = "missing-property-type"
message = "Property `$profiles` is missing a type hint."
count = 1

[[issues]]
file = "src/ConfigProvider.php"
code = "imprecise-type"
Expand Down Expand Up @@ -156,12 +30,6 @@ code = "imprecise-type"
message = "Type `array` in return type of `getConfig` is imprecise, equivalent to `array<array-key, mixed>`."
count = 1

[[issues]]
file = "src/Container/AbstractAdapterInterfaceFactory.php"
code = "incompatible-parameter-type"
message = 'Parameter `$container` of `PhpDb\Container\AbstractAdapterInterfaceFactory::__invoke()` expects type `Psr\Container\ContainerInterface&Laminas\ServiceManager\ServiceManager` but parent `Laminas\ServiceManager\Factory\FactoryInterface::__invoke()` expects type `Psr\Container\ContainerInterface`'
count = 1

[[issues]]
file = "src/Container/AbstractAdapterInterfaceFactory.php"
code = "invalid-return-statement"
Expand Down Expand Up @@ -240,12 +108,6 @@ code = "unhandled-thrown-type"
message = 'Potentially unhandled exception `Psr\Container\NotFoundExceptionInterface` in `PhpDb\Container\AbstractAdapterInterfaceFactory::getConfig`.'
count = 1

[[issues]]
file = "src/Container/AdapterInterfaceDelegator.php"
code = "class-must-be-final"
message = 'Class `PhpDb\Container\AdapterInterfaceDelegator` should be declared `final`.'
count = 1

[[issues]]
file = "src/Container/AdapterInterfaceDelegator.php"
code = "imprecise-type"
Expand Down Expand Up @@ -342,30 +204,12 @@ code = "incompatible-return-type"
message = 'Return type `int|null` of `PhpDb\ResultSet\AbstractResultSet::count()` is incompatible with parent return type `int` of `Countable::count()`'
count = 1

[[issues]]
file = "src/ResultSet/AbstractResultSet.php"
code = "invalid-type-cast"
message = "Casting `mixed` to `array`."
count = 1

[[issues]]
file = "src/ResultSet/AbstractResultSet.php"
code = "mixed-assignment"
message = "Assigning `mixed` type to a variable may lead to unexpected behavior."
count = 2

[[issues]]
file = "src/ResultSet/Exception/InvalidArgumentException.php"
code = "class-must-be-final"
message = 'Class `PhpDb\ResultSet\Exception\InvalidArgumentException` should be declared `final`.'
count = 1

[[issues]]
file = "src/ResultSet/Exception/RuntimeException.php"
code = "class-must-be-final"
message = 'Class `PhpDb\ResultSet\Exception\RuntimeException` should be declared `final`.'
count = 1

[[issues]]
file = "src/ResultSet/HydratingResultSet.php"
code = "redundant-docblock-type"
Expand Down Expand Up @@ -720,12 +564,6 @@ code = "non-existent-method"
message = 'Method `prepareStatement` does not exist on type `PhpDb\Sql\SqlInterface`.'
count = 1

[[issues]]
file = "src/Sql/Platform/Platform.php"
code = "class-must-be-final"
message = 'Class `PhpDb\Sql\Platform\Platform` should be declared `final`.'
count = 1

[[issues]]
file = "src/Sql/Platform/Platform.php"
code = "mixed-array-assignment"
Expand Down
2 changes: 1 addition & 1 deletion lint-baseline.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ count = 1
file = "src/ResultSet/AbstractResultSet.php"
code = "halstead"
message = "Method has a high halstead difficulty"
count = 3
count = 2

[[issues]]
file = "src/ResultSet/AbstractResultSet.php"
Expand Down
1 change: 1 addition & 0 deletions mago.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ ignore = [
{ code = "invalid-enum-case-value", in = ["src/Sql/ArgumentType.php"] },
]
class-initializers = [
"PhpDb\\Adapter\\Driver\\Pdo\\Result::initialize",
"PhpDb\\Adapter\\Driver\\Pdo\\Statement::initialize",
"PhpDb\\Adapter\\Driver\\Pdo\\Statement::setDriver",
"PhpDb\\ResultSet\\AbstractResultSet::initialize",
Expand Down
2 changes: 1 addition & 1 deletion src/Adapter/Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function getDriver(): Driver\DriverInterface
* @mago-expect lint:prefer-first-class-callable
*/
#[Override]
public function getHelpers()
public function getHelpers(): array
{
$functions = [];
$platform = $this->platform;
Expand Down
5 changes: 3 additions & 2 deletions src/Adapter/AdapterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace PhpDb\Adapter;

use Closure;
use PhpDb\ResultSet;

/**
Expand Down Expand Up @@ -51,9 +52,9 @@ public function getDriver(): Driver\DriverInterface;

/**
* @todo 0.3.x track down this usage!!!
* @return array
* @return list<Closure(string): string>
*/
public function getHelpers();
public function getHelpers(): array;

public function getPlatform(): Platform\PlatformInterface;

Expand Down
13 changes: 10 additions & 3 deletions src/Adapter/Driver/AbstractConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,15 @@ abstract class AbstractConnection implements ConnectionInterface, ProfilerAwareI

protected ?ProfilerInterface $profiler = null;

/** Extending classes must be covariant. */
protected $resource;
/**
* The driver's native connection handle, or null while disconnected. It is typed mixed
* because a native extension may hand back a resource, which has no declarable type, and
* property types are invariant, so a driver narrows it where it reads it, not by
* redeclaring it.
*
* @var resource|object|null
*/
protected mixed $resource = null;

#[Override]
public function disconnect(): ConnectionInterface
Expand Down Expand Up @@ -66,7 +73,7 @@ public function getProfiler(): ?ProfilerInterface
* @return resource|object|null
*/
#[Override]
public function getResource()
public function getResource(): mixed
{
if (! $this->isConnected()) {
$this->connect();
Expand Down
2 changes: 1 addition & 1 deletion src/Adapter/Driver/ConnectionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function getLastGeneratedValue(?string $name = null): string|int|false|nu
*
* @return resource|object|null
*/
public function getResource();
public function getResource(): mixed;

/** Checks whether the connection is in transaction state. */
public function inTransaction(): bool;
Expand Down
8 changes: 5 additions & 3 deletions src/Adapter/Driver/Pdo/AbstractPdo.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,13 @@ public function getProfiler(): ?ProfilerInterface
}

/**
* {@inheritDoc}
* The concrete driver sets the prototype, normally in its constructor.
*
* @throws Exception\RuntimeException When the concrete driver has not set it.
*/
public function getResultPrototype(): ?ResultInterface
public function getResultPrototype(): ResultInterface
{
return $this->resultPrototype;
return $this->resultPrototype ?? throw Exception\RuntimeException::forMissingResultPrototype();
}

#[Override]
Expand Down
3 changes: 0 additions & 3 deletions src/Adapter/Driver/Pdo/AbstractPdoConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ abstract class AbstractPdoConnection extends AbstractConnection implements

protected ?string $dsn;

/** @var ?PDO $resource */
protected $resource;

/**
* {@inheritDoc}
*
Expand Down
Loading
Loading