Skip to content
Open
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
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"require": {
"php": "~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0",
"php-db/phpdb": "^0.3.2"
"php-db/phpdb": "^0.4.0"
},
"require-dev": {
"ext-mysqli": "*",
Expand Down Expand Up @@ -62,7 +62,7 @@
"scripts": {
"check": [
"@cs-check",
"@static-analysis",
"@sa",
"@test",
"@test-integration"
],
Expand All @@ -71,8 +71,8 @@
"test": "phpunit --colors=always --testsuite \"unit test\"",
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml",
"test-integration": "phpunit --colors=always --testsuite \"integration test\"",
"static-analysis": "vendor/bin/phpstan analyse --memory-limit=256M",
"sa-generate-baseline": "vendor/bin/phpstan analyse --memory-limit=256M --generate-baseline",
"sa": "vendor/bin/phpstan analyse --memory-limit=256M",
"sa-gen-baseline": "vendor/bin/phpstan analyse --memory-limit=256M --generate-baseline",
"upload-coverage": "coveralls -v"
}
}
57 changes: 29 additions & 28 deletions composer.lock

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

30 changes: 0 additions & 30 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,6 @@ parameters:
count: 2
path: src/Driver/Pdo/Connection.php

-
message: '#^Parameter \#2 \$parameters of class PhpDb\\Adapter\\Exception\\InvalidConnectionParametersException constructor expects int, array given\.$#'
identifier: argument.type
count: 2
path: src/Driver/Pdo/Connection.php

-
message: '#^Parameter \#1 \$resource \(PDOStatement\) of method PhpDb\\Adapter\\Mysql\\Driver\\Pdo\\Pdo\:\:createResult\(\) should be compatible with parameter \$resource \(resource\) of method PhpDb\\Adapter\\Driver\\DriverInterface\:\:createResult\(\)$#'
identifier: method.childParameterType
Expand Down Expand Up @@ -198,30 +192,6 @@ parameters:
count: 2
path: src/Metadata/Source/MysqlMetadata.php

-
message: '#^Method PhpDb\\Adapter\\Mysql\\Sql\\Platform\\Mysql\\Ddl\\CreateTableDecorator\:\:processColumns\(\) never returns null so it can be removed from the return type\.$#'
identifier: return.unusedType
count: 1
path: src/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php

-
message: '#^Method PhpDb\\Adapter\\Mysql\\Sql\\Platform\\Mysql\\Ddl\\CreateTableDecorator\:\:processColumns\(\) should return array\<array\<string\>\>\|null but empty return statement found\.$#'
identifier: return.empty
count: 1
path: src/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php

-
message: '#^Method PhpDb\\Adapter\\Mysql\\Sql\\Platform\\Mysql\\SelectDecorator\:\:processLimit\(\) should return array\<string\>\|null but returns array\<int, int\>\.$#'
identifier: return.type
count: 1
path: src/Sql/Platform/Mysql/SelectDecorator.php

-
message: '#^Offset ''paramPrefix'' does not exist on string\.$#'
identifier: offsetAccess.notFound
count: 2
path: src/Sql/Platform/Mysql/SelectDecorator.php

-
message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertIsInt\(\) with int will always evaluate to true\.$#'
identifier: staticMethod.alreadyNarrowedType
Expand Down
33 changes: 18 additions & 15 deletions src/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,20 @@

namespace PhpDb\Adapter\Mysql;

use Laminas\ServiceManager\Factory\InvokableFactory;
use PhpDb\Adapter\AdapterInterface;
use PhpDb\Adapter\Driver\DriverInterface;
use PhpDb\Adapter\Driver\Pdo\Result;
use PhpDb\Adapter\Driver\Pdo\Statement as PdoStatement;
use PhpDb\Adapter\Driver\PdoDriverInterface;
use PhpDb\Adapter\Mysql\Driver;
use PhpDb\Adapter\Mysql\Metadata\Source\MysqlMetadata;
use PhpDb\Adapter\Platform\PlatformInterface;
use PhpDb\Adapter\Profiler;
use PhpDb\Container\AdapterAbstractServiceFactory;
use PhpDb\Container\ConnectionInterfaceFactoryFactoryInterface;
use PhpDb\Container\DriverInterfaceFactoryFactoryInterface;
use PhpDb\Container\PlatformInterfaceFactoryFactoryInterface;
use PhpDb\Metadata\MetadataInterface;
use PhpDb\ResultSet;

/** @internal */
final class ConfigProvider
{
public function __invoke(): array
Expand Down Expand Up @@ -50,35 +47,41 @@ public function getDependencies(): array
'pdo' => Driver\Pdo\Pdo::class,
DriverInterface::class => Driver\Mysqli\Mysqli::class,
PdoDriverInterface::class => Driver\Pdo\Pdo::class,
Profiler\ProfilerInterface::class => Profiler\Profiler::class,
ResultSet\ResultSetInterface::class => ResultSet\ResultSet::class,
ConnectionInterfaceFactoryFactoryInterface::class => Container\ConnectionInterfaceFactoryFactory::class,
DriverInterfaceFactoryFactoryInterface::class => Container\DriverInterfaceFactoryFactory::class,
MetadataInterface::class => MysqlMetadata::class,
PlatformInterfaceFactoryFactoryInterface::class => Container\PlatformInterfaceFactoryFactory::class,
// Uncomment to override the default implementations
//Profiler\ProfilerInterface::class => Profiler\Profiler::class,
//ResultSet\ResultSetInterface::class => ResultSet\ResultSet::class,
],
'factories' => [
AdapterInterface::class => Container\AdapterFactory::class,
Driver\Mysqli\Mysqli::class => Container\MysqliDriverFactory::class,
Driver\Mysqli\Connection::class => Container\MysqliConnectionFactory::class,
Driver\Mysqli\Result::class => Container\MysqliResultFactory::class,
Driver\Mysqli\Statement::class => Container\MysqliStatementFactory::class,
Driver\Mysqli\Statement::class => Container\StatementInterfaceFactory::class,
Driver\Pdo\Pdo::class => Container\PdoDriverFactory::class,
Driver\Pdo\Connection::class => Container\PdoConnectionFactory::class,
PdoStatement::class => Container\StatementInterfaceFactory::class,
MysqlMetadata::class => Container\MetadataInterfaceFactory::class,
PdoStatement::class => Container\PdoStatementFactory::class,
PlatformInterface::class => Container\PlatformInterfaceFactory::class,
Profiler\Profiler::class => InvokableFactory::class,
Result::class => Container\PdoResultFactory::class,
ResultSet\ResultSet::class => InvokableFactory::class,
],
'invokables' => [
Container\ConnectionInterfaceFactoryFactory::class
=> Container\ConnectionInterfaceFactoryFactory::class,
=> Container\ConnectionInterfaceFactoryFactory::class,
Container\DriverInterfaceFactoryFactory::class
=> Container\DriverInterfaceFactoryFactory::class,
=> Container\DriverInterfaceFactoryFactory::class,
Container\PlatformInterfaceFactoryFactory::class
=> Container\PlatformInterfaceFactoryFactory::class,
=> Container\PlatformInterfaceFactoryFactory::class,
// Uncomment to override the default implementations
// Driver\Mysqli\Result::class
// => Driver\Mysqli\Result::class,
// Profiler\Profiler::class
// => Profiler\Profiler::class,
// Result::class
// => Result::class,
// ResultSet\ResultSet::class
// => ResultSet\ResultSet::class,
],
];
}
Expand Down
32 changes: 16 additions & 16 deletions src/Container/AdapterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

use function sprintf;

/** @internal */
final class AdapterFactory
{
public function __invoke(ContainerInterface $container): AdapterInterface
Expand All @@ -36,7 +37,7 @@ public function __invoke(ContainerInterface $container): AdapterInterface

if (! $container->has($driver)) {
throw new ServiceNotFoundException(sprintf(
'Database driver "%s" is not registered in the adapter manager.',
'Database driver "%s" is not registered in the container.',
$driver
));
}
Expand All @@ -46,34 +47,33 @@ public function __invoke(ContainerInterface $container): AdapterInterface

if (! $container->has(PlatformInterface::class)) {
throw new ServiceNotFoundException(sprintf(
'Database platform "%s" is not registered in the adapter manager.',
'Database platform "%s" is not registered in the container.',
PlatformInterface::class
));
}

/** @var PlatformInterface $platformInstance */
$platformInstance = $container->get(PlatformInterface::class);

if (! $container->has(ResultSetInterface::class)) {
throw new ServiceNotFoundException(sprintf(
'ResultSet "%s" is not registered in the adapter manager.',
ResultSetInterface::class
));
}

/** @var ResultSetInterface $resultSetInstance */
$resultSetInstance = $container->get(ResultSetInterface::class);

/** @var ProfilerInterface|null $profilerInstanceOrNull */
$profilerInstanceOrNull = $container->has(ProfilerInterface::class)
? $container->get(ProfilerInterface::class)
: null;

// If its not provided, use the default ResultSet
if (! $container->has(ResultSetInterface::class)) {
return new Adapter(
driver: $driverInstance,
platform: $platformInstance,
profiler: $profilerInstanceOrNull
);
}

return new Adapter(
$driverInstance,
$platformInstance,
$resultSetInstance,
$profilerInstanceOrNull
driver: $driverInstance,
platform: $platformInstance,
queryResultSetPrototype: $container->get(ResultSetInterface::class),
profiler: $profilerInstanceOrNull
);
}
}
1 change: 1 addition & 0 deletions src/Container/ConnectionInterfaceFactoryFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use function array_key_exists;
use function sprintf;

/** @internal */
final class ConnectionInterfaceFactoryFactory implements FactoryFactoryInterface
{
public function __invoke(
Expand Down
Loading