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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml",
"test-integration": "phpunit --colors=always --testsuite \"integration test\"",
"sa": "vendor/bin/phpstan analyse --memory-limit=256M",
"sa-generate-baseline": "vendor/bin/phpstan analyse --memory-limit=256M --generate-baseline",
"sa-gen-baseline": "vendor/bin/phpstan analyse --memory-limit=256M --generate-baseline",
"sa-verbose": "vendor/bin/phpstan analyse --memory-limit=256M -vv",
"upload-coverage": "coveralls -v"
}
Expand Down
8 changes: 4 additions & 4 deletions composer.lock

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

19 changes: 18 additions & 1 deletion phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,2 +1,19 @@
parameters:
ignoreErrors:
ignoreErrors:
-
message: '#^Parameter \#2 \$array of function implode expects array\<string\>, array\<int, array\<int\|string, string\>\> given\.$#'
identifier: argument.type
count: 1
path: src/Metadata/Source.php

-
message: '#^Parameter \#2 \$array of function implode expects array\<string\>, array\<int, array\<string, string\>\|string\> given\.$#'
identifier: argument.type
count: 1
path: src/Metadata/Source.php

-
message: '#^Parameter \#2 \$array of function implode expects array\<string\>, array\<int, list\<string\>\> given\.$#'
identifier: argument.type
count: 1
path: src/Metadata/Source.php
7 changes: 1 addition & 6 deletions src/AdapterPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@ class AdapterPlatform extends AbstractPlatform
*/
protected string $quoteIdentifierTo = '""';

/** @var string[] */
private array $knownPgsqlResources = [
'pgsql link',
'pgsql link persistent',
];

public function __construct(
private readonly DriverInterface|PdoDriverInterface|PDO $driver,
) {
Expand Down Expand Up @@ -89,6 +83,7 @@ public function quoteTrustedValue($value): string
*/
protected function quoteViaDriver($value): ?string
{
/** @var PgSqlConnection|string $resource */
$resource = $this->driver instanceof DriverInterface
? $this->driver->getConnection()->getResource()
: $this->driver;
Expand Down
38 changes: 16 additions & 22 deletions src/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,29 @@

namespace PhpDb\Adapter\Pgsql;

use Laminas\ServiceManager\Factory\InvokableFactory;
use PhpDb\Adapter\Adapter;

Check failure on line 7 in src/ConfigProvider.php

View workflow job for this annotation

GitHub Actions / QA Checks (PHPCodeSniffer [8.2, locked], ubuntu-latest, laminas/laminas-continuous-integration-ac...

Type PhpDb\Adapter\Adapter is not used in this file.
use PhpDb\Adapter\AdapterInterface;
use PhpDb\Adapter\Driver\ConnectionInterface;
use PhpDb\Adapter\Driver\DriverInterface;
use PhpDb\Adapter\Driver\Pdo\Statement as PdoStatement;
use PhpDb\Adapter\Driver\PdoConnectionInterface;
use PhpDb\Adapter\Driver\PdoDriverInterface;
use PhpDb\Adapter\Driver\Pdo\Statement as PdoStatement;
use PhpDb\Adapter\Platform\PlatformInterface;
use PhpDb\Adapter\Pgsql\Pdo\Connection as PdoConnection;
use PhpDb\Adapter\Pgsql\Pdo\Driver as PdoDriver;
use PhpDb\Adapter\Profiler\Profiler;
use PhpDb\Adapter\Profiler\ProfilerInterface;
use PhpDb\Container\AdapterAbstractServiceFactory;
use PhpDb\Adapter\Platform\PlatformInterface;
use PhpDb\ConfigProvider as PhpDbConfigProvider;
use PhpDb\Metadata\MetadataInterface;
use PhpDb\ResultSet\ResultSetInterface;

/**
* @internal
*/
final readonly class ConfigProvider
{
public function __invoke(): array
{
return [
'dependencies' => $this->getDependencies(),

Check failure on line 28 in src/ConfigProvider.php

View workflow job for this annotation

GitHub Actions / QA Checks (PHPCodeSniffer [8.2, locked], ubuntu-latest, laminas/laminas-continuous-integration-ac...

Expected 1 space before double arrow; 10 found
AdapterInterface::class => $this->getConfig(),
//AdapterInterface::class => $this->getConfig(),
];
}

Expand All @@ -44,7 +43,7 @@
'database' => 'your_database',
],
// Named Adapter configurations
'adapters' => [
PhpDbConfigProvider::NAMED_ADAPTER_KEY => [
AdapterInterface::class => [
'driver' => Driver::class,
'connection' => [
Expand All @@ -62,11 +61,7 @@
public function getDependencies(): array
{
return [
'abstract_factories' => [
Container\AdapterAbstractServiceFactory::class,
],
'aliases' => [
AdapterInterface::class => Adapter::class,
DriverInterface::class => Driver::class,
'pgsql' => Driver::class,
'PgSQL' => Driver::class,
Expand All @@ -88,15 +83,14 @@
PlatformInterface::class => AdapterPlatform::class,
],
'factories' => [
Adapter::class => Container\AdapterInterfaceFactory::class,
AdapterPlatform::class => Container\PlatformInterfaceFactory::class,
Connection::class => Container\ConnectionInterfaceFactory::class,
Metadata\Source::class => Container\MetadataInterfaceFactory::class,
Statement::class => Container\StatementInterfaceFactory::class,
Driver::class => Container\DriverInterfaceFactory::class,
PdoConnection::class => Container\PdoConnectionInterfaceFactory::class,
PdoDriver::class => Container\PdoDriverInterfaceFactory::class,
PdoStatement::class => Container\PdoStatemenFactory::class,
AdapterPlatform::class => Container\PlatformInterfaceFactory::class,
Connection::class => Container\ConnectionInterfaceFactory::class,
Driver::class => Container\DriverInterfaceFactory::class,
Metadata\Source::class => Container\MetadataInterfaceFactory::class,
PdoConnection::class => Container\PdoConnectionInterfaceFactory::class,
PdoDriver::class => Container\PdoDriverInterfaceFactory::class,
PdoStatement::class => Container\PdoStatementFactory::class,
Statement::class => Container\StatementInterfaceFactory::class,
// Provide the following if you wish to override the Profiler implementation
//ProfilerInterface::class => YourCustomProfilerFactory::class,
// Provide the following if you wish to override the ResultSet implementation
Expand Down
10 changes: 6 additions & 4 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

class Connection extends AbstractConnection implements DriverAwareInterface
{
protected Driver $driver;
protected DriverInterface|Driver $driver;

/** @var ?PgSqlConnection */
protected $resource;
Expand All @@ -58,6 +58,7 @@ public function setResource(
return $this;
}

/** @phpstan-ignore method.childReturnType */
#[Override]
public function getResource(): ?PgSqlConnection
{
Expand All @@ -66,7 +67,7 @@ public function getResource(): ?PgSqlConnection

#[Override]
public function setDriver(
DriverInterface $driver
DriverInterface|Driver $driver
): ConnectionInterface&DriverAwareInterface {
$this->driver = $driver;

Expand Down Expand Up @@ -120,8 +121,8 @@ public function connect(): static
set_error_handler(function ($number, $string) {
throw new Exception\RuntimeException(
self::class . '::connect: Unable to connect to database',
$number ?? 0,
new Exception\ErrorException($string, $number ?? 0)
$number,
new Exception\ErrorException($string, $number)
);
});
try {
Expand Down Expand Up @@ -253,6 +254,7 @@ public function execute($sql): ResultInterface
throw new Exception\InvalidQueryException(pg_last_error($this->resource));
}

/** @phpstan-ignore argument.type */
return $this->driver->createResult($resultResource);
}

Expand Down
124 changes: 0 additions & 124 deletions src/Container/AdapterAbstractServiceFactory.php

This file was deleted.

Loading