From ea2cb3b41825eef3dc0890dd798a5f9184de6db2 Mon Sep 17 00:00:00 2001 From: Victor GREBOT Date: Tue, 13 Jan 2026 17:09:18 +0100 Subject: [PATCH] feature: remove construct from interfaces For better SOLID patterns compliance (Liskov) --- CHANGELOG | 3 +++ src/Ting/ConnectionPoolInterface.php | 5 ----- src/Ting/Driver/StatementInterface.php | 8 -------- src/Ting/Query/QueryInterface.php | 7 ------- tests/units/Ting/Repository/Metadata.php | 6 +++--- 5 files changed, 6 insertions(+), 23 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ba782e02..ebd74c0a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +4.0.0-rc.2 (unreleased): + * Remove constructors from Interfaces (Liskov Substitution Principle violation) + 4.0.0-rc.1 (2025-12-15): * BC PHP 8.0 dropped, minimum version is now PHP 8.1 * BC All classes now fully typehinted with strict types and return types diff --git a/src/Ting/ConnectionPoolInterface.php b/src/Ting/ConnectionPoolInterface.php index d50e3608..bfc20a5c 100644 --- a/src/Ting/ConnectionPoolInterface.php +++ b/src/Ting/ConnectionPoolInterface.php @@ -30,11 +30,6 @@ interface ConnectionPoolInterface { - /** - * @param DriverLoggerInterface $logger - */ - public function __construct(DriverLoggerInterface $logger); - public function setConfig(array $config): void; /** diff --git a/src/Ting/Driver/StatementInterface.php b/src/Ting/Driver/StatementInterface.php index 87fb085d..babe7746 100644 --- a/src/Ting/Driver/StatementInterface.php +++ b/src/Ting/Driver/StatementInterface.php @@ -31,14 +31,6 @@ interface StatementInterface { - /** - * @param mysqli_stmt|Object $driverStatement - * @param array $paramsOrder - * @param string $connectionName - * @param string $database - */ - public function __construct($driverStatement, array $paramsOrder, string $connectionName, string $database); - /** * @param array $params * @throws QueryException diff --git a/src/Ting/Query/QueryInterface.php b/src/Ting/Query/QueryInterface.php index 3f50d702..e676c798 100644 --- a/src/Ting/Query/QueryInterface.php +++ b/src/Ting/Query/QueryInterface.php @@ -34,13 +34,6 @@ */ interface QueryInterface { - /** - * @param string $sql - * @param Connection $connection - * @param CollectionFactoryInterface $collectionFactory - */ - public function __construct($sql, Connection $connection, ?CollectionFactoryInterface $collectionFactory = null); - /** * Execute a reading query (SELECT, SHOW, etc.) * @param CollectionInterface|null $collection diff --git a/tests/units/Ting/Repository/Metadata.php b/tests/units/Ting/Repository/Metadata.php index b010f621..e7f78978 100644 --- a/tests/units/Ting/Repository/Metadata.php +++ b/tests/units/Ting/Repository/Metadata.php @@ -693,7 +693,7 @@ public function testGenerateQueryForInsertShouldReturnAPreparedQuery() $mockConnection = new \mock\CCMBenchmark\Ting\Connection($mockConnectionPool, 'main', 'db'); $mockDriver = new \mock\tests\fixtures\FakeDriver\Driver(); - $mockStatement = new \mock\CCMBenchmark\Ting\Driver\StatementInterface(new \stdClass(), [], '', ''); + $mockStatement = new \mock\CCMBenchmark\Ting\Driver\StatementInterface(); $this->calling($mockDriver)->prepare = $mockStatement; $this->calling($mockDriver)->execute = true; $this->calling($mockStatement)->execute = true; @@ -960,7 +960,7 @@ public function testGenerateQueryForUpdateShouldReturnAPreparedQuery() { $mockConnectionPool = new \mock\CCMBenchmark\Ting\ConnectionPool(); $mockDriver = new \mock\tests\fixtures\FakeDriver\Driver(); - $mockStatement = new \mock\CCMBenchmark\Ting\Driver\StatementInterface(new \stdClass(), [], '', ''); + $mockStatement = new \mock\CCMBenchmark\Ting\Driver\StatementInterface(); $this->calling($mockDriver)->prepare = $mockStatement; $this->calling($mockDriver)->execute = true; $this->calling($mockStatement)->execute = true; @@ -1018,7 +1018,7 @@ public function testGenerateQueryForDeleteShouldReturnAPreparedQuery() { $mockConnectionPool = new \mock\CCMBenchmark\Ting\ConnectionPool(); $mockDriver = new \mock\tests\fixtures\FakeDriver\Driver(); - $mockStatement = new \mock\CCMBenchmark\Ting\Driver\StatementInterface(new \stdClass(), [], '', ''); + $mockStatement = new \mock\CCMBenchmark\Ting\Driver\StatementInterface(); $this->calling($mockDriver)->prepare = $mockStatement; $this->calling($mockDriver)->execute = true; $this->calling($mockStatement)->execute = true;