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: 5 additions & 3 deletions src/Sql/Sql.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

use PhpDb\Adapter\AdapterInterface;
use PhpDb\Adapter\Driver\StatementInterface;
use PhpDb\Sql\Platform\PlatformDecoratorInterface;
use PhpDb\Sql\SqlInterface;

use function sprintf;

Expand All @@ -15,15 +17,15 @@

protected TableIdentifier|string|array|null $table;

protected Platform\Platform $sqlPlatform;
protected PlatformDecoratorInterface|PreparableSqlInterface $sqlPlatform;

public function __construct(
AdapterInterface $adapter,
array|string|TableIdentifier|null $table = null
) {
$this->adapter = $adapter;
$this->table = $table;
$this->sqlPlatform = new Platform\Platform($adapter->getPlatform());
$this->sqlPlatform = $this->adapter->getPlatform()->getSqlPlatformDecorator();
}

public function getAdapter(): ?AdapterInterface
Expand Down Expand Up @@ -51,7 +53,7 @@
return $this->table;
}

public function getSqlPlatform(): ?Platform\Platform
public function getSqlPlatform(): ?PlatformDecoratorInterface
{
return $this->sqlPlatform;
}
Expand Down Expand Up @@ -112,7 +114,7 @@
$adapter ??= $this->adapter;
$statement ??= $adapter->getDriver()->createStatement();

$this->sqlPlatform->setSubject($sqlObject)->prepareStatement($adapter, $statement);

Check failure on line 117 in src/Sql/Sql.php

View workflow job for this annotation

GitHub Actions / QA Checks (PhpStan [8.2, latest], ubuntu-latest, laminas/laminas-continuous-integration-action@v1...

Call to an undefined method PhpDb\Sql\Platform\PlatformDecoratorInterface::prepareStatement().

Check failure on line 117 in src/Sql/Sql.php

View workflow job for this annotation

GitHub Actions / QA Checks (PHPStan [8.2, locked], ubuntu-latest, laminas/laminas-continuous-integration-action@v1...

Call to an undefined method PhpDb\Sql\Platform\PlatformDecoratorInterface::prepareStatement().

return $statement;
}
Expand All @@ -122,10 +124,10 @@
*/
public function buildSqlString(SqlInterface $sqlObject, ?AdapterInterface $adapter = null): string
{
return $this

Check failure on line 127 in src/Sql/Sql.php

View workflow job for this annotation

GitHub Actions / QA Checks (PHPStan [8.2, locked], ubuntu-latest, laminas/laminas-continuous-integration-action@v1...

Call to an undefined method PhpDb\Sql\Platform\PlatformDecoratorInterface::getSqlString().
->sqlPlatform
->setSubject($sqlObject)
->getSqlString(

Check failure on line 130 in src/Sql/Sql.php

View workflow job for this annotation

GitHub Actions / QA Checks (PhpStan [8.2, latest], ubuntu-latest, laminas/laminas-continuous-integration-action@v1...

Call to an undefined method PhpDb\Sql\Platform\PlatformDecoratorInterface::getSqlString().
$adapter instanceof AdapterInterface ? $adapter->getPlatform() : $this->adapter->getPlatform()
);
}
Expand Down
8 changes: 7 additions & 1 deletion test/unit/RowGateway/AbstractRowGatewayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
use PhpDb\RowGateway\Exception\RuntimeException;
use PhpDb\RowGateway\Feature\FeatureSet;
use PhpDb\RowGateway\RowGateway;
use PhpDb\Sql\Platform\PlatformDecoratorInterface;
use PhpDb\Sql\PreparableSqlInterface;
use PhpDb\Sql\Select;
use PhpDb\Sql\Sql;
use PHPUnit\Framework\Attributes\CoversMethod;
Expand Down Expand Up @@ -72,12 +74,16 @@ protected function setUp(): void
$mockDriver->expects($this->any())->method('createStatement')->willReturn($mockStatement);
$mockDriver->expects($this->any())->method('getConnection')->willReturn($mockConnection);

$mockPlatform = $this->createStubForIntersectionOfInterfaces(
[PlatformInterface::class, PlatformDecoratorInterface::class, PreparableSqlInterface::class]
);

$this->mockAdapter = $this->getMockBuilder(Adapter::class)
->onlyMethods([])
->setConstructorArgs(
[
$mockDriver,
$this->getMockBuilder(PlatformInterface::class)->getMock(),
$mockPlatform,
]
)->getMock();

Expand Down
8 changes: 7 additions & 1 deletion test/unit/RowGateway/RowGatewayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
use PhpDb\RowGateway\Exception\InvalidArgumentException;
use PhpDb\RowGateway\Exception\RuntimeException;
use PhpDb\RowGateway\RowGateway;
use PhpDb\Sql\Platform\PlatformDecoratorInterface;
use PhpDb\Sql\PreparableSqlInterface;
use PhpDb\Sql\Sql;
use PhpDb\Sql\TableIdentifier;
use PHPUnit\Framework\MockObject\MockObject;
Expand Down Expand Up @@ -46,12 +48,16 @@ protected function setUp(): void
$mockDriver->expects($this->any())->method('createStatement')->willReturn($mockStatement);
$mockDriver->expects($this->any())->method('getConnection')->willReturn($mockConnection);

$mockPlatform = $this->createStubForIntersectionOfInterfaces(
[PlatformInterface::class, PlatformDecoratorInterface::class, PreparableSqlInterface::class]
);

$this->mockAdapter = $this->getMockBuilder(Adapter::class)
->onlyMethods([])
->setConstructorArgs(
[
$mockDriver,
$this->getMockBuilder(PlatformInterface::class)->getMock(),
$mockPlatform,
]
)->getMock();
}
Expand Down
7 changes: 6 additions & 1 deletion test/unit/TableGateway/AbstractTableGatewayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
use PhpDb\Sql;
use PhpDb\Sql\Delete;
use PhpDb\Sql\Insert;
use PhpDb\Sql\Platform\PlatformDecoratorInterface;
use PhpDb\Sql\PreparableSqlInterface;
use PhpDb\Sql\Select;
use PhpDb\Sql\Update;
use PhpDb\TableGateway\AbstractTableGateway;
Expand Down Expand Up @@ -78,7 +80,10 @@ protected function setUp(): void
$mockResult = $this->getMockBuilder(ResultInterface::class)->getMock();
$mockResult->expects($this->any())->method('getAffectedRows')->willReturn(5);

$mockPlatform = $this->getMockBuilder(PlatformInterface::class)->getMock();
//$mockPlatform = $this->getMockBuilder(PlatformInterface::class)->getMock();
$mockPlatform = $this->createStubForIntersectionOfInterfaces(
[PlatformInterface::class, PlatformDecoratorInterface::class, PreparableSqlInterface::class]
);

$mockResultSet = $this->getMockBuilder(ResultSetInterface::class)->getMock();

Expand Down
Loading