From 1b974d368c3aa0edc0672aac32f94b0eb02ba96f Mon Sep 17 00:00:00 2001 From: David Grudl Date: Thu, 19 Mar 2020 15:09:44 +0100 Subject: [PATCH] renamed IConventions -> Conventions --- src/Database/{IConventions.php => Conventions.php} | 5 ++++- src/Database/Conventions/DiscoveredConventions.php | 4 ++-- src/Database/Conventions/StaticConventions.php | 4 ++-- src/Database/Explorer.php | 8 ++++---- src/Database/Table/GroupedSelection.php | 4 ++-- src/Database/Table/Selection.php | 6 +++--- src/Database/Table/SqlBuilder.php | 4 ++-- src/compatibility-intf.php | 5 +++++ tests/Database.DI/DatabaseExtension.multiple.phpt | 2 +- 9 files changed, 25 insertions(+), 17 deletions(-) rename src/Database/{IConventions.php => Conventions.php} (94%) diff --git a/src/Database/IConventions.php b/src/Database/Conventions.php similarity index 94% rename from src/Database/IConventions.php rename to src/Database/Conventions.php index 4a9ef385c..19ab567af 100644 --- a/src/Database/IConventions.php +++ b/src/Database/Conventions.php @@ -12,7 +12,7 @@ use Nette\Database\Conventions\AmbiguousReferenceKeyException; -interface IConventions +interface Conventions { /** * Returns primary key for table. @@ -40,3 +40,6 @@ function getHasManyReference(string $table, string $key): ?array; */ function getBelongsToReference(string $table, string $key): ?array; } + + +interface_exists(IConventions::class); diff --git a/src/Database/Conventions/DiscoveredConventions.php b/src/Database/Conventions/DiscoveredConventions.php index b7e82a061..933731db9 100644 --- a/src/Database/Conventions/DiscoveredConventions.php +++ b/src/Database/Conventions/DiscoveredConventions.php @@ -9,14 +9,14 @@ namespace Nette\Database\Conventions; -use Nette\Database\IConventions; +use Nette\Database\Conventions; use Nette\Database\IStructure; /** * Conventions based on database structure. */ -class DiscoveredConventions implements IConventions +class DiscoveredConventions implements Conventions { /** @var IStructure */ protected $structure; diff --git a/src/Database/Conventions/StaticConventions.php b/src/Database/Conventions/StaticConventions.php index 4610021f0..2581039b6 100644 --- a/src/Database/Conventions/StaticConventions.php +++ b/src/Database/Conventions/StaticConventions.php @@ -10,13 +10,13 @@ namespace Nette\Database\Conventions; use Nette; -use Nette\Database\IConventions; +use Nette\Database\Conventions; /** * Conventions based on static definition. */ -class StaticConventions implements IConventions +class StaticConventions implements Conventions { use Nette\SmartObject; diff --git a/src/Database/Explorer.php b/src/Database/Explorer.php index f38baba7a..3a56d0d98 100644 --- a/src/Database/Explorer.php +++ b/src/Database/Explorer.php @@ -26,7 +26,7 @@ class Explorer /** @var IStructure */ private $structure; - /** @var IConventions */ + /** @var Conventions */ private $conventions; /** @var Nette\Caching\IStorage */ @@ -35,8 +35,8 @@ class Explorer public function __construct( Connection $connection, - IStructure $structure, - IConventions $conventions = null, + Structure $structure, + Conventions $conventions = null, Nette\Caching\IStorage $cacheStorage = null ) { $this->connection = $connection; @@ -112,7 +112,7 @@ public function getStructure(): IStructure } - public function getConventions(): IConventions + public function getConventions(): Conventions { return $this->conventions; } diff --git a/src/Database/Table/GroupedSelection.php b/src/Database/Table/GroupedSelection.php index 27ce42a86..8ef9c77f2 100644 --- a/src/Database/Table/GroupedSelection.php +++ b/src/Database/Table/GroupedSelection.php @@ -10,8 +10,8 @@ namespace Nette\Database\Table; use Nette; +use Nette\Database\Conventions; use Nette\Database\Explorer; -use Nette\Database\IConventions; /** @@ -38,7 +38,7 @@ class GroupedSelection extends Selection */ public function __construct( Explorer $explorer, - IConventions $conventions, + Conventions $conventions, string $tableName, string $column, Selection $refTable, diff --git a/src/Database/Table/Selection.php b/src/Database/Table/Selection.php index ec29a38cd..c6a67128c 100644 --- a/src/Database/Table/Selection.php +++ b/src/Database/Table/Selection.php @@ -10,8 +10,8 @@ namespace Nette\Database\Table; use Nette; +use Nette\Database\Conventions; use Nette\Database\Explorer; -use Nette\Database\IConventions; /** @@ -28,7 +28,7 @@ class Selection implements \Iterator, IRowContainer, \ArrayAccess, \Countable /** @var Explorer back compatibility */ protected $context; - /** @var IConventions */ + /** @var Conventions */ protected $conventions; /** @var Nette\Caching\Cache */ @@ -88,7 +88,7 @@ class Selection implements \Iterator, IRowContainer, \ArrayAccess, \Countable */ public function __construct( Explorer $explorer, - IConventions $conventions, + Conventions $conventions, string $tableName, Nette\Caching\IStorage $cacheStorage = null ) { diff --git a/src/Database/Table/SqlBuilder.php b/src/Database/Table/SqlBuilder.php index b837480e1..03ab12e1d 100644 --- a/src/Database/Table/SqlBuilder.php +++ b/src/Database/Table/SqlBuilder.php @@ -10,9 +10,9 @@ namespace Nette\Database\Table; use Nette; +use Nette\Database\Conventions; use Nette\Database\Driver; use Nette\Database\Explorer; -use Nette\Database\IConventions; use Nette\Database\IStructure; use Nette\Database\SqlLiteral; @@ -28,7 +28,7 @@ class SqlBuilder /** @var string */ protected $tableName; - /** @var IConventions */ + /** @var Conventions */ protected $conventions; /** @var string delimited table name */ diff --git a/src/compatibility-intf.php b/src/compatibility-intf.php index 55a530f19..57b0c4e74 100644 --- a/src/compatibility-intf.php +++ b/src/compatibility-intf.php @@ -14,6 +14,11 @@ interface ISupplementalDriver { } + /** @deprecated use Nette\Database\Conventions */ + interface IConventions + { + } } elseif (!interface_exists(ISupplementalDriver::class)) { class_alias(Driver::class, ISupplementalDriver::class); + class_alias(Conventions::class, IConventions::class); } diff --git a/tests/Database.DI/DatabaseExtension.multiple.phpt b/tests/Database.DI/DatabaseExtension.multiple.phpt index 7636e2f4b..42b8f52d4 100644 --- a/tests/Database.DI/DatabaseExtension.multiple.phpt +++ b/tests/Database.DI/DatabaseExtension.multiple.phpt @@ -58,7 +58,7 @@ test('', function () { Assert::type(Nette\Database\Structure::class, $explorer->getStructure()); Assert::same($explorer->getStructure(), $container->getByType(Nette\Database\IStructure::class)); Assert::type(Nette\Database\Conventions\DiscoveredConventions::class, $explorer->getConventions()); - Assert::same($explorer->getConventions(), $container->getByType(Nette\Database\IConventions::class)); + Assert::same($explorer->getConventions(), $container->getByType(Nette\Database\Conventions::class)); // aliases Assert::same($connection, $container->getService('nette.database.first'));