Skip to content

Commit 530a55e

Browse files
committed
Fix phpcs violations: alignment, FQCN imports, unused imports
1 parent cf1f623 commit 530a55e

7 files changed

Lines changed: 39 additions & 29 deletions

File tree

test/unit/Adapter/Container/AbstractAdapterInterfaceFactoryTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,15 +173,15 @@ public function testInvokeUsesResultSetFromContainer(): void
173173
$profiler = $this->createMock(ProfilerInterface::class);
174174

175175
/** @var PdoDriverInterface&MockObject $driverMock */
176-
$driverMock = $this->createMock(PdoDriverInterface::class);
176+
$driverMock = $this->createMock(PdoDriverInterface::class);
177177
/** @var PlatformInterface&MockObject $platformMock */
178178
$platformMock = $this->createMock(PlatformInterface::class);
179179

180180
$container = new ServiceManager([
181181
'abstract_factories' => [AbstractAdapterInterfaceFactory::class],
182182
'factories' => [
183-
PdoStubDriver::class => static fn() => $driverMock,
184-
PlatformInterface::class => static fn() => $platformMock,
183+
PdoStubDriver::class => static fn() => $driverMock,
184+
PlatformInterface::class => static fn() => $platformMock,
185185
ResultSetInterface::class => static fn() => $resultSet,
186186
ProfilerInterface::class => static fn() => $profiler,
187187
],

test/unit/Adapter/ParameterContainerTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,6 @@ public function testOffsetSetThrowsOnInvalidKeyType(): void
312312
$this->expectException(InvalidArgumentException::class);
313313
$this->expectExceptionMessage('Keys must be string, integer or null');
314314

315-
/** @phpstan-ignore argument.type */
316315
$container->offsetSet(1.5, 'value');
317316
}
318317

test/unit/ResultSet/AbstractResultSetTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
use PhpDb\Adapter\Driver\Pdo\Result;
1515
use PhpDb\Adapter\Driver\ResultInterface;
1616
use PhpDb\ResultSet\AbstractResultSet;
17-
use PhpDb\ResultSet\Exception\InvalidArgumentException;
1817
use PhpDb\ResultSet\Exception\RuntimeException;
1918
use PHPUnit\Framework\Attributes\CoversMethod;
2019
use PHPUnit\Framework\Attributes\Group;
2120
use PHPUnit\Framework\MockObject\MockObject;
2221
use PHPUnit\Framework\TestCase;
22+
use stdClass;
2323
use TypeError;
2424

2525
use function assert;
@@ -584,7 +584,7 @@ public function testCountReturnsCachedResult(): void
584584
public function testToArrayThrowsOnNonCastableRows(): void
585585
{
586586
$resultSet = $this->createResultSetMock();
587-
$resultSet->initialize(new ArrayIterator([new \stdClass()]));
587+
$resultSet->initialize(new ArrayIterator([new stdClass()]));
588588

589589
$this->expectException(RuntimeException::class);
590590
$this->expectExceptionMessage('cannot be cast to an array');

test/unit/ResultSet/HydratingResultSetTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Laminas\Hydrator\ArraySerializableHydrator;
1111
use Laminas\Hydrator\ClassMethodsHydrator;
1212
use Override;
13+
use PhpDb\ResultSet\Exception\RuntimeException;
1314
use PhpDb\ResultSet\HydratingResultSet;
1415
use PHPUnit\Framework\Attributes\CoversMethod;
1516
use PHPUnit\Framework\Attributes\Group;
@@ -204,13 +205,13 @@ public function testToArrayUsesHydratorExtract(): void
204205
public function testCurrentDisablesBufferingImplicitly(): void
205206
{
206207
$hydratingRs = new HydratingResultSet();
207-
$hydratingRs->initialize(new \ArrayIterator([
208+
$hydratingRs->initialize(new ArrayIterator([
208209
['id' => 1],
209210
]));
210211

211212
$hydratingRs->current();
212213

213-
$this->expectException(\PhpDb\ResultSet\Exception\RuntimeException::class);
214+
$this->expectException(RuntimeException::class);
214215
$hydratingRs->buffer();
215216
}
216217
}

test/unit/Sql/AbstractSqlTest.php

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,25 @@
55
namespace PhpDbTest\Sql;
66

77
use Override;
8+
use PhpDb\Adapter\Adapter;
89
use PhpDb\Adapter\Driver\DriverInterface;
10+
use PhpDb\Adapter\Driver\StatementInterface;
911
use PhpDb\Adapter\ParameterContainer;
1012
use PhpDb\Adapter\StatementContainer;
1113
use PhpDb\Sql\AbstractSql;
1214
use PhpDb\Sql\Argument;
1315
use PhpDb\Sql\Argument\Identifier;
16+
use PhpDb\Sql\ArgumentInterface;
17+
use PhpDb\Sql\ArgumentType;
18+
use PhpDb\Sql\Exception\InvalidArgumentException;
1419
use PhpDb\Sql\Exception\RuntimeException;
1520
use PhpDb\Sql\Expression;
1621
use PhpDb\Sql\ExpressionInterface;
22+
use PhpDb\Sql\Join;
1723
use PhpDb\Sql\Predicate;
1824
use PhpDb\Sql\Select;
1925
use PhpDb\Sql\TableIdentifier;
26+
use PhpDbTest\TestAsset\SelectDecorator;
2027
use PhpDbTest\TestAsset\TrustingSql92Platform;
2128
use PHPUnit\Framework\Attributes\CoversMethod;
2229
use PHPUnit\Framework\Attributes\Group;
@@ -435,7 +442,7 @@ protected function invokeProcessExpressionMethod(
435442
*/
436443
public function testProcessJoinWithArrayAlias(): void
437444
{
438-
$join = new \PhpDb\Sql\Join();
445+
$join = new Join();
439446
$join->join(['b' => 'bar'], 'foo.id = b.foo_id');
440447

441448
$method = new ReflectionMethod($this->abstractSql, 'processJoin');
@@ -456,8 +463,8 @@ public function testProcessJoinWithArrayAlias(): void
456463
*/
457464
public function testProcessJoinWithTableIdentifier(): void
458465
{
459-
$join = new \PhpDb\Sql\Join();
460-
$join->join(new \PhpDb\Sql\TableIdentifier('bar', 'myschema'), 'foo.id = bar.foo_id');
466+
$join = new Join();
467+
$join->join(new TableIdentifier('bar', 'myschema'), 'foo.id = bar.foo_id');
461468

462469
$method = new ReflectionMethod($this->abstractSql, 'processJoin');
463470
$result = $method->invoke(
@@ -478,7 +485,7 @@ public function testProcessJoinWithTableIdentifier(): void
478485
*/
479486
public function testProcessJoinWithPredicateExpressionOnClause(): void
480487
{
481-
$join = new \PhpDb\Sql\Join();
488+
$join = new Join();
482489
$join->join('bar', new Predicate\Expression('foo.id = bar.foo_id AND bar.active = 1'));
483490

484491
$method = new ReflectionMethod($this->abstractSql, 'processJoin');
@@ -527,7 +534,7 @@ public function testRenderTableWithAlias(): void
527534
*/
528535
public function testProcessJoinWithExpressionNameViaArray(): void
529536
{
530-
$join = new \PhpDb\Sql\Join();
537+
$join = new Join();
531538
$join->join(['x' => new Expression('LATERAL(SELECT 1)')], 'true');
532539

533540
$method = new ReflectionMethod($this->abstractSql, 'processJoin');
@@ -548,7 +555,7 @@ public function testProcessJoinWithExpressionNameViaArray(): void
548555
public function testProcessJoinWithSelectSubqueryViaArray(): void
549556
{
550557
$subselect = new Select('bar');
551-
$join = new \PhpDb\Sql\Join();
558+
$join = new Join();
552559
$join->join(['b' => $subselect], 'foo.id = b.foo_id');
553560

554561
$method = new ReflectionMethod($this->abstractSql, 'processJoin');
@@ -644,10 +651,10 @@ public function testCreateSqlFromSpecNonCombinedByThrowsOnUnsupportedCount(): vo
644651

645652
public function testProcessExpressionThrowsOnUnknownArgumentType(): void
646653
{
647-
$unknownArg = new class implements \PhpDb\Sql\ArgumentInterface {
648-
public function getType(): \PhpDb\Sql\ArgumentType
654+
$unknownArg = new class implements ArgumentInterface {
655+
public function getType(): ArgumentType
649656
{
650-
return \PhpDb\Sql\ArgumentType::Value;
657+
return ArgumentType::Value;
651658
}
652659

653660
public function getValue(): string
@@ -663,7 +670,7 @@ public function getSpecification(): string
663670

664671
$expression = new Expression('?', [$unknownArg]);
665672

666-
$this->expectException(\PhpDb\Sql\Exception\InvalidArgumentException::class);
673+
$this->expectException(InvalidArgumentException::class);
667674
$this->expectExceptionMessage('Unknown argument type');
668675
$this->invokeProcessExpressionMethod($expression);
669676
}
@@ -679,11 +686,11 @@ public function testResolveColumnValueWithNamedParameterPrefix(): void
679686
->willReturnCallback(fn(string $name): string => ':' . $name);
680687

681688
$parameterContainer = new ParameterContainer();
682-
$mockStatement = $this->createMock(\PhpDb\Adapter\Driver\StatementInterface::class);
689+
$mockStatement = $this->createMock(StatementInterface::class);
683690
$mockStatement->method('getParameterContainer')->willReturn($parameterContainer);
684691
$mockStatement->method('setSql')->willReturnSelf();
685692

686-
$adapter = $this->getMockBuilder(\PhpDb\Adapter\Adapter::class)
693+
$adapter = $this->getMockBuilder(Adapter::class)
687694
->setConstructorArgs([$mockDriver, new TrustingSql92Platform()])
688695
->getMock();
689696
$adapter->method('getDriver')->willReturn($mockDriver);
@@ -696,7 +703,7 @@ public function testResolveColumnValueWithNamedParameterPrefix(): void
696703

697704
public function testLocalizeVariablesCopiesSubjectProperties(): void
698705
{
699-
$decorator = new \PhpDbTest\TestAsset\SelectDecorator();
706+
$decorator = new SelectDecorator();
700707
$select = new Select('users');
701708
$select->columns(['id', 'name']);
702709
$decorator->setSubject($select);
@@ -709,7 +716,7 @@ public function testLocalizeVariablesCopiesSubjectProperties(): void
709716

710717
public function testProcessSubSelectUsesDecoratorWhenPlatformDecorator(): void
711718
{
712-
$decorator = new \PhpDbTest\TestAsset\SelectDecorator();
719+
$decorator = new SelectDecorator();
713720
$outer = new Select('foo');
714721
$outer->where(['x' => new Select('bar')]);
715722

@@ -741,10 +748,10 @@ public function testFlattenExpressionValuesViaInPredicateWithParameterContainer(
741748
->willReturnCallback(fn(string $name): string => ':' . $name);
742749

743750
$parameterContainer = new ParameterContainer();
744-
$mockStatement = $this->createMock(\PhpDb\Adapter\Driver\StatementInterface::class);
751+
$mockStatement = $this->createMock(StatementInterface::class);
745752
$mockStatement->method('getParameterContainer')->willReturn($parameterContainer);
746753

747-
$adapter = $this->getMockBuilder(\PhpDb\Adapter\Adapter::class)
754+
$adapter = $this->getMockBuilder(Adapter::class)
748755
->setConstructorArgs([$mockDriver, new TrustingSql92Platform()])
749756
->getMock();
750757
$adapter->method('getDriver')->willReturn($mockDriver);

test/unit/Sql/Platform/PlatformTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
use PhpDb\Adapter\StatementContainer;
1212
use PhpDb\ResultSet\ResultSet;
1313
use PhpDb\Sql\Exception\RuntimeException;
14+
use PhpDb\Sql\Insert;
15+
use PhpDb\Sql\Platform\AbstractPlatform;
1416
use PhpDb\Sql\Platform\Platform;
1517
use PhpDb\Sql\Platform\PlatformDecoratorInterface;
1618
use PhpDb\Sql\PreparableSqlInterface;
@@ -245,7 +247,7 @@ public function testGetTypeDecoratorFallsThroughWhenNoMatch(): void
245247
$platform = new Platform($adapterPlatform);
246248

247249
$decorator = $this->createMock(PlatformDecoratorInterface::class);
248-
$platform->setTypeDecorator(\PhpDb\Sql\Insert::class, $decorator);
250+
$platform->setTypeDecorator(Insert::class, $decorator);
249251

250252
$select = new Select('foo');
251253
$result = $platform->getTypeDecorator($select);
@@ -258,7 +260,7 @@ public function testGetTypeDecoratorMatchesByInstanceofLoop(): void
258260
$adapterPlatform = new TestAsset\TrustingSql92Platform();
259261
$platform = new Platform($adapterPlatform);
260262

261-
$innerPlatform = new \PhpDb\Sql\Platform\AbstractPlatform();
263+
$innerPlatform = new AbstractPlatform();
262264
$platform->setTypeDecorator(SqlInterface::class, $innerPlatform);
263265

264266
$select = new Select('foo');

test/unit/Sql/SqlTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@
1010
use PhpDb\Adapter\Driver\DriverInterface;
1111
use PhpDb\Adapter\Driver\ResultInterface;
1212
use PhpDb\Adapter\Driver\StatementInterface;
13+
use PhpDb\Adapter\Platform\PlatformInterface;
1314
use PhpDb\Sql\Delete;
1415
use PhpDb\Sql\Exception\InvalidArgumentException;
1516
use PhpDb\Sql\Exception\RuntimeException;
1617
use PhpDb\Sql\Insert;
17-
use PhpDb\Sql\Select;
1818
use PhpDb\Sql\Platform\PlatformDecoratorInterface;
19+
use PhpDb\Sql\Select;
1920
use PhpDb\Sql\Sql;
2021
use PhpDb\Sql\TableIdentifier;
2122
use PhpDb\Sql\Update;
@@ -206,7 +207,7 @@ public function testGetSqlPlatformReturnsPlatformDecorator(): void
206207
public function testPrepareStatementThrowsWhenPlatformNotPreparable(): void
207208
{
208209
$decorator = $this->createMock(PlatformDecoratorInterface::class);
209-
$platform = $this->createMock(\PhpDb\Adapter\Platform\PlatformInterface::class);
210+
$platform = $this->createMock(PlatformInterface::class);
210211
$platform->method('getSqlPlatformDecorator')->willReturn($decorator);
211212

212213
$adapter = $this->getMockBuilder(Adapter::class)
@@ -227,7 +228,7 @@ public function testPrepareStatementThrowsWhenPlatformNotPreparable(): void
227228
public function testBuildSqlStringThrowsWhenPlatformNotSqlInterface(): void
228229
{
229230
$decorator = $this->createMock(PlatformDecoratorInterface::class);
230-
$platform = $this->createMock(\PhpDb\Adapter\Platform\PlatformInterface::class);
231+
$platform = $this->createMock(PlatformInterface::class);
231232
$platform->method('getSqlPlatformDecorator')->willReturn($decorator);
232233

233234
$adapter = $this->getMockBuilder(Adapter::class)

0 commit comments

Comments
 (0)