Skip to content

Commit e50c723

Browse files
authored
Merge pull request #16 from settermjd/fix-qa-issues
Update code to match the project style guide
2 parents 394667d + 13c19ab commit e50c723

28 files changed

+115
-194
lines changed

psalm-baseline.xml

Lines changed: 2 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121
<InvalidArgument>
2222
<code><![CDATA[$this->connectionParameters]]></code>
2323
</InvalidArgument>
24-
<MixedArgument>
25-
<code><![CDATA[$this->resource->getAttribute(\PDO::ATTR_DRIVER_NAME)]]></code>
26-
</MixedArgument>
24+
<MixedArgument/>
2725
<MixedArgumentTypeCoercion>
2826
<code><![CDATA[$key]]></code>
2927
</MixedArgumentTypeCoercion>
@@ -80,9 +78,6 @@
8078
</RedundantConditionGivenDocblockType>
8179
</file>
8280
<file src="src/Metadata/Source/SqliteMetadata.php">
83-
<ClassMustBeFinal>
84-
<code><![CDATA[SqliteMetadata]]></code>
85-
</ClassMustBeFinal>
8681
<MixedArgument>
8782
<code><![CDATA[$fk['match']]]></code>
8883
<code><![CDATA[$fk['on_delete']]]></code>
@@ -364,17 +359,9 @@
364359
</file>
365360
<file src="test/unit/AdapterTest.php">
366361
<InvalidPropertyAssignmentValue>
367-
<code><![CDATA[$this->getMockBuilder(Driver::class)
368-
->setConstructorArgs([
369-
$this->mockConnection,
370-
$this->mockStatement,
371-
])
372-
->getMock()]]></code>
373362
<code><![CDATA[$this->getMockBuilder(Statement::class)->getMock()]]></code>
374363
</InvalidPropertyAssignmentValue>
375364
<MixedArgument>
376-
<code><![CDATA[Driver::class]]></code>
377-
<code><![CDATA[Driver::class]]></code>
378365
<code><![CDATA[Statement::class]]></code>
379366
</MixedArgument>
380367
<MixedAssignment>
@@ -432,56 +419,13 @@
432419
<code><![CDATA[Adapter]]></code>
433420
<code><![CDATA[Adapter]]></code>
434421
<code><![CDATA[Adapter]]></code>
435-
<code><![CDATA[Driver]]></code>
436-
<code><![CDATA[Driver]]></code>
437422
<code><![CDATA[Statement]]></code>
438423
</UndefinedClass>
439424
<UnusedPsalmSuppress>
440425
<code><![CDATA[UndefinedMagicPropertyFetch]]></code>
441426
<code><![CDATA[UndefinedMagicPropertyFetch]]></code>
442427
</UnusedPsalmSuppress>
443428
</file>
444-
<file src="test/unit/ConfigProviderTest.php">
445-
<MixedPropertyTypeCoercion>
446-
<code><![CDATA[[
447-
'aliases' => [
448-
PlatformInterface::class => Platform\Sqlite::class,
449-
ProfilerInterface::class => Profiler::class,
450-
],
451-
'factories' => [
452-
AdapterInterface::class => AdapterServiceFactory::class,
453-
DriverInterface::class => Driver\Pdo\DriverFactory::class,
454-
Platform\Sqlite::class => InvokableFactory::class,
455-
Profiler::class => InvokableFactory::class,
456-
],
457-
]]]></code>
458-
</MixedPropertyTypeCoercion>
459-
<UndefinedClass>
460-
<code><![CDATA[AdapterServiceFactory]]></code>
461-
<code><![CDATA[Driver\Pdo\DriverFactory]]></code>
462-
</UndefinedClass>
463-
</file>
464-
<file src="test/unit/Driver/Pdo/PdoTest.php">
465-
<MixedAssignment>
466-
<code><![CDATA[$result]]></code>
467-
<code><![CDATA[$this->pdo]]></code>
468-
</MixedAssignment>
469-
<MixedMethodCall>
470-
<code><![CDATA[setConnectionParameters]]></code>
471-
</MixedMethodCall>
472-
<UndefinedClass>
473-
<code><![CDATA[$this->pdo]]></code>
474-
<code><![CDATA[$this->pdo]]></code>
475-
<code><![CDATA[$this->pdo]]></code>
476-
<code><![CDATA[$this->pdo]]></code>
477-
<code><![CDATA[$this->pdo]]></code>
478-
<code><![CDATA[$this->pdo]]></code>
479-
<code><![CDATA[Driver]]></code>
480-
<code><![CDATA[Driver]]></code>
481-
<code><![CDATA[Driver]]></code>
482-
<code><![CDATA[Driver]]></code>
483-
</UndefinedClass>
484-
</file>
485429
<file src="test/unit/Driver/Pdo/ResultTest.php">
486430
<InvalidArrayOffset>
487431
<code><![CDATA[$data[$position++]]]></code>
@@ -490,17 +434,6 @@
490434
<code><![CDATA[function () use ($data, &$position) {]]></code>
491435
</MissingClosureReturnType>
492436
</file>
493-
<file src="test/unit/Driver/Pdo/StatementIntegrationTest.php">
494-
<InvalidArgument>
495-
<code><![CDATA[$driver]]></code>
496-
</InvalidArgument>
497-
<MixedArgument>
498-
<code><![CDATA[Driver::class]]></code>
499-
</MixedArgument>
500-
<UndefinedClass>
501-
<code><![CDATA[Driver]]></code>
502-
</UndefinedClass>
503-
</file>
504437
<file src="test/unit/Driver/Pdo/StatementTest.php">
505438
<MixedArgument>
506439
<code><![CDATA[new Driver(new Connection())]]></code>
@@ -509,47 +442,8 @@
509442
<code><![CDATA[Driver]]></code>
510443
</UndefinedClass>
511444
</file>
512-
<file src="test/unit/ModuleTest.php">
513-
<MixedPropertyTypeCoercion>
514-
<code><![CDATA[[
515-
'aliases' => [
516-
PlatformInterface::class => Platform\Sqlite::class,
517-
ProfilerInterface::class => Profiler::class,
518-
],
519-
'factories' => [
520-
AdapterInterface::class => AdapterServiceFactory::class,
521-
DriverInterface::class => Driver\Pdo\DriverFactory::class,
522-
Platform\Sqlite::class => InvokableFactory::class,
523-
Profiler::class => InvokableFactory::class,
524-
],
525-
]]]></code>
526-
</MixedPropertyTypeCoercion>
527-
<UndefinedClass>
528-
<code><![CDATA[AdapterServiceFactory]]></code>
529-
<code><![CDATA[Driver\Pdo\DriverFactory]]></code>
530-
</UndefinedClass>
531-
</file>
532445
<file src="test/unit/Platform/SqliteTest.php">
533-
<InvalidArgument>
534-
<code><![CDATA[function ($errno, $errstr) use (&$raisedNotice) {
535-
$this->assertEquals(E_USER_NOTICE, $errno);
536-
$this->assertEquals(
537-
$errstr,
538-
'Attempting to quote a value in PhpDb\Adapter\Sqlite\Platform\Sqlite without extension/driver support can '
539-
. 'introduce security vulnerabilities in a production environment'
540-
);
541-
$raisedNotice = true;
542-
}]]></code>
543-
<code><![CDATA[function ($errno, $errstr) use (&$raisedNotice) {
544-
$this->assertEquals(E_USER_NOTICE, $errno);
545-
$this->assertEquals(
546-
$errstr,
547-
'Attempting to quote a value in PhpDb\Adapter\Sqlite\Platform\Sqlite without extension/driver support can '
548-
. 'introduce security vulnerabilities in a production environment'
549-
);
550-
$raisedNotice = true;
551-
}]]></code>
552-
</InvalidArgument>
446+
<InvalidArgument/>
553447
<MixedAssignment>
554448
<code><![CDATA[$driver]]></code>
555449
</MixedAssignment>

src/ConfigProvider.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
use Laminas\ServiceManager\Factory\InvokableFactory;
88
use PhpDb\Adapter\AdapterInterface;
99
use PhpDb\Adapter\Driver\ConnectionInterface;
10-
use PhpDb\Adapter\Driver\PdoConnectionInterface;
1110
use PhpDb\Adapter\Driver\DriverInterface;
11+
use PhpDb\Adapter\Driver\Pdo\Result;
12+
use PhpDb\Adapter\Driver\Pdo\Statement;
13+
use PhpDb\Adapter\Driver\PdoConnectionInterface;
1214
use PhpDb\Adapter\Driver\PdoDriverInterface;
1315
use PhpDb\Adapter\Driver\ResultInterface;
1416
use PhpDb\Adapter\Driver\StatementInterface;
15-
use PhpDb\Adapter\Driver\Pdo\Result;
16-
use PhpDb\Adapter\Driver\Pdo\Statement;
1717
use PhpDb\Adapter\Platform\PlatformInterface;
1818
use PhpDb\Adapter\Profiler\Profiler;
1919
use PhpDb\Adapter\Profiler\ProfilerInterface;
@@ -34,10 +34,10 @@ public function __invoke(): array
3434
public function getDependencies(): array
3535
{
3636
return [
37-
'aliases' => [
37+
'aliases' => [
3838
MetadataInterface::class => Metadata\Source\SqliteMetadata::class,
3939
],
40-
'factories' => [
40+
'factories' => [
4141
Metadata\Source\SqliteMetadata::class => Container\MetadataInterfaceFactory::class,
4242
],
4343
'delegators' => [

src/Container/AdapterFactory.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,3 @@ public function __invoke(ContainerInterface $container): AdapterInterface
8181
);
8282
}
8383
}
84-

src/Container/MetadataInterfaceFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
namespace PhpDb\Adapter\Sqlite\Container;
66

77
use PhpDb\Adapter\AdapterInterface;
8-
use PhpDb\Adapter\Sqlite\Metadata\Source\SqliteMetadata;
98
use PhpDb\Adapter\SchemaAwareInterface;
9+
use PhpDb\Adapter\Sqlite\Metadata\Source\SqliteMetadata;
1010
use PhpDb\Metadata\MetadataInterface;
1111
use Psr\Container\ContainerInterface;
1212

src/Container/PdoDriverFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
use PhpDb\Adapter\Driver\PdoDriverInterface;
1111
use PhpDb\Adapter\Driver\ResultInterface;
1212
use PhpDb\Adapter\Driver\StatementInterface;
13-
use PhpDb\Adapter\Sqlite\Driver\Pdo\Feature\SqliteRowCounter;
1413
use PhpDb\Adapter\Sqlite\Driver\Pdo\Connection;
14+
use PhpDb\Adapter\Sqlite\Driver\Pdo\Feature\SqliteRowCounter;
1515
use PhpDb\Adapter\Sqlite\Driver\Pdo\Pdo as PdoDriver;
1616
use PhpDb\Container\AdapterManager;
1717
use Psr\Container\ContainerInterface;

src/Container/PdoStatementFactory.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
use PhpDb\Adapter\Driver\Pdo\Statement;
88
use PhpDb\Adapter\Driver\StatementInterface;
9-
use PhpDb\Adapter\ParameterContainer;
109
use Psr\Container\ContainerInterface;
1110

1211
final class PdoStatementFactory

src/Container/PlatformInterfaceFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
use PDO;
88
use PhpDb\Adapter\Driver\PdoDriverInterface;
9-
use PhpDb\Adapter\Sqlite\Platform\Sqlite;
109
use PhpDb\Adapter\Platform\PlatformInterface;
10+
use PhpDb\Adapter\Sqlite\Platform\Sqlite;
1111
use PhpDb\Container\AdapterManager;
1212
use Psr\Container\ContainerInterface;
1313

src/Driver/Pdo/Connection.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
namespace PhpDb\Adapter\Sqlite\Driver\Pdo;
66

77
use Override;
8+
use PDO;
89
use PDOException;
910
use PhpDb\Adapter\Driver\ConnectionInterface;
1011
use PhpDb\Adapter\Driver\Pdo\AbstractPdoConnection;
1112
use PhpDb\Adapter\Exception;
1213
use Webmozart\Assert\Assert;
1314

1415
use function array_diff_key;
16+
use function assert;
1517
use function is_int;
1618
use function is_string;
1719
use function str_starts_with;
@@ -94,9 +96,11 @@ public function connect(): ConnectionInterface
9496
$this->dsn = $dsn;
9597

9698
try {
97-
$this->resource = new \PDO(dsn: $dsn, options: $options);
98-
$this->resource->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
99-
$this->driverName = strtolower($this->resource->getAttribute(\PDO::ATTR_DRIVER_NAME));
99+
$this->resource = new PDO(dsn: $dsn, options: $options);
100+
$this->resource->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
101+
$driverName = $this->resource->getAttribute(PDO::ATTR_DRIVER_NAME);
102+
assert(is_string($driverName));
103+
$this->driverName = strtolower($driverName);
100104
} catch (PDOException $e) {
101105
$code = $e->getCode();
102106
if (! is_int($code)) {

src/Driver/Pdo/Pdo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use PhpDb\Adapter\Driver\ResultInterface;
1414
use PhpDb\Adapter\Sqlite\Driver\DatabasePlatformNameTrait;
1515

16-
final class Pdo extends AbstractPdo implements DriverFeatureProviderInterface
16+
class Pdo extends AbstractPdo implements DriverFeatureProviderInterface
1717
{
1818
use DatabasePlatformNameTrait;
1919
use DriverFeatureProviderTrait;

src/Metadata/Source/SqliteMetadata.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ protected function loadConstraintData(string $table, string $schema): void
171171
$id = $name = null;
172172
foreach ($foreignKeys as $fk) {
173173
if ($id !== $fk['id']) {
174-
$id = $fk['id'];
174+
$id = $fk['id'];
175175
// todo: decide on whether to continue to use _laminas_
176176
$name = '_laminas_' . $table . '_FOREIGN_KEY_' . ($id + 1);
177177
$constraints[$name] = [

0 commit comments

Comments
 (0)