Skip to content

Commit 48df1a9

Browse files
committed
update baseline
Signed-off-by: Joey Smith <jsmith@webinertia.net> Signed-off-by: Joey Smith <jsmith@webinertia.net>
1 parent 378f495 commit 48df1a9

File tree

7 files changed

+577
-585
lines changed

7 files changed

+577
-585
lines changed

phpstan-baseline.neon

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ parameters:
66
count: 1
77
path: src/Container/DriverInterfaceFactoryFactory.php
88

9-
-
10-
message: '#^Cannot call static method createFromConfig\(\) on callable\.$#'
11-
identifier: staticMethod.nonObject
12-
count: 1
13-
path: src/Container/PdoDriverFactory.php
14-
159
-
1610
message: '#^Parameter \#1 \$name \(string\) of method PhpDb\\Adapter\\Sqlite\\Driver\\Pdo\\Connection\:\:getLastGeneratedValue\(\) should be compatible with parameter \$name \(null\) of method PhpDb\\Adapter\\Driver\\ConnectionInterface\:\:getLastGeneratedValue\(\)$#'
1711
identifier: method.childParameterType

src/ConfigProvider.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,17 @@ public function getDependencies(): array
5959
ConnectionInterfaceFactoryFactoryInterface::class => Container\ConnectionInterfaceFactoryFactory::class,
6060
DriverInterfaceFactoryFactoryInterface::class => Container\DriverInterfaceFactoryFactory::class,
6161
PlatformInterfaceFactoryFactoryInterface::class => Container\PlatformInterfaceFactoryFactory::class,
62-
MetadataInterface::class => Metadata\Source\SqliteMetadata::class,
62+
MetadataInterface::class => Metadata\Source\SqliteMetadata::class,
6363
],
6464
'factories' => [
65-
AdapterInterface::class => Container\AdapterFactory::class,
66-
Driver\Pdo\Connection::class => Container\PdoConnectionFactory::class,
67-
Driver\Pdo\Pdo::class => Container\PdoDriverFactory::class,
68-
Result::class => Container\PdoResultFactory::class,
69-
Statement::class => Container\PdoStatementFactory::class,
70-
Platform\Sqlite::class => Container\PlatformInterfaceFactory::class,
71-
Profiler::class => InvokableFactory::class,
72-
ResultSet\ResultSet::class => InvokableFactory::class,
65+
AdapterInterface::class => Container\AdapterFactory::class,
66+
Driver\Pdo\Connection::class => Container\PdoConnectionFactory::class,
67+
Driver\Pdo\Pdo::class => Container\PdoDriverFactory::class,
68+
Result::class => Container\PdoResultFactory::class,
69+
Statement::class => Container\PdoStatementFactory::class,
70+
Platform\Sqlite::class => Container\PlatformInterfaceFactory::class,
71+
Profiler::class => InvokableFactory::class,
72+
ResultSet\ResultSet::class => InvokableFactory::class,
7373
Metadata\Source\SqliteMetadata::class => Container\MetadataInterfaceFactory::class,
7474
],
7575
'invokables' => [

src/Container/PdoDriverFactory.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ final class PdoDriverFactory
1919
{
2020
public function __invoke(ContainerInterface $container): PdoDriverInterface&PdoDriver
2121
{
22-
2322
/** @var ConnectionInterface&Connection $connectionInstance */
2423
$connectionInstance = $container->get(Connection::class);
2524

@@ -41,7 +40,6 @@ public static function createFromConfig(
4140
ContainerInterface $container,
4241
string $requestedName,
4342
): PdoDriverInterface&PdoDriver {
44-
4543
$connectionFactory = (
4644
$container->get(ConnectionInterfaceFactoryFactory::class)
4745
)($container, $requestedName);
Lines changed: 101 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,101 @@
1-
<?php
2-
3-
declare(strict_types=1);
4-
5-
namespace PhpDbIntegrationTest\Adapter\Sqlite\Container\TestAsset;
6-
7-
use Laminas\ServiceManager\ServiceManager;
8-
use Laminas\Stdlib\ArrayUtils;
9-
use Override;
10-
use PhpDb\Adapter\AdapterInterface;
11-
use PhpDb\Adapter\Driver\DriverInterface;
12-
use PhpDb\Adapter\Sqlite\ConfigProvider;
13-
use PhpDb\Adapter\Sqlite\Driver\Pdo\Pdo;
14-
use PhpDb\ConfigProvider as LaminasDbConfigProvider;
15-
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
16-
use Psr\Container\ContainerInterface;
17-
18-
/**
19-
* This trait provides a setup method for integration tests that require
20-
* a database adapter configuration.
21-
*
22-
* It initializes the service manager with a database configuration,
23-
* allowing for the creation of an adapter manager and the retrieval
24-
* of an adapter instance.
25-
*/
26-
#[RequiresPhpExtension('pdo_sqlite')]
27-
trait SetupTrait
28-
{
29-
protected array $config = ['db' => []];
30-
31-
protected ?AdapterInterface $adapter;
32-
33-
protected ContainerInterface $container;
34-
35-
protected DriverInterface|string|null $driver;
36-
37-
#[Override]
38-
protected function setUp(): void
39-
{
40-
$this->getAdapter();
41-
parent::setUp();
42-
}
43-
44-
protected function getAdapter(array $config = []): AdapterInterface
45-
{
46-
$connectionConfig = [
47-
'db' => [
48-
'driver' => $this->driver ?? Pdo::class,
49-
'connection' => [
50-
'dsn' => 'sqlite::memory:',
51-
'charset' => 'utf8',
52-
'driver_options' => [],
53-
],
54-
'options' => [
55-
//'buffer_results' => false,
56-
],
57-
],
58-
];
59-
60-
// merge service config from both PhpDb and PhpDb\Adapter\Mysql
61-
$serviceManagerConfig = ArrayUtils::merge(
62-
(new LaminasDbConfigProvider())()['dependencies'],
63-
(new ConfigProvider())()['dependencies']
64-
);
65-
66-
$serviceManagerConfig = ArrayUtils::merge(
67-
$serviceManagerConfig,
68-
$connectionConfig
69-
);
70-
71-
// prefer passed config over environment variables
72-
if ($config !== []) {
73-
$serviceManagerConfig = ArrayUtils::merge($serviceManagerConfig, $config);
74-
}
75-
76-
$serviceManagerConfig = ArrayUtils::merge(
77-
$serviceManagerConfig,
78-
[
79-
'services' => [
80-
'config' => $serviceManagerConfig,
81-
],
82-
]
83-
);
84-
85-
$this->config = $serviceManagerConfig;
86-
$this->container = new ServiceManager($this->config);
87-
$this->adapter = $this->container->get(AdapterInterface::class);
88-
89-
return $this->adapter;
90-
}
91-
92-
protected function getConfig(): array
93-
{
94-
return $this->config;
95-
}
96-
97-
protected function getHostname(): string
98-
{
99-
return $this->getConfig()['db']['connection']['hostname'];
100-
}
101-
}
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace PhpDbIntegrationTest\Adapter\Sqlite\Container\TestAsset;
6+
7+
use Laminas\ServiceManager\ServiceManager;
8+
use Laminas\Stdlib\ArrayUtils;
9+
use Override;
10+
use PhpDb\Adapter\AdapterInterface;
11+
use PhpDb\Adapter\Driver\DriverInterface;
12+
use PhpDb\Adapter\Sqlite\ConfigProvider;
13+
use PhpDb\Adapter\Sqlite\Driver\Pdo\Pdo;
14+
use PhpDb\ConfigProvider as LaminasDbConfigProvider;
15+
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
16+
use Psr\Container\ContainerInterface;
17+
18+
/**
19+
* This trait provides a setup method for integration tests that require
20+
* a database adapter configuration.
21+
*
22+
* It initializes the service manager with a database configuration,
23+
* allowing for the creation of an adapter manager and the retrieval
24+
* of an adapter instance.
25+
*/
26+
#[RequiresPhpExtension('pdo_sqlite')]
27+
trait SetupTrait
28+
{
29+
protected array $config = ['db' => []];
30+
31+
protected ?AdapterInterface $adapter;
32+
33+
protected ContainerInterface $container;
34+
35+
protected DriverInterface|string|null $driver;
36+
37+
#[Override]
38+
protected function setUp(): void
39+
{
40+
$this->getAdapter();
41+
parent::setUp();
42+
}
43+
44+
protected function getAdapter(array $config = []): AdapterInterface
45+
{
46+
$connectionConfig = [
47+
'db' => [
48+
'driver' => $this->driver ?? Pdo::class,
49+
'connection' => [
50+
'dsn' => 'sqlite::memory:',
51+
'charset' => 'utf8',
52+
'driver_options' => [],
53+
],
54+
'options' => [
55+
//'buffer_results' => false,
56+
],
57+
],
58+
];
59+
60+
// merge service config from both PhpDb and PhpDb\Adapter\Mysql
61+
$serviceManagerConfig = ArrayUtils::merge(
62+
(new LaminasDbConfigProvider())()['dependencies'],
63+
(new ConfigProvider())()['dependencies']
64+
);
65+
66+
$serviceManagerConfig = ArrayUtils::merge(
67+
$serviceManagerConfig,
68+
$connectionConfig
69+
);
70+
71+
// prefer passed config over environment variables
72+
if ($config !== []) {
73+
$serviceManagerConfig = ArrayUtils::merge($serviceManagerConfig, $config);
74+
}
75+
76+
$serviceManagerConfig = ArrayUtils::merge(
77+
$serviceManagerConfig,
78+
[
79+
'services' => [
80+
'config' => $serviceManagerConfig,
81+
],
82+
]
83+
);
84+
85+
$this->config = $serviceManagerConfig;
86+
$this->container = new ServiceManager($this->config);
87+
$this->adapter = $this->container->get(AdapterInterface::class);
88+
89+
return $this->adapter;
90+
}
91+
92+
protected function getConfig(): array
93+
{
94+
return $this->config;
95+
}
96+
97+
protected function getHostname(): string
98+
{
99+
return $this->getConfig()['db']['connection']['hostname'];
100+
}
101+
}

0 commit comments

Comments
 (0)