Skip to content

Commit defc66d

Browse files
committed
Removes AdapterManager
Bumps deps Adds PHP 8.5 support Updates phpstan baseline Signed-off-by: Joey Smith <jsmith@webinertia.net> Signed-off-by: Joey Smith <jsmith@webinertia.net>
1 parent e49dd91 commit defc66d

13 files changed

+132
-202
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
}
3333
},
3434
"require": {
35-
"php": "~8.2.0 || ~8.3.0 || ~8.4.0",
36-
"php-db/phpdb": "^0.2.1"
35+
"php": "~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0",
36+
"php-db/phpdb": "^0.3.0"
3737
},
3838
"require-dev": {
3939
"ext-mysqli": "*",

composer.lock

Lines changed: 76 additions & 80 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpstan-baseline.neon

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +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/MysqliDriverFactory.php
14-
15-
-
16-
message: '#^Cannot call static method createFromConfig\(\) on callable\.$#'
17-
identifier: staticMethod.nonObject
18-
count: 1
19-
path: src/Container/PdoDriverFactory.php
20-
219
-
2210
message: '#^Method PhpDb\\Adapter\\Profiler\\ProfilerInterface\:\:profilerFinish\(\) invoked with 1 parameter, 0 required\.$#'
2311
identifier: arguments.count

src/ConfigProvider.php

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@
1515
use PhpDb\Adapter\Platform\PlatformInterface;
1616
use PhpDb\Adapter\Profiler;
1717
use PhpDb\Container\AdapterAbstractServiceFactory;
18-
use PhpDb\Container\AdapterManager;
1918
use PhpDb\Container\ConnectionInterfaceFactoryFactoryInterface;
2019
use PhpDb\Container\DriverInterfaceFactoryFactoryInterface;
21-
use PhpDb\Container\MetadataFactory;
2220
use PhpDb\Container\PlatformInterfaceFactoryFactoryInterface;
2321
use PhpDb\Metadata\MetadataInterface;
2422
use PhpDb\ResultSet;
@@ -28,8 +26,7 @@ final class ConfigProvider
2826
public function __invoke(): array
2927
{
3028
return [
31-
'dependencies' => $this->getDependencies(),
32-
AdapterManager::class => $this->getAdapterManagerConfig(),
29+
'dependencies' => $this->getDependencies(),
3330
];
3431
}
3532

@@ -40,23 +37,6 @@ public function getDependencies(): array
4037
AdapterAbstractServiceFactory::class,
4138
],
4239
'aliases' => [
43-
MetadataInterface::class => MysqlMetadata::class,
44-
],
45-
'factories' => [
46-
MysqlMetadata::class => MetadataFactory::class,
47-
],
48-
'delegators' => [
49-
AdapterManager::class => [
50-
Container\AdapterManagerDelegator::class,
51-
],
52-
],
53-
];
54-
}
55-
56-
public function getAdapterManagerConfig(): array
57-
{
58-
return [
59-
'aliases' => [
6040
'MySqli' => Driver\Mysqli\Mysqli::class,
6141
'MySQLi' => Driver\Mysqli\Mysqli::class,
6242
'Mysqli' => Driver\Mysqli\Mysqli::class,
@@ -74,29 +54,31 @@ public function getAdapterManagerConfig(): array
7454
ResultSet\ResultSetInterface::class => ResultSet\ResultSet::class,
7555
ConnectionInterfaceFactoryFactoryInterface::class => Container\ConnectionInterfaceFactoryFactory::class,
7656
DriverInterfaceFactoryFactoryInterface::class => Container\DriverInterfaceFactoryFactory::class,
57+
MetadataInterface::class => MysqlMetadata::class,
7758
PlatformInterfaceFactoryFactoryInterface::class => Container\PlatformInterfaceFactoryFactory::class,
7859
],
79-
'factories' => [
60+
'factories' => [
8061
AdapterInterface::class => Container\AdapterFactory::class,
8162
Driver\Mysqli\Mysqli::class => Container\MysqliDriverFactory::class,
8263
Driver\Mysqli\Connection::class => Container\MysqliConnectionFactory::class,
8364
Driver\Mysqli\Result::class => Container\MysqliResultFactory::class,
8465
Driver\Mysqli\Statement::class => Container\MysqliStatementFactory::class,
8566
Driver\Pdo\Pdo::class => Container\PdoDriverFactory::class,
8667
Driver\Pdo\Connection::class => Container\PdoConnectionFactory::class,
87-
Result::class => Container\PdoResultFactory::class,
68+
MysqlMetadata::class => Container\MetadataInterfaceFactory::class,
8869
PdoStatement::class => Container\PdoStatementFactory::class,
8970
PlatformInterface::class => Container\PlatformInterfaceFactory::class,
9071
Profiler\Profiler::class => InvokableFactory::class,
72+
Result::class => Container\PdoResultFactory::class,
9173
ResultSet\ResultSet::class => InvokableFactory::class,
9274
],
93-
'invokables' => [
75+
'invokables' => [
9476
Container\ConnectionInterfaceFactoryFactory::class
95-
=> Container\ConnectionInterfaceFactoryFactory::class,
77+
=> Container\ConnectionInterfaceFactoryFactory::class,
9678
Container\DriverInterfaceFactoryFactory::class
97-
=> Container\DriverInterfaceFactoryFactory::class,
79+
=> Container\DriverInterfaceFactoryFactory::class,
9880
Container\PlatformInterfaceFactoryFactory::class
99-
=> Container\PlatformInterfaceFactoryFactory::class,
81+
=> Container\PlatformInterfaceFactoryFactory::class,
10082
],
10183
];
10284
}

src/Container/AdapterFactory.php

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use PhpDb\Adapter\Exception\RuntimeException;
1313
use PhpDb\Adapter\Platform\PlatformInterface;
1414
use PhpDb\Adapter\Profiler\ProfilerInterface;
15-
use PhpDb\Container\AdapterManager;
1615
use PhpDb\ResultSet\ResultSetInterface;
1716
use Psr\Container\ContainerInterface;
1817

@@ -22,9 +21,6 @@ final class AdapterFactory
2221
{
2322
public function __invoke(ContainerInterface $container): AdapterInterface
2423
{
25-
/** @var AdapterManager $adapterManager */
26-
$adapterManager = $container->get(AdapterManager::class);
27-
2824
/** @var array $config */
2925
$config = $container->get('config');
3026

@@ -38,39 +34,39 @@ public function __invoke(ContainerInterface $container): AdapterInterface
3834
/** @var string $driver */
3935
$driver = $dbConfig['driver'];
4036

41-
if (! $adapterManager->has($driver)) {
37+
if (! $container->has($driver)) {
4238
throw new ServiceNotFoundException(sprintf(
4339
'Database driver "%s" is not registered in the adapter manager.',
4440
$driver
4541
));
4642
}
4743

4844
/** @var DriverInterface|PdoDriverInterface $driverInstance */
49-
$driverInstance = $adapterManager->get($driver);
45+
$driverInstance = $container->get($driver);
5046

51-
if (! $adapterManager->has(PlatformInterface::class)) {
47+
if (! $container->has(PlatformInterface::class)) {
5248
throw new ServiceNotFoundException(sprintf(
5349
'Database platform "%s" is not registered in the adapter manager.',
5450
PlatformInterface::class
5551
));
5652
}
5753

5854
/** @var PlatformInterface $platformInstance */
59-
$platformInstance = $adapterManager->get(PlatformInterface::class);
55+
$platformInstance = $container->get(PlatformInterface::class);
6056

61-
if (! $adapterManager->has(ResultSetInterface::class)) {
57+
if (! $container->has(ResultSetInterface::class)) {
6258
throw new ServiceNotFoundException(sprintf(
6359
'ResultSet "%s" is not registered in the adapter manager.',
6460
ResultSetInterface::class
6561
));
6662
}
6763

6864
/** @var ResultSetInterface $resultSetInstance */
69-
$resultSetInstance = $adapterManager->get(ResultSetInterface::class);
65+
$resultSetInstance = $container->get(ResultSetInterface::class);
7066

7167
/** @var ProfilerInterface|null $profilerInstanceOrNull */
72-
$profilerInstanceOrNull = $adapterManager->has(ProfilerInterface::class)
73-
? $adapterManager->get(ProfilerInterface::class)
68+
$profilerInstanceOrNull = $container->has(ProfilerInterface::class)
69+
? $container->get(ProfilerInterface::class)
7470
: null;
7571

7672
return new Adapter(

src/Container/AdapterManagerDelegator.php

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/Container/ConnectionInterfaceFactoryFactory.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use PhpDb\Adapter\Mysql\Container\PdoConnectionFactory;
99
use PhpDb\Adapter\Mysql\Driver\Mysqli\Mysqli;
1010
use PhpDb\Adapter\Mysql\Driver\Pdo\Pdo;
11-
use PhpDb\Container\AdapterManager;
1211
use PhpDb\Container\ConnectionInterfaceFactoryFactoryInterface as FactoryFactoryInterface;
1312
use Psr\Container\ContainerInterface;
1413
use RuntimeException;
@@ -29,7 +28,7 @@ public function __invoke(
2928
$requestedName
3029
));
3130
}
32-
$adapterServices = $container->get('config')[AdapterManager::class];
31+
$adapterServices = $container->get('config');
3332
$configuredDriver = $adapterConfig[$requestedName]['driver'];
3433
if (array_key_exists($configuredDriver, $adapterServices['aliases'])) {
3534
$aliasTo = $adapterServices['aliases'][$configuredDriver];

src/Container/DriverInterfaceFactoryFactory.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace PhpDb\Adapter\Mysql\Container;
66

7-
use PhpDb\Container\AdapterManager;
87
use PhpDb\Container\DriverInterfaceFactoryFactoryInterface as FactoryFactoryInterface;
98
use Psr\Container\ContainerInterface;
109
use RuntimeException;
@@ -24,7 +23,7 @@ public function __invoke(
2423
$requestedName
2524
));
2625
}
27-
$adapterServices = $container->get('config')[AdapterManager::class];
26+
$adapterServices = $container->get('config');
2827

2928
$configuredDriver = $adapterConfig[$requestedName]['driver'];
3029
$aliasTo ??= $adapterServices['aliases'][$configuredDriver] ?? $configuredDriver;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace PhpDb\Adapter\Mysql\Container;
6+
7+
use PhpDb\Adapter\AdapterInterface;
8+
use PhpDb\Adapter\Mysql\Metadata\Source\MysqlMetadata;
9+
use PhpDb\Metadata\MetadataInterface;
10+
use Psr\Container\ContainerInterface;
11+
12+
final class MetadataInterfaceFactory
13+
{
14+
public function __invoke(ContainerInterface $container): MetadataInterface
15+
{
16+
$adapterInterface = $container->get(AdapterInterface::class);
17+
return new MysqlMetadata($adapterInterface);
18+
}
19+
}

src/Container/MysqliDriverFactory.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,12 @@
66

77
use PhpDb\Adapter\Driver;
88
use PhpDb\Adapter\Mysql\Driver\Mysqli;
9-
use PhpDb\Container\AdapterManager;
109
use Psr\Container\ContainerInterface;
1110

1211
final class MysqliDriverFactory
1312
{
1413
public function __invoke(ContainerInterface $container): Driver\DriverInterface&Mysqli\Mysqli
1514
{
16-
/** @var AdapterManager $adapterManager */
17-
$adapterManager = $container->get(AdapterManager::class);
18-
1915
/** @var array $config */
2016
$config = $container->get('config');
2117

@@ -26,13 +22,13 @@ public function __invoke(ContainerInterface $container): Driver\DriverInterface&
2622
$options = $dbConfig['options'] ?? [];
2723

2824
/** @var Driver\ConnectionInterface&Mysqli\Connection $connectionInstance */
29-
$connectionInstance = $adapterManager->get(Mysqli\Connection::class);
25+
$connectionInstance = $container->get(Mysqli\Connection::class);
3026

3127
/** @var Driver\StatementInterface&Mysqli\Statement $statementInstance */
32-
$statementInstance = $adapterManager->get(Mysqli\Statement::class);
28+
$statementInstance = $container->get(Mysqli\Statement::class);
3329

3430
/** @var Driver\ResultInterface&Mysqli\Result $resultInstance */
35-
$resultInstance = $adapterManager->get(Mysqli\Result::class);
31+
$resultInstance = $container->get(Mysqli\Result::class);
3632

3733
return new Mysqli\Mysqli(
3834
$connectionInstance,
@@ -46,10 +42,8 @@ public static function createFromConfig(
4642
ContainerInterface $container,
4743
string $requestedName,
4844
): Driver\DriverInterface&Mysqli\Mysqli {
49-
/** @var AdapterManager $adapterManager */
50-
$adapterManager = $container->get(AdapterManager::class);
5145
$connectionFactory = (
52-
$adapterManager->get(ConnectionInterfaceFactoryFactory::class)
46+
$container->get(ConnectionInterfaceFactoryFactory::class)
5347
)($container, $requestedName);
5448
/** @var array $config */
5549
$config = $container->get('config');
@@ -60,8 +54,8 @@ public static function createFromConfig(
6054

6155
return new Mysqli\Mysqli(
6256
$connectionFactory::createFromConfig($container, $requestedName),
63-
$adapterManager->get(Mysqli\Statement::class),
64-
$adapterManager->get(Mysqli\Result::class),
57+
$container->get(Mysqli\Statement::class),
58+
$container->get(Mysqli\Result::class),
6559
$adapterConfig['options'] ?? []
6660
);
6761
}

0 commit comments

Comments
 (0)