From 7d5fa38e05efa3377328bdec588920429baa1e97 Mon Sep 17 00:00:00 2001 From: Spamer Date: Tue, 22 Aug 2023 23:33:45 +0200 Subject: [PATCH 01/37] =?UTF-8?q?=F0=9F=A7=99=E2=80=8D=E2=99=82=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Commands/AddAlias.php | 4 +++- src/Commands/CreateIndex.php | 4 +++- src/Commands/DeleteIndex.php | 4 +++- src/Commands/DumpIndex.php | 4 +++- src/Commands/InitializeIndexes.php | 4 +++- src/Commands/LoadDump.php | 4 +++- src/Commands/RemoveAlias.php | 4 +++- src/Commands/TypeToNewIndex.php | 4 +++- src/Model/AbstractBaseService.php | 2 +- src/Model/Insert.php | 2 ++ src/Model/Insert/PrepareEntityArray.php | 1 + tests/SpameriTests/Elastic/Data/Entity/Person.php | 2 +- tests/SpameriTests/Elastic/Data/Entity/Video.php | 2 +- 13 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/Commands/AddAlias.php b/src/Commands/AddAlias.php index 0e9773bd..c015ccf6 100644 --- a/src/Commands/AddAlias.php +++ b/src/Commands/AddAlias.php @@ -5,6 +5,8 @@ class AddAlias extends \Symfony\Component\Console\Command\Command { + protected static $defaultName = 'spameri:elastic:add-alias'; + private \Spameri\Elastic\Model\Indices\AddAlias $addAlias; @@ -20,7 +22,7 @@ public function __construct( protected function configure(): void { $this - ->setName('spameri:elastic:add-alias') + ->setName(self::$defaultName) ->setDescription('Adds alias to existing index.') ->addArgument('index', \Symfony\Component\Console\Input\InputArgument::REQUIRED) ->addArgument('alias', \Symfony\Component\Console\Input\InputArgument::REQUIRED) diff --git a/src/Commands/CreateIndex.php b/src/Commands/CreateIndex.php index 92f40c6e..8b4e4cf9 100644 --- a/src/Commands/CreateIndex.php +++ b/src/Commands/CreateIndex.php @@ -5,6 +5,8 @@ class CreateIndex extends \Symfony\Component\Console\Command\Command { + protected static $defaultName = 'spameri:elastic:create-index'; + private \Spameri\Elastic\Model\CreateIndex $createIndex; private \Spameri\Elastic\Model\DeleteIndex $deleteIndex; @@ -24,7 +26,7 @@ public function __construct( protected function configure(): void { $this - ->setName('spameri:elastic:create-index') + ->setName(self::$defaultName) ->setDescription( 'Creates index. Take string as is, adds timestamp and inserts it in Elastic. No mapping or settings.' ) diff --git a/src/Commands/DeleteIndex.php b/src/Commands/DeleteIndex.php index 18ce2faa..b433608a 100644 --- a/src/Commands/DeleteIndex.php +++ b/src/Commands/DeleteIndex.php @@ -5,6 +5,8 @@ class DeleteIndex extends \Symfony\Component\Console\Command\Command { + protected static $defaultName = 'spameri:elastic:delete-index'; + private \Spameri\Elastic\Model\Indices\Delete $delete; @@ -20,7 +22,7 @@ public function __construct( protected function configure(): void { $this - ->setName('spameri:elastic:delete-index') + ->setName(self::$defaultName) ->setDescription('Deletes index by name or alias. Warning this deletes your data!') ->addArgument('indexName', \Symfony\Component\Console\Input\InputArgument::IS_ARRAY) ; diff --git a/src/Commands/DumpIndex.php b/src/Commands/DumpIndex.php index 7dec382d..db41a674 100644 --- a/src/Commands/DumpIndex.php +++ b/src/Commands/DumpIndex.php @@ -5,6 +5,8 @@ class DumpIndex extends \Symfony\Component\Console\Command\Command { + protected static $defaultName = 'spameri:elastic:dump-index'; + private \Spameri\Elastic\Model\DumpIndex $dumpIndex; @@ -23,7 +25,7 @@ public function __construct( protected function configure(): void { $this - ->setName('spameri:elastic:dump-index') + ->setName(self::$defaultName) ->setDescription('Dumps all data from index to file') ->addArgument('index', \Symfony\Component\Console\Input\InputArgument::REQUIRED) ->addArgument('filename', \Symfony\Component\Console\Input\InputArgument::REQUIRED) diff --git a/src/Commands/InitializeIndexes.php b/src/Commands/InitializeIndexes.php index b491cb9a..dbd15384 100644 --- a/src/Commands/InitializeIndexes.php +++ b/src/Commands/InitializeIndexes.php @@ -5,6 +5,8 @@ class InitializeIndexes extends \Symfony\Component\Console\Command\Command { + protected static $defaultName = 'spameri:elastic:initialize-index'; + private \Spameri\Elastic\Model\DeleteIndex $deleteIndex; private \Spameri\Elastic\Model\InitializeIndex $initializeIndex; @@ -28,7 +30,7 @@ public function __construct( protected function configure(): void { $this - ->setName('spameri:elastic:initialize-index') + ->setName(self::$defaultName) ->setDescription( 'Creates index/es. And initializes with settings and mappings' ) diff --git a/src/Commands/LoadDump.php b/src/Commands/LoadDump.php index e02d39c5..49b9e25d 100644 --- a/src/Commands/LoadDump.php +++ b/src/Commands/LoadDump.php @@ -5,6 +5,8 @@ class LoadDump extends \Symfony\Component\Console\Command\Command { + protected static $defaultName = 'spameri:elastic:load-dump'; + private \Spameri\Elastic\Model\RestoreIndex $restoreIndex; @@ -23,7 +25,7 @@ public function __construct( protected function configure(): void { $this - ->setName('spameri:elastic:load-dump') + ->setName(self::$defaultName) ->setDescription('Loads data from provided dump file.') ->addArgument('filename', \Symfony\Component\Console\Input\InputArgument::REQUIRED) ->addArgument( diff --git a/src/Commands/RemoveAlias.php b/src/Commands/RemoveAlias.php index c155048c..853af4fc 100644 --- a/src/Commands/RemoveAlias.php +++ b/src/Commands/RemoveAlias.php @@ -5,6 +5,8 @@ class RemoveAlias extends \Symfony\Component\Console\Command\Command { + protected static $defaultName = 'spameri:elastic:remove-alias'; + private \Spameri\Elastic\Model\Indices\RemoveAlias $removeAlias; @@ -20,7 +22,7 @@ public function __construct( protected function configure(): void { $this - ->setName('spameri:elastic:remove-alias') + ->setName(self::$defaultName) ->setDescription('Adds alias to existing index.') ->addArgument('index', \Symfony\Component\Console\Input\InputArgument::REQUIRED) ->addArgument('alias', \Symfony\Component\Console\Input\InputArgument::REQUIRED) diff --git a/src/Commands/TypeToNewIndex.php b/src/Commands/TypeToNewIndex.php index e7fa655e..4dbeadb7 100644 --- a/src/Commands/TypeToNewIndex.php +++ b/src/Commands/TypeToNewIndex.php @@ -5,6 +5,8 @@ class TypeToNewIndex extends \Symfony\Component\Console\Command\Command { + protected static $defaultName = 'spameri:elastic:move-type'; + private \Spameri\Elastic\Model\TypeToNewIndex\Migrate $migrate; @@ -23,7 +25,7 @@ public function __construct( protected function configure(): void { $this - ->setName('spameri:elastic:move-type') + ->setName(self::$defaultName) ->setDescription('Move type to new index to separate data and prepare for deprecation of types is ES.') ->addArgument('indexFrom', \Symfony\Component\Console\Input\InputArgument::REQUIRED) ->addArgument('typeFrom', \Symfony\Component\Console\Input\InputArgument::REQUIRED) diff --git a/src/Model/AbstractBaseService.php b/src/Model/AbstractBaseService.php index b7a74972..7caa57a8 100644 --- a/src/Model/AbstractBaseService.php +++ b/src/Model/AbstractBaseService.php @@ -5,7 +5,7 @@ abstract class AbstractBaseService implements ServiceInterface { - protected string $index; + public string $index; protected \Spameri\Elastic\Model\Insert $insert; diff --git a/src/Model/Insert.php b/src/Model/Insert.php index 4163a785..5b8ea860 100644 --- a/src/Model/Insert.php +++ b/src/Model/Insert.php @@ -82,10 +82,12 @@ public function execute( } if (isset($response['created']) || isset($response['updated'])) { + $entity->id = new \Spameri\Elastic\Entity\Property\ElasticId($response['_id']); return $response['_id']; } if (isset($response['result']) && ($response['result'] === 'created' || $response['result'] === 'updated')) { + $entity->id = new \Spameri\Elastic\Entity\Property\ElasticId($response['_id']); return $response['_id']; } diff --git a/src/Model/Insert/PrepareEntityArray.php b/src/Model/Insert/PrepareEntityArray.php index 9ffcb3e8..0e6499f6 100644 --- a/src/Model/Insert/PrepareEntityArray.php +++ b/src/Model/Insert/PrepareEntityArray.php @@ -56,6 +56,7 @@ public function iterateVariables( foreach ($property as $item) { $preparedArray[$key][] = $this->iterateVariables($item->entityVariables()); } + // TODO kolekce bez klíčů } elseif ($property instanceof \Spameri\Elastic\Entity\ElasticEntityCollectionInterface) { $preparedArray[$key] = []; diff --git a/tests/SpameriTests/Elastic/Data/Entity/Person.php b/tests/SpameriTests/Elastic/Data/Entity/Person.php index cb0e5bcf..c9ddb7a0 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Person.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Person.php @@ -8,7 +8,7 @@ class Person implements \Spameri\Elastic\Entity\ElasticEntityInterface /** * @var \Spameri\Elastic\Entity\Property\ElasticIdInterface */ - private $id; + public $id; /** * @var \SpameriTests\Elastic\Data\Entity\Video\Identification diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video.php b/tests/SpameriTests/Elastic/Data/Entity/Video.php index b9635304..0630b63c 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video.php @@ -8,7 +8,7 @@ class Video implements \Spameri\Elastic\Entity\ElasticEntityInterface /** * @var \Spameri\Elastic\Entity\Property\ElasticIdInterface */ - private $id; + public $id; /** * @var \SpameriTests\Elastic\Data\Entity\Video\Identification From 0ef8d33f426ea9c7283089c455737f4a281c6b10 Mon Sep 17 00:00:00 2001 From: Spamer Date: Tue, 29 Aug 2023 22:18:15 +0200 Subject: [PATCH 02/37] =?UTF-8?q?Added=20ability=20to=20create=20cached=20?= =?UTF-8?q?entity=20collection=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AbstractCachedEntityCollection.php | 79 +++++++++++++++++++ .../Collection/AbstractEntityCollection.php | 2 +- 2 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 src/Entity/Collection/AbstractCachedEntityCollection.php diff --git a/src/Entity/Collection/AbstractCachedEntityCollection.php b/src/Entity/Collection/AbstractCachedEntityCollection.php new file mode 100644 index 00000000..d2fb19bd --- /dev/null +++ b/src/Entity/Collection/AbstractCachedEntityCollection.php @@ -0,0 +1,79 @@ +initialize(); + + return parent::entity($key); + } + + + public function remove( + string $key + ): void + { + $this->initialize(); + + parent::remove($key); + } + + + public function isValue( + string $key + ): bool + { + $this->initialize(); + + return parent::isValue($key); + } + + + public function count(): int + { + $this->initialize(); + + return parent::count(); + } + + + public function keys(): array + { + $this->initialize(); + + return parent::keys(); + } + + + public function isKey( + string $key + ): bool + { + $this->initialize(); + + return parent::isKey($key); + } + + + public function sort( + \Spameri\Elastic\Entity\Collection\SortField $sortField, // phpcs:ignore + string $type + ): void + { + $this->initialize(); + + parent::sort($sortField, $type); + } + +} diff --git a/src/Entity/Collection/AbstractEntityCollection.php b/src/Entity/Collection/AbstractEntityCollection.php index 2af991f3..8089c390 100644 --- a/src/Entity/Collection/AbstractEntityCollection.php +++ b/src/Entity/Collection/AbstractEntityCollection.php @@ -8,7 +8,7 @@ abstract class AbstractEntityCollection implements \Spameri\Elastic\Entity\Entit /** * @var array<\Spameri\Elastic\Entity\EntityInterface> */ - private $collection; + protected array $collection; public function __construct( From 80108b40291e802829bdd352a480a08cd6c13fee Mon Sep 17 00:00:00 2001 From: Spamer Date: Wed, 30 Aug 2023 17:26:42 +0200 Subject: [PATCH 03/37] Added strictly typed getvalue methods --- src/Factory/CollectionFactoryInterface.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Factory/CollectionFactoryInterface.php b/src/Factory/CollectionFactoryInterface.php index e9d08ed7..fe66d826 100644 --- a/src/Factory/CollectionFactoryInterface.php +++ b/src/Factory/CollectionFactoryInterface.php @@ -5,6 +5,10 @@ interface CollectionFactoryInterface { + /** + * @param array $elasticIds + * @return \Spameri\Elastic\Entity\ElasticEntityCollectionInterface<\Spameri\Elastic\Entity\ElasticEntityInterface> + */ public function create( \Spameri\Elastic\Model\ServiceInterface $service, array $elasticIds = [], From 3ece459253abbee808ceb25e8ddeba12c8f52232 Mon Sep 17 00:00:00 2001 From: Spamer Date: Sat, 2 Sep 2023 22:54:02 +0200 Subject: [PATCH 04/37] Added shortcut to createEmptyCollection from service elastic id has constant for its field --- src/Entity/Property/ElasticId.php | 3 +++ src/Model/AbstractBaseService.php | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/src/Entity/Property/ElasticId.php b/src/Entity/Property/ElasticId.php index 48503b66..418f63c9 100644 --- a/src/Entity/Property/ElasticId.php +++ b/src/Entity/Property/ElasticId.php @@ -5,6 +5,9 @@ class ElasticId implements \Spameri\Elastic\Entity\ValueInterface, \Spameri\Elastic\Entity\Property\ElasticIdInterface { + public const FIELD_NAME = '_id'; + + /** * @var string */ diff --git a/src/Model/AbstractBaseService.php b/src/Model/AbstractBaseService.php index 7caa57a8..7809b459 100644 --- a/src/Model/AbstractBaseService.php +++ b/src/Model/AbstractBaseService.php @@ -142,6 +142,12 @@ public function getAllBy( } + public function createEmptyCollection(): \Spameri\Elastic\Entity\ElasticEntityCollectionInterface + { + return $this->collectionFactory->create($this); + } + + public function delete( \Spameri\Elastic\Entity\Property\ElasticIdInterface $id ): bool From 94d8cd650539fcf4831fafc456f198987272509f Mon Sep 17 00:00:00 2001 From: Spamer Date: Wed, 6 Sep 2023 17:53:13 +0200 Subject: [PATCH 05/37] If you cant create entity just skip, dont crash --- src/Model/AbstractBaseService.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Model/AbstractBaseService.php b/src/Model/AbstractBaseService.php index 7809b459..9d519d39 100644 --- a/src/Model/AbstractBaseService.php +++ b/src/Model/AbstractBaseService.php @@ -131,7 +131,12 @@ public function getAllBy( $entities = []; foreach ($resultSearch->hits() as $hit) { - $entities[] = $this->entityFactory->create($hit)->current(); + try { + $entities[] = $this->entityFactory->create($hit)->current(); + + } catch (\Spameri\Elastic\Exception\ElasticSearch $exception) { + \Tracy\Debugger::log($exception->getMessage(), \Tracy\ILogger::CRITICAL); + } } return $this->collectionFactory->create( From 2d4a6cc337d47e2ee07c9efd32c33bf4aad81c72 Mon Sep 17 00:00:00 2001 From: Spamer Date: Thu, 14 Sep 2023 16:57:56 +0200 Subject: [PATCH 06/37] get first entity of collection --- .../Collection/AbstractElasticEntityCollection.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Entity/Collection/AbstractElasticEntityCollection.php b/src/Entity/Collection/AbstractElasticEntityCollection.php index 2f3f6d13..9d59b0ea 100644 --- a/src/Entity/Collection/AbstractElasticEntityCollection.php +++ b/src/Entity/Collection/AbstractElasticEntityCollection.php @@ -220,4 +220,14 @@ public function sort( throw new \Nette\NotImplementedException(); } + + public function first(): ?\Spameri\Elastic\Entity\ElasticEntityInterface + { + if ( ! $this->initialized) { + $this->initialize(); + } + + return \reset($this->collection) ?: NULL; + } + } From a73e696b4b54ea5112955ea0c696f6af0971b07a Mon Sep 17 00:00:00 2001 From: Spamer Date: Fri, 15 Sep 2023 10:21:51 +0200 Subject: [PATCH 07/37] Datetime has method for time ago wording --- src/Entity/Property/DateTime.php | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/Entity/Property/DateTime.php b/src/Entity/Property/DateTime.php index a4df11ab..f3a6299d 100644 --- a/src/Entity/Property/DateTime.php +++ b/src/Entity/Property/DateTime.php @@ -1,4 +1,4 @@ -format('U'); + + if ($timeDifference < 1) { + return 'less than 1 second ago'; + } + + $condition = [ + 12 * 30 * 24 * 60 * 60 => 'year', + 30 * 24 * 60 * 60 => 'month', + 24 * 60 * 60 => 'day', + 60 * 60 => 'hour', + 60 => 'minute', + 1 => 'second' + ]; + + foreach ($condition as $secs => $str) { + $d = $timeDifference / $secs; + + if ($d >= 1) { + $t = \round($d); + return $t . ' ' . $str . ($t > 1 ? 's' : '') . ' ago'; + } + } + + return 'some time ago'; + } + } From 7cf01cffa3e5fd814c8194bcfdcd6a2b59c76d87 Mon Sep 17 00:00:00 2001 From: Spamer Date: Sat, 16 Sep 2023 09:47:13 +0200 Subject: [PATCH 08/37] character service has delete cascade --- src/Model/AbstractBaseService.php | 75 +++++++++++++++---------------- 1 file changed, 35 insertions(+), 40 deletions(-) diff --git a/src/Model/AbstractBaseService.php b/src/Model/AbstractBaseService.php index 9d519d39..2d93b508 100644 --- a/src/Model/AbstractBaseService.php +++ b/src/Model/AbstractBaseService.php @@ -5,47 +5,18 @@ abstract class AbstractBaseService implements ServiceInterface { - public string $index; - - protected \Spameri\Elastic\Model\Insert $insert; - - protected \Spameri\Elastic\Model\Get $get; - - protected \Spameri\Elastic\Model\Delete $delete; - - protected \Spameri\Elastic\Model\GetBy $getBy; - - protected \Spameri\Elastic\Model\GetAllBy $getAllBy; - - protected \Spameri\Elastic\Factory\EntityFactoryInterface $entityFactory; - - protected \Spameri\Elastic\Factory\CollectionFactoryInterface $collectionFactory; - - protected \Spameri\Elastic\Model\Aggregate $aggregate; - - public function __construct( - string $index, - \Spameri\Elastic\Factory\EntityFactoryInterface $entityFactory, - \Spameri\Elastic\Factory\CollectionFactoryInterface $collectionFactory, - \Spameri\Elastic\Model\Insert $insert, - \Spameri\Elastic\Model\Get $get, - \Spameri\Elastic\Model\GetBy $getBy, - \Spameri\Elastic\Model\GetAllBy $getAllBy, - \Spameri\Elastic\Model\Delete $delete, - \Spameri\Elastic\Model\Aggregate $aggregate - ) - { - $this->index = $index; - $this->insert = $insert; - $this->get = $get; - $this->delete = $delete; - $this->getBy = $getBy; - $this->getAllBy = $getAllBy; - $this->entityFactory = $entityFactory; - $this->collectionFactory = $collectionFactory; - $this->aggregate = $aggregate; - } + public string $index, + protected readonly \Spameri\Elastic\Factory\EntityFactoryInterface $entityFactory, + protected readonly \Spameri\Elastic\Factory\CollectionFactoryInterface $collectionFactory, + protected readonly \Spameri\Elastic\Model\Insert $insert, + protected readonly \Spameri\Elastic\Model\Get $get, + protected readonly \Spameri\Elastic\Model\GetBy $getBy, + protected readonly \Spameri\Elastic\Model\GetAllBy $getAllBy, + protected readonly \Spameri\Elastic\Model\Delete $delete, + protected readonly \Spameri\Elastic\Model\Aggregate $aggregate, + protected readonly \Spameri\Elastic\Model\ServiceLocator $serviceLocator, + ) {} /** @@ -167,6 +138,30 @@ public function delete( } } + public function deleteReference( + \Spameri\Elastic\Entity\ElasticEntityInterface $entityToDelete, + string $class, + string $field, + ): void + { + try { + $service = $this->serviceLocator->locateByEntityClass($class); + $elasticQuery = new \Spameri\ElasticQuery\ElasticQuery(); + $elasticQuery->addMustQuery( + new \Spameri\ElasticQuery\Query\Term( + field: $field, + query: $entityToDelete->id()->value() + ) + ); + $collection = $service->getAllBy($elasticQuery); + foreach ($collection as $entity) { + $service->delete($entity->id()); + } + + } catch (\Spameri\Elastic\Exception\DocumentNotFound $e) { + // Do nothing + } + } public function aggregate( \Spameri\ElasticQuery\ElasticQuery $elasticQuery From fc89dcdeea4616951ff5136985533f9b32d65d80 Mon Sep 17 00:00:00 2001 From: Spamer Date: Wed, 20 Sep 2023 16:56:04 +0200 Subject: [PATCH 09/37] Stats returns number without from and size parameters, so we must count hits that really exits in collection --- src/Model/AbstractBaseService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Model/AbstractBaseService.php b/src/Model/AbstractBaseService.php index 2d93b508..d920b027 100644 --- a/src/Model/AbstractBaseService.php +++ b/src/Model/AbstractBaseService.php @@ -96,7 +96,7 @@ public function getAllBy( throw $exception; } - if ($resultSearch->stats()->total() === 0) { + if ($resultSearch->hits()->count() === 0) { throw new \Spameri\Elastic\Exception\DocumentNotFound($this->index, $elasticQuery); } From fc9cc08c57fa39d53d008ba0d831000e11d703b8 Mon Sep 17 00:00:00 2001 From: Spamer Date: Mon, 25 Sep 2023 02:49:19 +0200 Subject: [PATCH 10/37] Service locator ignores interface and other namings when locating entity --- src/Model/ServiceLocator.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Model/ServiceLocator.php b/src/Model/ServiceLocator.php index 43c84a9d..2226f063 100644 --- a/src/Model/ServiceLocator.php +++ b/src/Model/ServiceLocator.php @@ -38,6 +38,9 @@ public function locateByEntityClass( ): \Spameri\Elastic\Model\ServiceInterface { $serviceName = \str_replace('Entity', 'Model', $entityClass . 'Service'); + $serviceName = \str_replace('Interface', '', $serviceName); + $serviceName = \str_replace('Abstract', '', $serviceName); + $serviceName = \str_replace('Trait', '', $serviceName); /** @var \Spameri\Elastic\Model\ServiceInterface $service */ $service = $this->container->getByType($serviceName); From 34d0a0260c220e77251ad0ce3b8edd4209fdb1ad Mon Sep 17 00:00:00 2001 From: Spamer Date: Mon, 25 Sep 2023 02:52:06 +0200 Subject: [PATCH 11/37] Prevents infinite loop when inserting entities that have dependencies on each other - Each entity by id is saved only once --- src/Model/Insert/PrepareEntityArray.php | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/Model/Insert/PrepareEntityArray.php b/src/Model/Insert/PrepareEntityArray.php index 0e6499f6..ac318f0f 100644 --- a/src/Model/Insert/PrepareEntityArray.php +++ b/src/Model/Insert/PrepareEntityArray.php @@ -10,6 +10,8 @@ class PrepareEntityArray */ private $serviceLocator; + private array $insertedEntities; + public function __construct( \Spameri\Elastic\Model\ServiceLocatorInterface $serviceLocator @@ -26,6 +28,9 @@ public function prepare( \Spameri\Elastic\Entity\ElasticEntityInterface $entity ): array { + $this->insertedEntities = []; + $this->insertedEntities[$entity->id()->value()] = true; + return $this->iterateVariables($entity->entityVariables()); } @@ -42,7 +47,13 @@ public function iterateVariables( foreach ($variables as $key => $property) { if ($property instanceof \Spameri\Elastic\Entity\ElasticEntityInterface) { - $preparedArray[$key] = $this->serviceLocator->locate($property)->insert($property); + if (\in_array($property->id()->value(), $this->insertedEntities)) { + $preparedArray[$key] = $property->id()->value(); + + } else { + $preparedArray[$key] = $this->serviceLocator->locate($property)->insert($property); + $this->insertedEntities[$property->id()->value()] = true; + } } elseif ($property instanceof \Spameri\Elastic\Entity\EntityInterface) { $preparedArray[$key] = $this->iterateVariables($property->entityVariables()); @@ -66,7 +77,13 @@ public function iterateVariables( } else { /** @var \Spameri\Elastic\Entity\ElasticEntityInterface $item */ foreach ($property as $item) { - $preparedArray[$key][] = $this->serviceLocator->locate($item)->insert($item); + if (\in_array($item->id()->value(), $this->insertedEntities)) { + $preparedArray[$key][] = $item->id()->value(); + + } else { + $preparedArray[$key][] = $this->serviceLocator->locate($item)->insert($item); + $this->insertedEntities[$item->id()->value()] = true; + } } } From e9c829b0b80e8720580a8098d7eeeda870e7c858 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20=C4=8Cevela?= Date: Tue, 19 Dec 2023 09:53:24 +0100 Subject: [PATCH 12/37] Update composer.json bump --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 7f92e9ba..0bad6cd3 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "ext-json": "*", "ext-curl": "*", "spameri/elastic-query": "^v1.0.0", - "elasticsearch/elasticsearch": "^7.12.0", + "elasticsearch/elasticsearch": "^7.12", "nette/di": "^3.0.5", "nette/utils": "^3.2.5", "symfony/console": "^4.4.26", From b3c83fc437dd4a51aeaa878ba1db6f2ea3379b0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20=C4=8Cevela?= Date: Tue, 19 Dec 2023 09:56:02 +0100 Subject: [PATCH 13/37] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 0bad6cd3..7d40d089 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "ext-json": "*", "ext-curl": "*", "spameri/elastic-query": "^v1.0.0", - "elasticsearch/elasticsearch": "^7.12", + "elasticsearch/elasticsearch": "^7.12|^8", "nette/di": "^3.0.5", "nette/utils": "^3.2.5", "symfony/console": "^4.4.26", From 52a2a91b97f06afc871e9315f5e04a564b6bf679 Mon Sep 17 00:00:00 2001 From: Spamer Date: Wed, 8 Nov 2023 02:14:57 +0100 Subject: [PATCH 14/37] Added method for first element --- src/Entity/Collection/AbstractEntityCollection.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Entity/Collection/AbstractEntityCollection.php b/src/Entity/Collection/AbstractEntityCollection.php index 8089c390..58f199e7 100644 --- a/src/Entity/Collection/AbstractEntityCollection.php +++ b/src/Entity/Collection/AbstractEntityCollection.php @@ -108,4 +108,10 @@ public function sort( throw new \Nette\NotImplementedException(); } + + public function first(): ?\Spameri\Elastic\Entity\EntityInterface + { + return \reset($this->collection) ?: NULL; + } + } From ad54db4d9120375a84ec680b4ea70463520d7d02 Mon Sep 17 00:00:00 2001 From: Spamer Date: Wed, 8 Nov 2023 02:15:17 +0100 Subject: [PATCH 15/37] Added ability to handle enums --- src/Model/Insert/PrepareEntityArray.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Model/Insert/PrepareEntityArray.php b/src/Model/Insert/PrepareEntityArray.php index ac318f0f..f04bda94 100644 --- a/src/Model/Insert/PrepareEntityArray.php +++ b/src/Model/Insert/PrepareEntityArray.php @@ -117,6 +117,11 @@ public function iterateVariables( } elseif ($property instanceof \DateTime) { $preparedArray[$key] = $property->format(\Spameri\Elastic\Entity\Property\DateTime::FORMAT); + } elseif ( + $property instanceof \BackedEnum + ) { + $preparedArray[$key] = $property->value; + } else { if (\is_object($property)) { throw new \Spameri\Elastic\Exception\EntityIsNotValid( From ff79284e96467db7e378ffab05437fb297e852e4 Mon Sep 17 00:00:00 2001 From: Spamer Date: Wed, 8 Nov 2023 02:15:41 +0100 Subject: [PATCH 16/37] Service locator can locate by index name --- src/Model/ServiceLocator.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/Model/ServiceLocator.php b/src/Model/ServiceLocator.php index 2226f063..137e24ec 100644 --- a/src/Model/ServiceLocator.php +++ b/src/Model/ServiceLocator.php @@ -10,12 +10,18 @@ class ServiceLocator implements ServiceLocatorInterface */ private $container; + /** + * @var array + */ + private array $services; + public function __construct( \Nette\DI\Container $container ) { $this->container = $container; + $this->services = $container->findByType(\Spameri\Elastic\Model\ServiceInterface::class); } @@ -38,6 +44,7 @@ public function locateByEntityClass( ): \Spameri\Elastic\Model\ServiceInterface { $serviceName = \str_replace('Entity', 'Model', $entityClass . 'Service'); + $serviceName = \str_replace('Interface', '', $serviceName); $serviceName = \str_replace('Abstract', '', $serviceName); $serviceName = \str_replace('Trait', '', $serviceName); @@ -48,4 +55,20 @@ public function locateByEntityClass( return $service; } + + public function locateByIndex(string $index): \Spameri\Elastic\Model\ServiceInterface|null + { + foreach ($this->services as $serviceType) { + $service = $this->container->getService($serviceType); + if (($service instanceof \Spameri\Elastic\Model\AbstractBaseService) === false) { + continue; + } + + if ($service->index === $index) { + return $service; + } + } + + return null; + } } From b1a3edf8853b6a7f1b2bbbfc50b0083767363c50 Mon Sep 17 00:00:00 2001 From: Spamer Date: Thu, 28 Dec 2023 23:13:38 +0100 Subject: [PATCH 17/37] Added generate sitemap command - Command generates sitemap from --- src/ClientProvider.php | 6 +- src/Commands/AddAlias.php | 4 +- src/Commands/CreateIndex.php | 8 +-- src/Commands/DeleteIndex.php | 4 +- src/Commands/DumpIndex.php | 4 +- src/Commands/InitializeIndexes.php | 8 +-- src/Commands/LoadDump.php | 6 +- src/Commands/RemoveAlias.php | 4 +- src/Commands/TypeToNewIndex.php | 6 +- src/DI/SpameriElasticSearchExtension.php | 8 +-- src/Diagnostics/Panel.php | 2 +- src/Diagnostics/PanelLogger.php | 26 +++---- src/Entity/AbstractImport.php | 2 +- src/Entity/AbstractValueCollection.php | 6 +- .../AbstractCachedEntityCollection.php | 12 ++-- .../AbstractElasticEntityCollection.php | 28 ++++---- .../Collection/AbstractEntityCollection.php | 18 ++--- .../ElasticEntityCollectionInterface.php | 12 ++-- src/Entity/EntityCollectionInterface.php | 12 ++-- src/Entity/Import/ArrayValue.php | 2 +- src/Entity/Import/BoolValue.php | 2 +- src/Entity/Import/DateValue.php | 2 +- src/Entity/Import/EmptyValue.php | 2 +- src/Entity/Import/FloatValue.php | 2 +- src/Entity/Import/IntegerValue.php | 2 +- src/Entity/Import/StringValue.php | 2 +- src/Entity/Property/DateTime.php | 2 +- src/Entity/Property/ElasticId.php | 2 +- src/Entity/Property/EmptyElasticId.php | 2 +- src/Entity/Value/BoolValue.php | 2 +- src/Entity/Value/IntegerValue.php | 2 +- src/Entity/Value/StringValue.php | 2 +- src/Exception/AliasAlreadyExists.php | 4 +- src/Exception/DocumentNotFound.php | 4 +- src/Exception/IndexAlreadyExists.php | 4 +- src/Exception/SettingsNotLocated.php | 2 +- src/Factory/CollectionFactoryInterface.php | 2 +- src/Factory/EntityFactoryInterface.php | 2 +- src/Import/AfterImportInterface.php | 2 +- src/Import/DataImportInterface.php | 2 +- src/Import/DataProviderInterface.php | 4 +- src/Import/Lock/FileLock.php | 2 +- src/Import/LockInterface.php | 4 +- src/Import/LoggerHandlerInterface.php | 12 ++-- src/Import/PrepareImportDataInterface.php | 2 +- src/Import/Response/SimpleResponse.php | 2 +- src/Import/ResponseInterface.php | 2 +- src/Import/Run.php | 4 +- src/Import/Run/LoggerHandler.php | 2 +- src/Import/Run/Options.php | 2 +- src/Import/RunHandlerInterface.php | 4 +- src/Import/SimpleRun.php | 2 +- src/Model/AbstractBaseService.php | 18 ++--- src/Model/Aggregate.php | 10 +-- src/Model/CreateIndex.php | 2 +- src/Model/Delete.php | 10 +-- src/Model/DeleteIndex.php | 2 +- src/Model/DeleteMultiple.php | 6 +- src/Model/DumpIndex.php | 10 +-- src/Model/EntitySettingsLocator.php | 2 +- src/Model/Get.php | 8 +-- src/Model/GetAllBy.php | 8 +-- src/Model/GetBy.php | 8 +-- src/Model/Index.php | 10 +-- src/Model/Indices/AddAlias.php | 12 ++-- src/Model/Indices/Close.php | 6 +- src/Model/Indices/Create.php | 10 +-- src/Model/Indices/Delete.php | 8 +-- src/Model/Indices/Exists.php | 8 +-- src/Model/Indices/Get.php | 8 +-- src/Model/Indices/GetFieldMapping.php | 8 +-- src/Model/Indices/GetMapping.php | 6 +- src/Model/Indices/MoveAlias.php | 8 +-- src/Model/Indices/Open.php | 6 +- src/Model/Indices/PutMapping.php | 10 +-- src/Model/Indices/PutSettings.php | 8 +-- src/Model/Indices/RemoveAlias.php | 8 +-- src/Model/InitializeIndex.php | 2 +- src/Model/Insert.php | 10 +-- src/Model/Insert/PrepareEntityArray.php | 10 +-- src/Model/InsertMultiple.php | 6 +- src/Model/RestoreIndex.php | 10 +-- src/Model/Scroll.php | 20 +++--- src/Model/Search.php | 8 +-- src/Model/ServiceInterface.php | 12 ++-- src/Model/ServiceLocator.php | 6 +- src/Model/ServiceLocatorInterface.php | 4 +- .../TypeToNewIndex/DocumentMigrateStatus.php | 4 +- src/Model/TypeToNewIndex/Migrate.php | 22 +++--- src/Model/VersionProvider.php | 2 +- src/Provider/DateTimeProvider.php | 2 +- src/Settings.php | 2 +- src/Settings/NeonSettingsProvider.php | 4 +- .../Elastic/Data/Entity/Person.php | 14 ++-- .../Elastic/Data/Entity/Person/Character.php | 8 +-- .../Person/CharacterCollectionElastic.php | 4 +- .../Elastic/Data/Entity/Person/Job.php | 4 +- .../Entity/Person/JobCollectionElastic.php | 4 +- .../Data/Entity/Property/CountryShort.php | 2 +- .../Data/Entity/Property/Description.php | 4 +- .../Entity/Property/ElasticIdCollection.php | 2 +- .../Elastic/Data/Entity/Property/ImdbId.php | 2 +- .../Data/Entity/Property/ImdbIdCollection.php | 10 +-- .../Elastic/Data/Entity/Property/Name.php | 2 +- .../Elastic/Data/Entity/Property/Text.php | 2 +- .../Elastic/Data/Entity/Property/Url.php | 2 +- .../Elastic/Data/Entity/Property/Year.php | 2 +- .../Elastic/Data/Entity/Video.php | 2 +- .../Elastic/Data/Entity/Video/Alias.php | 2 +- .../Elastic/Data/Entity/Video/Connections.php | 2 +- .../Entity/Video/Connections/EditedFrom.php | 2 +- .../Entity/Video/Connections/EditedInto.php | 2 +- .../Entity/Video/Connections/Featured.php | 2 +- .../Entity/Video/Connections/Followed.php | 2 +- .../Data/Entity/Video/Connections/Follows.php | 2 +- .../Entity/Video/Connections/Reference.php | 2 +- .../Entity/Video/Connections/Referenced.php | 2 +- .../Data/Entity/Video/Connections/Remade.php | 2 +- .../Data/Entity/Video/Connections/SpinOff.php | 2 +- .../Data/Entity/Video/Connections/Spoofed.php | 2 +- .../Data/Entity/Video/Connections/SpunOff.php | 2 +- .../Entity/Video/Connections/VersionOf.php | 2 +- .../Elastic/Data/Entity/Video/Details.php | 2 +- .../Data/Entity/Video/Details/Alias.php | 2 +- .../Data/Entity/Video/Details/Genre.php | 2 +- .../Entity/Video/Details/GenreCollection.php | 4 +- .../Data/Entity/Video/Details/Ratings.php | 2 +- .../Entity/Video/Details/RatingsCount.php | 2 +- .../Data/Entity/Video/Details/Release.php | 2 +- .../Elastic/Data/Entity/Video/HighLights.php | 2 +- .../Video/HighLights/AlternateVersion.php | 2 +- .../Entity/Video/HighLights/CompanyCredit.php | 2 +- .../HighLights/CompanyCredit/Company.php | 2 +- .../Entity/Video/HighLights/CrazyCredit.php | 2 +- .../Data/Entity/Video/HighLights/Goof.php | 2 +- .../Data/Entity/Video/HighLights/Location.php | 2 +- .../Data/Entity/Video/HighLights/Quote.php | 2 +- .../Entity/Video/HighLights/Relevancy.php | 2 +- .../Data/Entity/Video/HighLights/Trivia.php | 2 +- .../Data/Entity/Video/Identification.php | 6 +- .../Elastic/Data/Entity/Video/People.php | 4 +- .../Elastic/Data/Entity/Video/Season.php | 2 +- .../Data/Entity/Video/Season/Episode.php | 2 +- .../Entity/Video/Season/EpisodeCollection.php | 2 +- .../Data/Entity/Video/SeasonCollection.php | 2 +- .../Elastic/Data/Entity/Video/Story.php | 8 +-- .../Data/Entity/Video/Story/KeyWord.php | 2 +- .../Entity/Video/Story/KeyWordCollection.php | 4 +- .../Data/Entity/Video/Story/PlotSummary.php | 2 +- .../Video/Story/PlotSummaryCollection.php | 6 +- .../Data/Entity/Video/Story/Synopsis.php | 4 +- .../Data/Entity/Video/Story/TagLine.php | 2 +- .../Entity/Video/Story/TagLineCollection.php | 4 +- .../Elastic/Data/Entity/Video/Technical.php | 36 +++++----- .../Data/Entity/Video/Technical/Camera.php | 4 +- .../Entity/Video/Technical/CineProcess.php | 4 +- .../Data/Entity/Video/Technical/Color.php | 4 +- .../Entity/Video/Technical/FilmLength.php | 4 +- .../Entity/Video/Technical/Laboratory.php | 4 +- .../Entity/Video/Technical/NegativeFormat.php | 4 +- .../Data/Entity/Video/Technical/Printed.php | 4 +- .../Data/Entity/Video/Technical/Ratio.php | 4 +- .../Data/Entity/Video/Technical/Runtime.php | 4 +- .../Data/Model/PersonCollectionFactory.php | 4 +- .../Elastic/Data/Model/PersonFactory.php | 4 +- .../Elastic/Data/Model/PersonMapping.php | 2 +- .../Elastic/Data/Model/PersonService.php | 8 +-- .../Data/Model/VideoCollectionFactory.php | 4 +- .../Elastic/Data/Model/VideoFactory.php | 18 ++--- .../Elastic/Data/Model/VideoMapping.php | 72 +++++++++---------- .../Elastic/Data/Model/VideoService.php | 8 +-- .../Elastic/Model/Indices/CreateTest.php | 24 +++---- 172 files changed, 492 insertions(+), 492 deletions(-) diff --git a/src/ClientProvider.php b/src/ClientProvider.php index d754ff2f..d388f114 100644 --- a/src/ClientProvider.php +++ b/src/ClientProvider.php @@ -23,7 +23,7 @@ class ClientProvider public function __construct( \Elasticsearch\ClientBuilder $clientBuilder, - \Spameri\Elastic\SettingsProviderInterface $settingsProvider + \Spameri\Elastic\SettingsProviderInterface $settingsProvider, ) { $this->clientBuilder = $clientBuilder; @@ -38,14 +38,14 @@ public function init(): void $this->clientBuilder->setHosts( [ $settings->host() . ':' . $settings->port(), - ] + ], ); $this->clientBuilder->setConnectionParams( [ 'client' => [ 'headers' => $settings->headers(), ], - ] + ], ); } diff --git a/src/Commands/AddAlias.php b/src/Commands/AddAlias.php index c015ccf6..5848e20d 100644 --- a/src/Commands/AddAlias.php +++ b/src/Commands/AddAlias.php @@ -11,7 +11,7 @@ class AddAlias extends \Symfony\Component\Console\Command\Command public function __construct( - \Spameri\Elastic\Model\Indices\AddAlias $addAlias + \Spameri\Elastic\Model\Indices\AddAlias $addAlias, ) { parent::__construct(NULL); @@ -32,7 +32,7 @@ protected function configure(): void protected function execute( \Symfony\Component\Console\Input\InputInterface $input, - \Symfony\Component\Console\Output\OutputInterface $output + \Symfony\Component\Console\Output\OutputInterface $output, ): int { /** @var string $index */ diff --git a/src/Commands/CreateIndex.php b/src/Commands/CreateIndex.php index 8b4e4cf9..a53f9a9b 100644 --- a/src/Commands/CreateIndex.php +++ b/src/Commands/CreateIndex.php @@ -14,7 +14,7 @@ class CreateIndex extends \Symfony\Component\Console\Command\Command public function __construct( \Spameri\Elastic\Model\CreateIndex $createIndex, - \Spameri\Elastic\Model\DeleteIndex $deleteIndex + \Spameri\Elastic\Model\DeleteIndex $deleteIndex, ) { parent::__construct(NULL); @@ -28,12 +28,12 @@ protected function configure(): void $this ->setName(self::$defaultName) ->setDescription( - 'Creates index. Take string as is, adds timestamp and inserts it in Elastic. No mapping or settings.' + 'Creates index. Take string as is, adds timestamp and inserts it in Elastic. No mapping or settings.', ) ->addArgument('indexName', \Symfony\Component\Console\Input\InputArgument::REQUIRED) ->addOption( 'force', 'f', NULL, - 'Warning this deletes your data! Forces now used index to be deleted before new index is created.' + 'Warning this deletes your data! Forces now used index to be deleted before new index is created.', ) ; } @@ -44,7 +44,7 @@ protected function configure(): void */ protected function execute( \Symfony\Component\Console\Input\InputInterface $input, - \Symfony\Component\Console\Output\OutputInterface $output + \Symfony\Component\Console\Output\OutputInterface $output, ): int { /** @var string $indexName */ diff --git a/src/Commands/DeleteIndex.php b/src/Commands/DeleteIndex.php index b433608a..6136ee20 100644 --- a/src/Commands/DeleteIndex.php +++ b/src/Commands/DeleteIndex.php @@ -11,7 +11,7 @@ class DeleteIndex extends \Symfony\Component\Console\Command\Command public function __construct( - \Spameri\Elastic\Model\Indices\Delete $delete + \Spameri\Elastic\Model\Indices\Delete $delete, ) { parent::__construct(NULL); @@ -31,7 +31,7 @@ protected function configure(): void protected function execute( \Symfony\Component\Console\Input\InputInterface $input, - \Symfony\Component\Console\Output\OutputInterface $output + \Symfony\Component\Console\Output\OutputInterface $output, ): int { /** @var array $indexNames */ diff --git a/src/Commands/DumpIndex.php b/src/Commands/DumpIndex.php index db41a674..477607d2 100644 --- a/src/Commands/DumpIndex.php +++ b/src/Commands/DumpIndex.php @@ -11,7 +11,7 @@ class DumpIndex extends \Symfony\Component\Console\Command\Command public function __construct( - \Spameri\Elastic\Model\DumpIndex $migrate + \Spameri\Elastic\Model\DumpIndex $migrate, ) { parent::__construct(NULL); @@ -36,7 +36,7 @@ protected function configure(): void protected function execute( \Symfony\Component\Console\Input\InputInterface $input, - \Symfony\Component\Console\Output\OutputInterface $output + \Symfony\Component\Console\Output\OutputInterface $output, ): int { $output->writeln('Starting'); diff --git a/src/Commands/InitializeIndexes.php b/src/Commands/InitializeIndexes.php index dbd15384..9774fd72 100644 --- a/src/Commands/InitializeIndexes.php +++ b/src/Commands/InitializeIndexes.php @@ -17,7 +17,7 @@ class InitializeIndexes extends \Symfony\Component\Console\Command\Command public function __construct( \Spameri\Elastic\Model\EntitySettingsLocator $entitySettingsLocator, \Spameri\Elastic\Model\DeleteIndex $deleteIndex, - \Spameri\Elastic\Model\InitializeIndex $initializeIndex + \Spameri\Elastic\Model\InitializeIndex $initializeIndex, ) { parent::__construct(NULL); @@ -32,12 +32,12 @@ protected function configure(): void $this ->setName(self::$defaultName) ->setDescription( - 'Creates index/es. And initializes with settings and mappings' + 'Creates index/es. And initializes with settings and mappings', ) ->addArgument('entityName', \Symfony\Component\Console\Input\InputArgument::IS_ARRAY) ->addOption( 'force', 'f', NULL, - 'Warning this deletes your data! Forces now used index to be deleted before new index is created.' + 'Warning this deletes your data! Forces now used index to be deleted before new index is created.', ) ; } @@ -48,7 +48,7 @@ protected function configure(): void */ protected function execute( \Symfony\Component\Console\Input\InputInterface $input, - \Symfony\Component\Console\Output\OutputInterface $output + \Symfony\Component\Console\Output\OutputInterface $output, ): int { /** @var array $entityNames */ diff --git a/src/Commands/LoadDump.php b/src/Commands/LoadDump.php index 49b9e25d..72acb2e9 100644 --- a/src/Commands/LoadDump.php +++ b/src/Commands/LoadDump.php @@ -11,7 +11,7 @@ class LoadDump extends \Symfony\Component\Console\Command\Command public function __construct( - \Spameri\Elastic\Model\RestoreIndex $migrate + \Spameri\Elastic\Model\RestoreIndex $migrate, ) { parent::__construct(NULL); @@ -32,7 +32,7 @@ protected function configure(): void 'step', \Symfony\Component\Console\Input\InputArgument::OPTIONAL, 'Number of documents per one bulk index', - '500' + '500', ) ; } @@ -40,7 +40,7 @@ protected function configure(): void protected function execute( \Symfony\Component\Console\Input\InputInterface $input, - \Symfony\Component\Console\Output\OutputInterface $output + \Symfony\Component\Console\Output\OutputInterface $output, ): int { $output->writeln('Starting'); diff --git a/src/Commands/RemoveAlias.php b/src/Commands/RemoveAlias.php index 853af4fc..378e329e 100644 --- a/src/Commands/RemoveAlias.php +++ b/src/Commands/RemoveAlias.php @@ -11,7 +11,7 @@ class RemoveAlias extends \Symfony\Component\Console\Command\Command public function __construct( - \Spameri\Elastic\Model\Indices\RemoveAlias $removeAlias + \Spameri\Elastic\Model\Indices\RemoveAlias $removeAlias, ) { parent::__construct(NULL); @@ -32,7 +32,7 @@ protected function configure(): void protected function execute( \Symfony\Component\Console\Input\InputInterface $input, - \Symfony\Component\Console\Output\OutputInterface $output + \Symfony\Component\Console\Output\OutputInterface $output, ): int { /** @var string $index */ diff --git a/src/Commands/TypeToNewIndex.php b/src/Commands/TypeToNewIndex.php index 4dbeadb7..35f6e7c4 100644 --- a/src/Commands/TypeToNewIndex.php +++ b/src/Commands/TypeToNewIndex.php @@ -11,7 +11,7 @@ class TypeToNewIndex extends \Symfony\Component\Console\Command\Command public function __construct( - \Spameri\Elastic\Model\TypeToNewIndex\Migrate $migrate + \Spameri\Elastic\Model\TypeToNewIndex\Migrate $migrate, ) { parent::__construct(NULL); @@ -35,7 +35,7 @@ protected function configure(): void ->addOption( 'allowClose', 'c', \Symfony\Component\Console\Input\InputOption::VALUE_OPTIONAL, 'Allows command to close index for data transfer. After data is transferred index is opened and resumes normal operations. When open it needs to check changed files after move and sync remaining.', - TRUE + TRUE, ) ; } @@ -46,7 +46,7 @@ protected function configure(): void */ protected function execute( \Symfony\Component\Console\Input\InputInterface $input, - \Symfony\Component\Console\Output\OutputInterface $output + \Symfony\Component\Console\Output\OutputInterface $output, ): int { $output->writeln('Starting'); diff --git a/src/DI/SpameriElasticSearchExtension.php b/src/DI/SpameriElasticSearchExtension.php index 34a2a60e..353b4101 100644 --- a/src/DI/SpameriElasticSearchExtension.php +++ b/src/DI/SpameriElasticSearchExtension.php @@ -39,7 +39,7 @@ public function loadConfiguration(): void } $this->compiler->loadDefinitionsFromConfig( - $aliasedServices + $aliasedServices, ); } @@ -47,7 +47,7 @@ public function loadConfiguration(): void public function setConfigOptions( array $services, - array $config + array $config, ): array { $neonSettingsProvider = $services['services']['neonSettingsProvider']['factory']; @@ -68,7 +68,7 @@ public function setConfigOptions( */ public function toggleDebugBar( array $config, - array $services + array $services, ): array { if ( ! $config['debug']) { @@ -77,7 +77,7 @@ public function toggleDebugBar( $services['services']['elasticPanelLogger'], $services['services']['nullLogger'], $services['services']['elasticPanel'], - $services['services']['clientBuilder']['setup'] + $services['services']['clientBuilder']['setup'], ); } else { diff --git a/src/Diagnostics/Panel.php b/src/Diagnostics/Panel.php index b98cd018..a7207ec0 100644 --- a/src/Diagnostics/Panel.php +++ b/src/Diagnostics/Panel.php @@ -12,7 +12,7 @@ class Panel implements \Tracy\IBarPanel public function __construct( - \Spameri\Elastic\Diagnostics\PanelLogger $logger + \Spameri\Elastic\Diagnostics\PanelLogger $logger, ) { $this->logger = $logger; diff --git a/src/Diagnostics/PanelLogger.php b/src/Diagnostics/PanelLogger.php index 61e12837..94a20257 100644 --- a/src/Diagnostics/PanelLogger.php +++ b/src/Diagnostics/PanelLogger.php @@ -27,7 +27,7 @@ class PanelLogger implements \Psr\Log\LoggerInterface public function __construct( - \Psr\Log\LoggerInterface $logger + \Psr\Log\LoggerInterface $logger, ) { $this->logger = $logger; @@ -40,7 +40,7 @@ public function __construct( */ public function emergency( $message, - array $context = [] + array $context = [], ) { $this->logger->emergency($message, $context); @@ -54,7 +54,7 @@ public function emergency( */ public function alert( $message, - array $context = [] + array $context = [], ): void { $this->logger->alert($message, $context); @@ -68,7 +68,7 @@ public function alert( */ public function critical( $message, - array $context = [] + array $context = [], ): void { $this->logger->critical($message, $context); @@ -82,7 +82,7 @@ public function critical( */ public function error( $message, - array $context = [] + array $context = [], ): void { $this->logger->error($message, $context); @@ -96,7 +96,7 @@ public function error( */ public function warning( $message, - array $context = [] + array $context = [], ): void { $this->logger->warning($message, $context); @@ -110,7 +110,7 @@ public function warning( */ public function notice( $message, - array $context = [] + array $context = [], ): void { $this->logger->notice($message, $context); @@ -124,7 +124,7 @@ public function notice( */ public function info( $message, - array $context = [] + array $context = [], ): void { $this->logger->info($message, $context); @@ -138,7 +138,7 @@ public function info( */ public function debug( $message, - array $context = [] + array $context = [], ): void { $this->logger->debug($message, $context); @@ -156,7 +156,7 @@ public function debug( public function log( $level, $message, - array $context = [] + array $context = [], ): void { $this->logger->log($level, $message, $context); @@ -195,7 +195,7 @@ public function getResponseBodies(): array * @param array $context */ private function logQuery( - array $context = [] + array $context = [], ): void { if (isset($context['method'], $context['uri'])) { @@ -211,7 +211,7 @@ private function logQuery( */ private function logRequestBody( string $message, - $context + $context, ): void { if ( @@ -228,7 +228,7 @@ private function logRequestBody( */ private function logResponseBody( string $message, - $context + $context, ): void { if ($message === 'Response') { diff --git a/src/Entity/AbstractImport.php b/src/Entity/AbstractImport.php index 1f47ad14..c50f1417 100644 --- a/src/Entity/AbstractImport.php +++ b/src/Entity/AbstractImport.php @@ -15,7 +15,7 @@ abstract class AbstractImport implements \Spameri\Elastic\Entity\Import\Validati * @param int|string $key */ public function __construct( - $key + $key, ) { $this->key = $key; diff --git a/src/Entity/AbstractValueCollection.php b/src/Entity/AbstractValueCollection.php index ba2a1e86..69597c9c 100644 --- a/src/Entity/AbstractValueCollection.php +++ b/src/Entity/AbstractValueCollection.php @@ -12,7 +12,7 @@ abstract class AbstractValueCollection implements ValueCollectionInterface public function __construct( - \Spameri\Elastic\Entity\ValueInterface ...$collection + \Spameri\Elastic\Entity\ValueInterface ...$collection, ) { $this->collection = []; @@ -23,7 +23,7 @@ public function __construct( public function add( - \Spameri\Elastic\Entity\ValueInterface $value + \Spameri\Elastic\Entity\ValueInterface $value, ): void { $this->collection[$value->value()] = $value; @@ -42,7 +42,7 @@ public function remove($key): void /** * @param mixed $key */ - public function get($key): ?\Spameri\Elastic\Entity\ValueInterface + public function get($key): \Spameri\Elastic\Entity\ValueInterface|null { if ( ! isset($this->collection[$key])) { return NULL; diff --git a/src/Entity/Collection/AbstractCachedEntityCollection.php b/src/Entity/Collection/AbstractCachedEntityCollection.php index d2fb19bd..cc9e377b 100644 --- a/src/Entity/Collection/AbstractCachedEntityCollection.php +++ b/src/Entity/Collection/AbstractCachedEntityCollection.php @@ -11,8 +11,8 @@ abstract class AbstractCachedEntityCollection extends AbstractEntityCollection abstract public function initialize(): void; public function entity( - string $key - ): ?\Spameri\Elastic\Entity\EntityInterface + string $key, + ): \Spameri\Elastic\Entity\EntityInterface|null { $this->initialize(); @@ -21,7 +21,7 @@ public function entity( public function remove( - string $key + string $key, ): void { $this->initialize(); @@ -31,7 +31,7 @@ public function remove( public function isValue( - string $key + string $key, ): bool { $this->initialize(); @@ -57,7 +57,7 @@ public function keys(): array public function isKey( - string $key + string $key, ): bool { $this->initialize(); @@ -68,7 +68,7 @@ public function isKey( public function sort( \Spameri\Elastic\Entity\Collection\SortField $sortField, // phpcs:ignore - string $type + string $type, ): void { $this->initialize(); diff --git a/src/Entity/Collection/AbstractElasticEntityCollection.php b/src/Entity/Collection/AbstractElasticEntityCollection.php index 9d59b0ea..f5f3710d 100644 --- a/src/Entity/Collection/AbstractElasticEntityCollection.php +++ b/src/Entity/Collection/AbstractElasticEntityCollection.php @@ -29,7 +29,7 @@ abstract class AbstractElasticEntityCollection implements \Spameri\Elastic\Entit public function __construct( \Spameri\Elastic\Model\ServiceInterface $service, array $elasticIds = [], - \Spameri\Elastic\Entity\ElasticEntityInterface ...$entityCollection + \Spameri\Elastic\Entity\ElasticEntityInterface ...$entityCollection, ) { $this->collection = []; @@ -51,7 +51,7 @@ public function __construct( public function add( - \Spameri\Elastic\Entity\ElasticEntityInterface $elasticEntity + \Spameri\Elastic\Entity\ElasticEntityInterface $elasticEntity, ): void { if ( ! $this->initialized) { @@ -76,11 +76,11 @@ public function initialize(): void new \Spameri\ElasticQuery\Query\MustCollection( new \Spameri\ElasticQuery\Query\Terms( '_id', - $this->elasticIds - ) - ) - ) - ) + $this->elasticIds, + ), + ), + ), + ), ); $this->initialized = TRUE; @@ -123,8 +123,8 @@ public function getIterator(): \ArrayIterator public function entity( - \Spameri\Elastic\Entity\Property\ElasticIdInterface $id - ): ?\Spameri\Elastic\Entity\ElasticEntityInterface + \Spameri\Elastic\Entity\Property\ElasticIdInterface $id, + ): \Spameri\Elastic\Entity\ElasticEntityInterface|null { if ( ! $this->initialized) { $this->initialize(); @@ -143,7 +143,7 @@ public function entity( public function remove( - \Spameri\Elastic\Entity\Property\ElasticIdInterface $id + \Spameri\Elastic\Entity\Property\ElasticIdInterface $id, ): void { if ( ! $this->initialized) { @@ -155,7 +155,7 @@ public function remove( public function isValue( - \Spameri\Elastic\Entity\Property\ElasticIdInterface $id + \Spameri\Elastic\Entity\Property\ElasticIdInterface $id, ): bool { if ( ! $this->initialized) { @@ -187,7 +187,7 @@ public function keys(): array public function isKey( - string $key + string $key, ): bool { if ( ! $this->initialized) { @@ -206,7 +206,7 @@ public function clear(): void public function sort( \Spameri\Elastic\Entity\Collection\SortField $sortField, // phpcs:ignore - string $type + string $type, ): void { if ( ! $this->initialized) { @@ -221,7 +221,7 @@ public function sort( } - public function first(): ?\Spameri\Elastic\Entity\ElasticEntityInterface + public function first(): \Spameri\Elastic\Entity\ElasticEntityInterface|null { if ( ! $this->initialized) { $this->initialize(); diff --git a/src/Entity/Collection/AbstractEntityCollection.php b/src/Entity/Collection/AbstractEntityCollection.php index 58f199e7..03a1e609 100644 --- a/src/Entity/Collection/AbstractEntityCollection.php +++ b/src/Entity/Collection/AbstractEntityCollection.php @@ -12,7 +12,7 @@ abstract class AbstractEntityCollection implements \Spameri\Elastic\Entity\Entit public function __construct( - \Spameri\Elastic\Entity\EntityInterface ...$entityCollection + \Spameri\Elastic\Entity\EntityInterface ...$entityCollection, ) { $this->collection = []; @@ -23,7 +23,7 @@ public function __construct( public function add( - \Spameri\Elastic\Entity\EntityInterface $entity + \Spameri\Elastic\Entity\EntityInterface $entity, ): void { $this->collection[$entity->key()] = $entity; @@ -43,8 +43,8 @@ public function getIterator(): \ArrayIterator public function entity( - string $key - ): ?\Spameri\Elastic\Entity\EntityInterface + string $key, + ): \Spameri\Elastic\Entity\EntityInterface|null { if (\array_key_exists($key, $this->collection)) { return $this->collection[$key]; @@ -55,7 +55,7 @@ public function entity( public function remove( - string $key + string $key, ): void { unset($this->collection[$key]); @@ -63,7 +63,7 @@ public function remove( public function isValue( - string $key + string $key, ): bool { return \array_key_exists($key, $this->collection); @@ -83,7 +83,7 @@ public function keys(): array public function isKey( - string $key + string $key, ): bool { return \array_key_exists($key, \array_map('\strval', \array_keys($this->collection))); @@ -98,7 +98,7 @@ public function clear(): void public function sort( \Spameri\Elastic\Entity\Collection\SortField $sortField, // phpcs:ignore - string $type + string $type, ): void { if ( ! \in_array($type, ['asc', 'desc'], TRUE)) { @@ -109,7 +109,7 @@ public function sort( } - public function first(): ?\Spameri\Elastic\Entity\EntityInterface + public function first(): \Spameri\Elastic\Entity\EntityInterface|null { return \reset($this->collection) ?: NULL; } diff --git a/src/Entity/ElasticEntityCollectionInterface.php b/src/Entity/ElasticEntityCollectionInterface.php index a7958d32..aeb2f9bf 100644 --- a/src/Entity/ElasticEntityCollectionInterface.php +++ b/src/Entity/ElasticEntityCollectionInterface.php @@ -6,22 +6,22 @@ interface ElasticEntityCollectionInterface extends \IteratorAggregate { public function add( - \Spameri\Elastic\Entity\ElasticEntityInterface $entity + \Spameri\Elastic\Entity\ElasticEntityInterface $entity, ): void; public function entity( - \Spameri\Elastic\Entity\Property\ElasticIdInterface $id - ): ?\Spameri\Elastic\Entity\ElasticEntityInterface; + \Spameri\Elastic\Entity\Property\ElasticIdInterface $id, + ): \Spameri\Elastic\Entity\ElasticEntityInterface|null; public function remove( - \Spameri\Elastic\Entity\Property\ElasticIdInterface $id + \Spameri\Elastic\Entity\Property\ElasticIdInterface $id, ): void; public function isValue( - \Spameri\Elastic\Entity\Property\ElasticIdInterface $id + \Spameri\Elastic\Entity\Property\ElasticIdInterface $id, ): bool; @@ -42,7 +42,7 @@ public function elasticIds(): array; public function sort( \Spameri\Elastic\Entity\Collection\SortField $sortField, - string $type + string $type, ): void; } diff --git a/src/Entity/EntityCollectionInterface.php b/src/Entity/EntityCollectionInterface.php index 29412fe9..4623b4db 100644 --- a/src/Entity/EntityCollectionInterface.php +++ b/src/Entity/EntityCollectionInterface.php @@ -6,22 +6,22 @@ interface EntityCollectionInterface extends \IteratorAggregate { public function add( - \Spameri\Elastic\Entity\EntityInterface $entity + \Spameri\Elastic\Entity\EntityInterface $entity, ): void; public function entity( - string $key - ): ?\Spameri\Elastic\Entity\EntityInterface; + string $key, + ): \Spameri\Elastic\Entity\EntityInterface|null; public function remove( - string $key + string $key, ): void; public function isValue( - string $key + string $key, ): bool; @@ -36,7 +36,7 @@ public function clear(): void; public function sort( \Spameri\Elastic\Entity\Collection\SortField $sortField, - string $type + string $type, ): void; } diff --git a/src/Entity/Import/ArrayValue.php b/src/Entity/Import/ArrayValue.php index cc360998..bb704d7d 100644 --- a/src/Entity/Import/ArrayValue.php +++ b/src/Entity/Import/ArrayValue.php @@ -21,7 +21,7 @@ class ArrayValue implements ValidationPropertyInterface */ public function __construct( array $array, - string $key + string $key, ) { $this->array = $array; diff --git a/src/Entity/Import/BoolValue.php b/src/Entity/Import/BoolValue.php index f88cf329..7c10fba9 100644 --- a/src/Entity/Import/BoolValue.php +++ b/src/Entity/Import/BoolValue.php @@ -18,7 +18,7 @@ class BoolValue implements ValidationPropertyInterface public function __construct( bool $value, - string $key + string $key, ) { $this->value = $value; diff --git a/src/Entity/Import/DateValue.php b/src/Entity/Import/DateValue.php index d7044bff..390d6b2d 100644 --- a/src/Entity/Import/DateValue.php +++ b/src/Entity/Import/DateValue.php @@ -24,7 +24,7 @@ class DateValue implements ValidationPropertyInterface public function __construct( \DateTime $value, string $key, - string $format = 'Y-m-d H:i:s' + string $format = 'Y-m-d H:i:s', ) { $this->value = $value; diff --git a/src/Entity/Import/EmptyValue.php b/src/Entity/Import/EmptyValue.php index 96436812..2fdb1974 100644 --- a/src/Entity/Import/EmptyValue.php +++ b/src/Entity/Import/EmptyValue.php @@ -12,7 +12,7 @@ class EmptyValue implements ValidationPropertyInterface public function __construct( - string $key + string $key, ) { $this->key = $key; diff --git a/src/Entity/Import/FloatValue.php b/src/Entity/Import/FloatValue.php index 6b08ff48..000da9d6 100644 --- a/src/Entity/Import/FloatValue.php +++ b/src/Entity/Import/FloatValue.php @@ -18,7 +18,7 @@ class FloatValue implements ValidationPropertyInterface public function __construct( float $value, - string $key + string $key, ) { $this->value = $value; diff --git a/src/Entity/Import/IntegerValue.php b/src/Entity/Import/IntegerValue.php index 34c43d14..24db539c 100644 --- a/src/Entity/Import/IntegerValue.php +++ b/src/Entity/Import/IntegerValue.php @@ -18,7 +18,7 @@ class IntegerValue implements ValidationPropertyInterface public function __construct( int $value, - string $key + string $key, ) { $this->value = $value; diff --git a/src/Entity/Import/StringValue.php b/src/Entity/Import/StringValue.php index fd39bd9e..c838c65b 100644 --- a/src/Entity/Import/StringValue.php +++ b/src/Entity/Import/StringValue.php @@ -18,7 +18,7 @@ class StringValue implements ValidationPropertyInterface public function __construct( string $value, - string $key + string $key, ) { $this->value = $value; diff --git a/src/Entity/Property/DateTime.php b/src/Entity/Property/DateTime.php index f3a6299d..9e2c9b61 100644 --- a/src/Entity/Property/DateTime.php +++ b/src/Entity/Property/DateTime.php @@ -38,7 +38,7 @@ public function formatTimeAgo(): string 24 * 60 * 60 => 'day', 60 * 60 => 'hour', 60 => 'minute', - 1 => 'second' + 1 => 'second', ]; foreach ($condition as $secs => $str) { diff --git a/src/Entity/Property/ElasticId.php b/src/Entity/Property/ElasticId.php index 418f63c9..9843bd98 100644 --- a/src/Entity/Property/ElasticId.php +++ b/src/Entity/Property/ElasticId.php @@ -15,7 +15,7 @@ class ElasticId implements \Spameri\Elastic\Entity\ValueInterface, \Spameri\Elas public function __construct( - string $id + string $id, ) { if ($id === '') { diff --git a/src/Entity/Property/EmptyElasticId.php b/src/Entity/Property/EmptyElasticId.php index da60ff76..76b60414 100644 --- a/src/Entity/Property/EmptyElasticId.php +++ b/src/Entity/Property/EmptyElasticId.php @@ -12,7 +12,7 @@ class EmptyElasticId implements \Spameri\Elastic\Entity\ValueInterface, \Spameri public function __construct( - string $id = '' + string $id = '', ) { if ($id !== '') { diff --git a/src/Entity/Value/BoolValue.php b/src/Entity/Value/BoolValue.php index ffcdec64..3a74592a 100644 --- a/src/Entity/Value/BoolValue.php +++ b/src/Entity/Value/BoolValue.php @@ -12,7 +12,7 @@ class BoolValue implements \Spameri\Elastic\Entity\ValueInterface public function __construct( - bool $value + bool $value, ) { $this->value = $value; diff --git a/src/Entity/Value/IntegerValue.php b/src/Entity/Value/IntegerValue.php index 0a5d202a..3ab18e08 100644 --- a/src/Entity/Value/IntegerValue.php +++ b/src/Entity/Value/IntegerValue.php @@ -12,7 +12,7 @@ class IntegerValue implements \Spameri\Elastic\Entity\ValueInterface public function __construct( - int $value + int $value, ) { $this->value = $value; diff --git a/src/Entity/Value/StringValue.php b/src/Entity/Value/StringValue.php index 171bb19c..13b66404 100644 --- a/src/Entity/Value/StringValue.php +++ b/src/Entity/Value/StringValue.php @@ -12,7 +12,7 @@ class StringValue implements \Spameri\Elastic\Entity\ValueInterface public function __construct( - string $value + string $value, ) { $this->value = $value; diff --git a/src/Exception/AliasAlreadyExists.php b/src/Exception/AliasAlreadyExists.php index 92b6d6ab..dd4be20c 100644 --- a/src/Exception/AliasAlreadyExists.php +++ b/src/Exception/AliasAlreadyExists.php @@ -6,11 +6,11 @@ class AliasAlreadyExists extends \Spameri\Elastic\Exception\AbstractElasticSearc { public function __construct( - string $indexName + string $indexName, ) { parent::__construct( - 'You are trying to create already existing alias with name: ' . $indexName . "\n" + 'You are trying to create already existing alias with name: ' . $indexName . "\n", ); } diff --git a/src/Exception/DocumentNotFound.php b/src/Exception/DocumentNotFound.php index 43684518..b707e0be 100644 --- a/src/Exception/DocumentNotFound.php +++ b/src/Exception/DocumentNotFound.php @@ -7,7 +7,7 @@ class DocumentNotFound extends \Spameri\Elastic\Exception\AbstractElasticSearchE public function __construct( string $message, - ?\Spameri\ElasticQuery\ElasticQuery $elasticQuery = NULL + \Spameri\ElasticQuery\ElasticQuery|null $elasticQuery = NULL, ) { $queryString = ''; @@ -22,7 +22,7 @@ public function __construct( parent::__construct( 'Document in index "' . $message . '" not found. With query: ' - . $queryString + . $queryString, ); } diff --git a/src/Exception/IndexAlreadyExists.php b/src/Exception/IndexAlreadyExists.php index 6d4bbb76..7fdfb4b9 100644 --- a/src/Exception/IndexAlreadyExists.php +++ b/src/Exception/IndexAlreadyExists.php @@ -6,12 +6,12 @@ class IndexAlreadyExists extends \Spameri\Elastic\Exception\AbstractElasticSearc { public function __construct( - string $indexName + string $indexName, ) { parent::__construct( 'You are trying to create already existing index or aliased index with name: ' . $indexName . "\n" - . 'You can delete already existing index by -f option' . "\n" + . 'You can delete already existing index by -f option' . "\n", ); } diff --git a/src/Exception/SettingsNotLocated.php b/src/Exception/SettingsNotLocated.php index 340f2910..3c246eae 100644 --- a/src/Exception/SettingsNotLocated.php +++ b/src/Exception/SettingsNotLocated.php @@ -6,7 +6,7 @@ class SettingsNotLocated extends \Spameri\Elastic\Exception\AbstractElasticSearc { public function __construct( - string $indexName + string $indexName, ) { parent::__construct('Settings not found for index name ' . $indexName); diff --git a/src/Factory/CollectionFactoryInterface.php b/src/Factory/CollectionFactoryInterface.php index fe66d826..ac05b912 100644 --- a/src/Factory/CollectionFactoryInterface.php +++ b/src/Factory/CollectionFactoryInterface.php @@ -12,7 +12,7 @@ interface CollectionFactoryInterface public function create( \Spameri\Elastic\Model\ServiceInterface $service, array $elasticIds = [], - \Spameri\Elastic\Entity\ElasticEntityInterface ...$entityCollection + \Spameri\Elastic\Entity\ElasticEntityInterface ...$entityCollection, ): \Spameri\Elastic\Entity\ElasticEntityCollectionInterface; } diff --git a/src/Factory/EntityFactoryInterface.php b/src/Factory/EntityFactoryInterface.php index 5a5c310f..34b6fbe8 100644 --- a/src/Factory/EntityFactoryInterface.php +++ b/src/Factory/EntityFactoryInterface.php @@ -6,7 +6,7 @@ interface EntityFactoryInterface { public function create( - \Spameri\ElasticQuery\Response\Result\Hit $hit + \Spameri\ElasticQuery\Response\Result\Hit $hit, ): \Generator; } diff --git a/src/Import/AfterImportInterface.php b/src/Import/AfterImportInterface.php index 3ef02dfe..6b24a5a4 100644 --- a/src/Import/AfterImportInterface.php +++ b/src/Import/AfterImportInterface.php @@ -10,7 +10,7 @@ interface AfterImportInterface */ public function process( array $entityData, - \Spameri\Elastic\Import\ResponseInterface $result + \Spameri\Elastic\Import\ResponseInterface $result, ): void; } diff --git a/src/Import/DataImportInterface.php b/src/Import/DataImportInterface.php index b61b924d..65af255c 100644 --- a/src/Import/DataImportInterface.php +++ b/src/Import/DataImportInterface.php @@ -6,7 +6,7 @@ interface DataImportInterface { public function import( - \Spameri\Elastic\Entity\AbstractImport $entity + \Spameri\Elastic\Entity\AbstractImport $entity, ): \Spameri\Elastic\Import\ResponseInterface; } diff --git a/src/Import/DataProviderInterface.php b/src/Import/DataProviderInterface.php index a92be2b3..32f5e919 100644 --- a/src/Import/DataProviderInterface.php +++ b/src/Import/DataProviderInterface.php @@ -9,12 +9,12 @@ interface DataProviderInterface * @return \Generator */ public function provide( - \Spameri\Elastic\Import\Run\Options $options + \Spameri\Elastic\Import\Run\Options $options, ): \Generator; public function count( - \Spameri\Elastic\Import\Run\Options $options + \Spameri\Elastic\Import\Run\Options $options, ): int; } diff --git a/src/Import/Lock/FileLock.php b/src/Import/Lock/FileLock.php index f54e7734..095e1914 100644 --- a/src/Import/Lock/FileLock.php +++ b/src/Import/Lock/FileLock.php @@ -17,7 +17,7 @@ class FileLock implements \Spameri\Elastic\Import\LockInterface public function __construct( - string $lockDir + string $lockDir, ) { $this->lockDir = $lockDir; diff --git a/src/Import/LockInterface.php b/src/Import/LockInterface.php index f8f04d86..17d648c5 100644 --- a/src/Import/LockInterface.php +++ b/src/Import/LockInterface.php @@ -12,7 +12,7 @@ public function setRunName(string $runName): void; * @throws \Spameri\Elastic\Import\Exception\AlreadyLocked */ public function acquire( - int $time + int $time, ): self; @@ -20,7 +20,7 @@ public function release(): void; public function extend( - int $time + int $time, ): void; } diff --git a/src/Import/LoggerHandlerInterface.php b/src/Import/LoggerHandlerInterface.php index 587b079a..5b587ba8 100644 --- a/src/Import/LoggerHandlerInterface.php +++ b/src/Import/LoggerHandlerInterface.php @@ -9,32 +9,32 @@ interface LoggerHandlerInterface * @param mixed $item */ public function logItemStart( - $item + $item, ): void; public function logPrepared( - \Spameri\Elastic\Entity\AbstractImport $import + \Spameri\Elastic\Entity\AbstractImport $import, ): void; public function logResponse( - \Spameri\Elastic\Import\ResponseInterface $result + \Spameri\Elastic\Import\ResponseInterface $result, ): void; public function logOmitException( - \Spameri\Elastic\Import\Exception\ImportException $exception + \Spameri\Elastic\Import\Exception\ImportException $exception, ): void; public function logErrorException( - \Spameri\Elastic\Import\Exception\ImportException $exception + \Spameri\Elastic\Import\Exception\ImportException $exception, ): void; public function logFatalException( - \Spameri\Elastic\Import\Exception\ImportException $exception + \Spameri\Elastic\Import\Exception\ImportException $exception, ): void; diff --git a/src/Import/PrepareImportDataInterface.php b/src/Import/PrepareImportDataInterface.php index 79622efd..c3cfc509 100644 --- a/src/Import/PrepareImportDataInterface.php +++ b/src/Import/PrepareImportDataInterface.php @@ -9,7 +9,7 @@ interface PrepareImportDataInterface * @param mixed $entityData */ public function prepare( - $entityData + $entityData, ): \Spameri\Elastic\Entity\AbstractImport; } diff --git a/src/Import/Response/SimpleResponse.php b/src/Import/Response/SimpleResponse.php index 926db986..e2a9d361 100644 --- a/src/Import/Response/SimpleResponse.php +++ b/src/Import/Response/SimpleResponse.php @@ -18,7 +18,7 @@ class SimpleResponse implements \Spameri\Elastic\Import\ResponseInterface public function __construct( $response, - \Spameri\Elastic\Entity\AbstractImport $entity + \Spameri\Elastic\Entity\AbstractImport $entity, ) { $this->response = $response; diff --git a/src/Import/ResponseInterface.php b/src/Import/ResponseInterface.php index 9c3552c0..1e5ca392 100644 --- a/src/Import/ResponseInterface.php +++ b/src/Import/ResponseInterface.php @@ -10,7 +10,7 @@ interface ResponseInterface */ public function __construct( $response, - \Spameri\Elastic\Entity\AbstractImport $entity + \Spameri\Elastic\Entity\AbstractImport $entity, ); diff --git a/src/Import/Run.php b/src/Import/Run.php index 87807865..1abf4336 100644 --- a/src/Import/Run.php +++ b/src/Import/Run.php @@ -72,7 +72,7 @@ public function __construct( \Spameri\Elastic\Import\DataProviderInterface $dataProvider, \Spameri\Elastic\Import\PrepareImportDataInterface $prepareImportData, \Spameri\Elastic\Import\DataImportInterface $dataImport, - \Spameri\Elastic\Import\AfterImportInterface $afterImport + \Spameri\Elastic\Import\AfterImportInterface $afterImport, ) { $this->lock = $lock; @@ -113,7 +113,7 @@ protected function setUpLogger(string $logDir): void public function execute( - \Spameri\Elastic\Import\Run\Options $options + \Spameri\Elastic\Import\Run\Options $options, ): void { $this->lock->acquire($options->lockDuration()); diff --git a/src/Import/Run/LoggerHandler.php b/src/Import/Run/LoggerHandler.php index a6fb7013..ff3c79d0 100644 --- a/src/Import/Run/LoggerHandler.php +++ b/src/Import/Run/LoggerHandler.php @@ -12,7 +12,7 @@ class LoggerHandler implements \Spameri\Elastic\Import\LoggerHandlerInterface public function __construct( - \Psr\Log\LoggerInterface $logger + \Psr\Log\LoggerInterface $logger, ) { $this->logger = $logger; diff --git a/src/Import/Run/Options.php b/src/Import/Run/Options.php index 572e4bab..eab755ab 100644 --- a/src/Import/Run/Options.php +++ b/src/Import/Run/Options.php @@ -12,7 +12,7 @@ class Options public function __construct( - int $lockDuration + int $lockDuration, ) { $this->lockDuration = $lockDuration; diff --git a/src/Import/RunHandlerInterface.php b/src/Import/RunHandlerInterface.php index fff41aea..0cd433ed 100644 --- a/src/Import/RunHandlerInterface.php +++ b/src/Import/RunHandlerInterface.php @@ -8,14 +8,14 @@ interface RunHandlerInterface public function advance( string $runName, \Symfony\Component\Console\Helper\ProgressBar $progressBar, - ?\Spameri\Elastic\Entity\AbstractImport $lastProcessed + \Spameri\Elastic\Entity\AbstractImport|null $lastProcessed, ): void; public function finish( string $runName, \Symfony\Component\Console\Helper\ProgressBar $progressBar, - ?\Spameri\Elastic\Entity\AbstractImport $lastProcessed + \Spameri\Elastic\Entity\AbstractImport|null $lastProcessed, ): void; } diff --git a/src/Import/SimpleRun.php b/src/Import/SimpleRun.php index e17d1501..057f3b16 100644 --- a/src/Import/SimpleRun.php +++ b/src/Import/SimpleRun.php @@ -13,7 +13,7 @@ public function __construct( \Spameri\Elastic\Import\DataProviderInterface $dataProvider, \Spameri\Elastic\Import\PrepareImportDataInterface $prepareImportData, \Spameri\Elastic\Import\DataImportInterface $dataImport, - \Spameri\Elastic\Import\AfterImport\NullAfterImport $afterImport + \Spameri\Elastic\Import\AfterImport\NullAfterImport $afterImport, ) { parent::__construct($logDir, $loggerHandler, $lock, $runHandler, $dataProvider, $prepareImportData, $dataImport, $afterImport); diff --git a/src/Model/AbstractBaseService.php b/src/Model/AbstractBaseService.php index d920b027..1fb22363 100644 --- a/src/Model/AbstractBaseService.php +++ b/src/Model/AbstractBaseService.php @@ -24,7 +24,7 @@ public function __construct( * @throws \Spameri\Elastic\Exception\DocumentInsertFailed */ public function insert( - \Spameri\Elastic\Entity\ElasticEntityInterface $entity + \Spameri\Elastic\Entity\ElasticEntityInterface $entity, ): string { return $this->insert->execute($entity, $this->index); @@ -35,7 +35,7 @@ public function insert( * @throws \Spameri\Elastic\Exception\DocumentNotFound */ public function get( - \Spameri\Elastic\Entity\Property\ElasticId $id + \Spameri\Elastic\Entity\Property\ElasticId $id, ): \Spameri\Elastic\Entity\ElasticEntityInterface { try { @@ -60,7 +60,7 @@ public function get( * @throws \Spameri\Elastic\Exception\ElasticSearch */ public function getBy( - \Spameri\ElasticQuery\ElasticQuery $elasticQuery + \Spameri\ElasticQuery\ElasticQuery $elasticQuery, ): \Spameri\Elastic\Entity\ElasticEntityInterface { try { @@ -84,7 +84,7 @@ public function getBy( * @throws \Spameri\Elastic\Exception\DocumentNotFound */ public function getAllBy( - \Spameri\ElasticQuery\ElasticQuery $elasticQuery + \Spameri\ElasticQuery\ElasticQuery $elasticQuery, ): \Spameri\Elastic\Entity\ElasticEntityCollectionInterface { try { @@ -113,7 +113,7 @@ public function getAllBy( return $this->collectionFactory->create( $this, [], - ... $entities + ... $entities, ); } @@ -125,7 +125,7 @@ public function createEmptyCollection(): \Spameri\Elastic\Entity\ElasticEntityCo public function delete( - \Spameri\Elastic\Entity\Property\ElasticIdInterface $id + \Spameri\Elastic\Entity\Property\ElasticIdInterface $id, ): bool { try { @@ -150,8 +150,8 @@ public function deleteReference( $elasticQuery->addMustQuery( new \Spameri\ElasticQuery\Query\Term( field: $field, - query: $entityToDelete->id()->value() - ) + query: $entityToDelete->id()->value(), + ), ); $collection = $service->getAllBy($elasticQuery); foreach ($collection as $entity) { @@ -164,7 +164,7 @@ public function deleteReference( } public function aggregate( - \Spameri\ElasticQuery\ElasticQuery $elasticQuery + \Spameri\ElasticQuery\ElasticQuery $elasticQuery, ): \Spameri\ElasticQuery\Response\ResultSearch { return $this->aggregate->execute($elasticQuery, $this->index); diff --git a/src/Model/Aggregate.php b/src/Model/Aggregate.php index ea128e93..b93fdd96 100644 --- a/src/Model/Aggregate.php +++ b/src/Model/Aggregate.php @@ -21,7 +21,7 @@ class Aggregate public function __construct( \Spameri\Elastic\ClientProvider $clientProvider, \Spameri\ElasticQuery\Response\ResultMapper $resultMapper, - \Spameri\Elastic\Model\VersionProvider $versionProvider + \Spameri\Elastic\Model\VersionProvider $versionProvider, ) { $this->clientProvider = $clientProvider; @@ -33,7 +33,7 @@ public function __construct( public function execute( \Spameri\ElasticQuery\ElasticQuery $elasticQuery, string $index, - ?string $type = NULL + string|null $type = NULL, ): \Spameri\ElasticQuery\Response\ResultSearch { if ($type === NULL) { @@ -50,11 +50,11 @@ public function execute( new \Spameri\ElasticQuery\Document( $index, new \Spameri\ElasticQuery\Document\Body\Plain( - $elasticQuery->toArray() + $elasticQuery->toArray(), ), - $type + $type, ) - )->toArray() + )->toArray(), ) ; diff --git a/src/Model/CreateIndex.php b/src/Model/CreateIndex.php index cccafd8d..2d91a5b6 100644 --- a/src/Model/CreateIndex.php +++ b/src/Model/CreateIndex.php @@ -18,7 +18,7 @@ public function __construct( \Spameri\Elastic\Provider\DateTimeProvider $dateTimeProvider, \Spameri\Elastic\Model\Indices\AddAlias $addAlias, \Spameri\Elastic\Model\Indices\Get $get, - \Spameri\Elastic\Model\Indices\Create $create + \Spameri\Elastic\Model\Indices\Create $create, ) { $this->dateTimeProvider = $dateTimeProvider; diff --git a/src/Model/Delete.php b/src/Model/Delete.php index bcf6b4b9..12d58d17 100644 --- a/src/Model/Delete.php +++ b/src/Model/Delete.php @@ -15,7 +15,7 @@ class Delete public function __construct( \Spameri\Elastic\ClientProvider $clientProvider, - VersionProvider $versionProvider + VersionProvider $versionProvider, ) { $this->clientProvider = $clientProvider; @@ -29,7 +29,7 @@ public function __construct( public function execute( \Spameri\Elastic\Entity\Property\ElasticIdInterface $id, string $index, - ?string $type = NULL + string|null $type = NULL, ): bool { if ($type === NULL) { @@ -47,10 +47,10 @@ public function execute( $index, NULL, $type, - $id->value() + $id->value(), ) ) - ->toArray() + ->toArray(), ) ; @@ -63,7 +63,7 @@ public function execute( ( new \Spameri\ElasticQuery\Document($index) ) - ->toArray() + ->toArray(), ) ; diff --git a/src/Model/DeleteIndex.php b/src/Model/DeleteIndex.php index 49d6f37a..b49f941a 100644 --- a/src/Model/DeleteIndex.php +++ b/src/Model/DeleteIndex.php @@ -12,7 +12,7 @@ class DeleteIndex public function __construct( \Spameri\Elastic\Model\Indices\Get $get, - \Spameri\Elastic\Model\Indices\Delete $delete + \Spameri\Elastic\Model\Indices\Delete $delete, ) { $this->get = $get; diff --git a/src/Model/DeleteMultiple.php b/src/Model/DeleteMultiple.php index 4c6dc1d3..7acbe866 100644 --- a/src/Model/DeleteMultiple.php +++ b/src/Model/DeleteMultiple.php @@ -21,7 +21,7 @@ class DeleteMultiple public function __construct( \Spameri\Elastic\ClientProvider $clientProvider, \Spameri\ElasticQuery\Response\ResultMapper $resultMapper, - VersionProvider $versionProvider + VersionProvider $versionProvider, ) { $this->clientProvider = $clientProvider; @@ -37,7 +37,7 @@ public function __construct( public function execute( \Spameri\Elastic\Entity\ElasticEntityCollectionInterface $entityCollection, string $index, - ?string $type = NULL + string|null $type = NULL, ): \Spameri\ElasticQuery\Response\ResultBulk { if ($type === NULL) { @@ -75,7 +75,7 @@ public function execute( ( new \Spameri\ElasticQuery\Document($index) ) - ->toArray() + ->toArray(), ) ; diff --git a/src/Model/DumpIndex.php b/src/Model/DumpIndex.php index 8ca1d3b0..2aad4a7e 100644 --- a/src/Model/DumpIndex.php +++ b/src/Model/DumpIndex.php @@ -22,7 +22,7 @@ class DumpIndex public function __construct( - \Spameri\Elastic\Model\Scroll $scroll + \Spameri\Elastic\Model\Scroll $scroll, ) { $this->bulkData = ''; @@ -31,7 +31,7 @@ public function __construct( public function setOutput( - \Symfony\Component\Console\Output\OutputInterface $output + \Symfony\Component\Console\Output\OutputInterface $output, ): void { $this->output = $output; @@ -41,7 +41,7 @@ public function setOutput( public function execute( string $index, string $filename, - ?string $type = NULL + string|null $type = NULL, ): void { if ( ! $type) { @@ -84,7 +84,7 @@ public function execute( public function processHit( - \Spameri\ElasticQuery\Response\Result\Hit $hit + \Spameri\ElasticQuery\Response\Result\Hit $hit, ): void { $bulkData = [ @@ -101,7 +101,7 @@ public function processHit( public function writeToFile( - string $filename + string $filename, ): void { @\file_put_contents($filename, $this->bulkData, \FILE_APPEND); diff --git a/src/Model/EntitySettingsLocator.php b/src/Model/EntitySettingsLocator.php index de4793bc..6a948245 100644 --- a/src/Model/EntitySettingsLocator.php +++ b/src/Model/EntitySettingsLocator.php @@ -9,7 +9,7 @@ class EntitySettingsLocator public function __construct( - \Nette\DI\Container $container + \Nette\DI\Container $container, ) { $this->container = $container; diff --git a/src/Model/Get.php b/src/Model/Get.php index 19e4fbca..70a9665a 100644 --- a/src/Model/Get.php +++ b/src/Model/Get.php @@ -21,7 +21,7 @@ class Get public function __construct( \Spameri\Elastic\ClientProvider $clientProvider, \Spameri\ElasticQuery\Response\ResultMapper $resultMapper, - VersionProvider $versionProvider + VersionProvider $versionProvider, ) { $this->clientProvider = $clientProvider; @@ -38,7 +38,7 @@ public function __construct( public function execute( \Spameri\Elastic\Entity\Property\ElasticId $id, string $index, - ?string $type = NULL + string|null $type = NULL, ): \Spameri\ElasticQuery\Response\ResultSingle { if ($type === NULL) { @@ -56,10 +56,10 @@ public function execute( $index, NULL, $type, - $id->value() + $id->value(), ) ) - ->toArray() + ->toArray(), ) ; diff --git a/src/Model/GetAllBy.php b/src/Model/GetAllBy.php index 3e80a97c..a11ab629 100644 --- a/src/Model/GetAllBy.php +++ b/src/Model/GetAllBy.php @@ -21,7 +21,7 @@ class GetAllBy public function __construct( \Spameri\Elastic\ClientProvider $clientProvider, \Spameri\ElasticQuery\Response\ResultMapper $resultMapper, - VersionProvider $versionProvider + VersionProvider $versionProvider, ) { $this->clientProvider = $clientProvider; @@ -33,7 +33,7 @@ public function __construct( public function execute( \Spameri\ElasticQuery\ElasticQuery $options, string $index, - ?string $type = NULL + string|null $type = NULL, ): \Spameri\ElasticQuery\Response\ResultSearch { if ($type === NULL) { @@ -50,10 +50,10 @@ public function execute( new \Spameri\ElasticQuery\Document( $index, new \Spameri\ElasticQuery\Document\Body\Plain($options->toArray()), - $type + $type, ) ) - ->toArray() + ->toArray(), ) ; diff --git a/src/Model/GetBy.php b/src/Model/GetBy.php index 35c68544..585e2403 100644 --- a/src/Model/GetBy.php +++ b/src/Model/GetBy.php @@ -21,7 +21,7 @@ class GetBy public function __construct( \Spameri\Elastic\ClientProvider $clientProvider, \Spameri\ElasticQuery\Response\ResultMapper $resultMapper, - VersionProvider $versionProvider + VersionProvider $versionProvider, ) { $this->clientProvider = $clientProvider; @@ -36,7 +36,7 @@ public function __construct( public function execute( \Spameri\ElasticQuery\ElasticQuery $options, string $index, - ?string $type = NULL + string|null $type = NULL, ): \Spameri\ElasticQuery\Response\ResultSearch { if ($type === NULL) { @@ -53,10 +53,10 @@ public function execute( new \Spameri\ElasticQuery\Document( $index, new \Spameri\ElasticQuery\Document\Body\Plain($options->toArray()), - $type + $type, ) ) - ->toArray() + ->toArray(), ) ; diff --git a/src/Model/Index.php b/src/Model/Index.php index 64a1bda1..9c8acd1d 100644 --- a/src/Model/Index.php +++ b/src/Model/Index.php @@ -12,7 +12,7 @@ class Index public function __construct( \Spameri\Elastic\ClientProvider $clientProvider, - \Spameri\Elastic\Model\VersionProvider $versionProvider + \Spameri\Elastic\Model\VersionProvider $versionProvider, ) { $this->clientProvider = $clientProvider; @@ -27,7 +27,7 @@ public function __construct( public function execute( array $data, string $index, - ?string $type = NULL + string|null $type = NULL, ): string { if ($type === NULL) { @@ -44,9 +44,9 @@ public function execute( new \Spameri\ElasticQuery\Document( $index, new \Spameri\ElasticQuery\Document\Body\Plain($data), - $type + $type, ) - )->toArray() + )->toArray(), ) ; @@ -59,7 +59,7 @@ public function execute( ( new \Spameri\ElasticQuery\Document($index) ) - ->toArray() + ->toArray(), ) ; diff --git a/src/Model/Indices/AddAlias.php b/src/Model/Indices/AddAlias.php index f9344db8..c5ecf353 100644 --- a/src/Model/Indices/AddAlias.php +++ b/src/Model/Indices/AddAlias.php @@ -9,7 +9,7 @@ class AddAlias public function __construct( - \Spameri\Elastic\ClientProvider $clientProvider + \Spameri\Elastic\ClientProvider $clientProvider, ) { $this->clientProvider = $clientProvider; @@ -23,9 +23,9 @@ public function execute(string $alias, string $index): array $this->clientProvider->client()->indices()->get( ( new \Spameri\ElasticQuery\Document( - $alias + $alias, ) - )->toArray() + )->toArray(), ) ; @@ -44,15 +44,15 @@ public function execute(string $alias, string $index): array 'alias' => $alias, ], ], - ] + ], ), NULL, NULL, [ 'name' => $index, - ] + ], ) - )->toArray() + )->toArray(), ) ; } diff --git a/src/Model/Indices/Close.php b/src/Model/Indices/Close.php index 5597a3f6..a569e34b 100644 --- a/src/Model/Indices/Close.php +++ b/src/Model/Indices/Close.php @@ -12,7 +12,7 @@ class Close public function __construct( - \Spameri\Elastic\ClientProvider $clientProvider + \Spameri\Elastic\ClientProvider $clientProvider, ) { $this->clientProvider = $clientProvider; @@ -20,14 +20,14 @@ public function __construct( public function execute( - string $index + string $index, ): bool { try { $result = $this->clientProvider->client()->indices()->close( ( new \Spameri\ElasticQuery\Document($index) - )->toArray() + )->toArray(), ) ; diff --git a/src/Model/Indices/Create.php b/src/Model/Indices/Create.php index 2a1a2863..1bf6d287 100644 --- a/src/Model/Indices/Create.php +++ b/src/Model/Indices/Create.php @@ -12,7 +12,7 @@ class Create public function __construct( \Spameri\Elastic\ClientProvider $clientProvider, - \Spameri\Elastic\Model\VersionProvider $versionProvider + \Spameri\Elastic\Model\VersionProvider $versionProvider, ) { $this->clientProvider = $clientProvider; @@ -27,7 +27,7 @@ public function __construct( public function execute( string $index, array $parameters, - ?string $type = NULL + string|null $type = NULL, ): array { if ($type === NULL) { @@ -56,9 +56,9 @@ public function execute( ( new \Spameri\ElasticQuery\Document( $index, - new \Spameri\ElasticQuery\Document\Body\Plain($parameters) + new \Spameri\ElasticQuery\Document\Body\Plain($parameters), ) - )->toArray() + )->toArray(), ) ; @@ -93,7 +93,7 @@ public function replaceKeywordInOlderVersion(array &$field): void \strtolower($field['type']), [ \Spameri\Elastic\Model\ValidateMapping\AllowedValues::TYPE_TEXT, \Spameri\Elastic\Model\ValidateMapping\AllowedValues::TYPE_KEYWORD, - ], TRUE + ], TRUE, ) ) { $field['type'] = \Spameri\Elastic\Model\ValidateMapping\AllowedValues::TYPE_STRING; diff --git a/src/Model/Indices/Delete.php b/src/Model/Indices/Delete.php index 12d9dde0..411d41fc 100644 --- a/src/Model/Indices/Delete.php +++ b/src/Model/Indices/Delete.php @@ -12,7 +12,7 @@ class Delete public function __construct( - \Spameri\Elastic\ClientProvider $clientProvider + \Spameri\Elastic\ClientProvider $clientProvider, ) { $this->clientProvider = $clientProvider; @@ -23,16 +23,16 @@ public function __construct( * @return array */ public function execute( - string $index + string $index, ): array { try { return $this->clientProvider->client()->indices()->delete( ( new \Spameri\ElasticQuery\Document( - $index + $index, ) - )->toArray() + )->toArray(), ) ; diff --git a/src/Model/Indices/Exists.php b/src/Model/Indices/Exists.php index 2a8f95cf..61216b70 100644 --- a/src/Model/Indices/Exists.php +++ b/src/Model/Indices/Exists.php @@ -9,7 +9,7 @@ class Exists public function __construct( - \Spameri\Elastic\ClientProvider $clientProvider + \Spameri\Elastic\ClientProvider $clientProvider, ) { $this->clientProvider = $clientProvider; @@ -17,16 +17,16 @@ public function __construct( public function execute( - string $index + string $index, ): bool { try { return $this->clientProvider->client()->indices()->exists( ( new \Spameri\ElasticQuery\Document( - $index + $index, ) - )->toArray() + )->toArray(), ) ; diff --git a/src/Model/Indices/Get.php b/src/Model/Indices/Get.php index f027a33f..146ab99d 100644 --- a/src/Model/Indices/Get.php +++ b/src/Model/Indices/Get.php @@ -12,7 +12,7 @@ class Get public function __construct( - \Spameri\Elastic\ClientProvider $clientProvider + \Spameri\Elastic\ClientProvider $clientProvider, ) { $this->clientProvider = $clientProvider; @@ -23,7 +23,7 @@ public function __construct( * @return array */ public function execute( - string $index + string $index, ): array { try { @@ -31,9 +31,9 @@ public function execute( $result = $this->clientProvider->client()->indices()->get( ( new \Spameri\ElasticQuery\Document( - $index + $index, ) - )->toArray() + )->toArray(), ) ; diff --git a/src/Model/Indices/GetFieldMapping.php b/src/Model/Indices/GetFieldMapping.php index cad9a7d0..fbb6df3e 100644 --- a/src/Model/Indices/GetFieldMapping.php +++ b/src/Model/Indices/GetFieldMapping.php @@ -9,7 +9,7 @@ class GetFieldMapping public function __construct( - \Spameri\Elastic\ClientProvider $clientProvider + \Spameri\Elastic\ClientProvider $clientProvider, ) { $this->clientProvider = $clientProvider; @@ -19,7 +19,7 @@ public function __construct( public function execute( string $index, string $type = '_doc', - array $fields = [] + array $fields = [], ): array { try { @@ -32,9 +32,9 @@ public function execute( NULL, [ 'fields' => $fields, - ] + ], ) - )->toArray() + )->toArray(), ) ; diff --git a/src/Model/Indices/GetMapping.php b/src/Model/Indices/GetMapping.php index ba3bbeac..ffebc13f 100644 --- a/src/Model/Indices/GetMapping.php +++ b/src/Model/Indices/GetMapping.php @@ -15,7 +15,7 @@ class GetMapping public function __construct( \Spameri\Elastic\ClientProvider $clientProvider, - \Spameri\Elastic\Model\VersionProvider $versionProvider + \Spameri\Elastic\Model\VersionProvider $versionProvider, ) { $this->clientProvider = $clientProvider; @@ -28,7 +28,7 @@ public function __construct( */ public function execute( string $index, - ?string $type = NULL + string|null $type = NULL, ): array { if ($type === NULL) { @@ -44,7 +44,7 @@ public function execute( new \Spameri\ElasticQuery\Document( $index, NULL, - $type + $type, ) )->toArray(); diff --git a/src/Model/Indices/MoveAlias.php b/src/Model/Indices/MoveAlias.php index 7925686c..34889ca5 100644 --- a/src/Model/Indices/MoveAlias.php +++ b/src/Model/Indices/MoveAlias.php @@ -9,7 +9,7 @@ class MoveAlias public function __construct( - \Spameri\Elastic\ClientProvider $clientProvider + \Spameri\Elastic\ClientProvider $clientProvider, ) { $this->clientProvider = $clientProvider; @@ -35,15 +35,15 @@ public function execute(string $alias, string $indexFrom, string $indexTo): arra 'alias' => $alias, ], ], - ] + ], ), NULL, NULL, [ 'name' => $indexTo, - ] + ], ) - )->toArray() + )->toArray(), ) ; diff --git a/src/Model/Indices/Open.php b/src/Model/Indices/Open.php index 2614d674..749f0f0d 100644 --- a/src/Model/Indices/Open.php +++ b/src/Model/Indices/Open.php @@ -12,7 +12,7 @@ class Open public function __construct( - \Spameri\Elastic\ClientProvider $clientProvider + \Spameri\Elastic\ClientProvider $clientProvider, ) { $this->clientProvider = $clientProvider; @@ -20,14 +20,14 @@ public function __construct( public function execute( - string $index + string $index, ): bool { try { $result = $this->clientProvider->client()->indices()->open( ( new \Spameri\ElasticQuery\Document($index) - )->toArray() + )->toArray(), ) ; diff --git a/src/Model/Indices/PutMapping.php b/src/Model/Indices/PutMapping.php index 9e56e430..20a9f2b9 100644 --- a/src/Model/Indices/PutMapping.php +++ b/src/Model/Indices/PutMapping.php @@ -15,7 +15,7 @@ class PutMapping public function __construct( \Spameri\Elastic\ClientProvider $clientProvider, - \Spameri\Elastic\Model\VersionProvider $versionProvider + \Spameri\Elastic\Model\VersionProvider $versionProvider, ) { $this->clientProvider = $clientProvider; @@ -31,7 +31,7 @@ public function execute( string $index, array $mapping, string $dynamic = 'false', - ?string $type = NULL + string|null $type = NULL, ): array { if ($type === NULL) { @@ -54,11 +54,11 @@ public function execute( [ 'properties' => $properties, 'dynamic' => $dynamic, - ] + ], ), - $type + $type, ) - )->toArray() + )->toArray(), ) ; diff --git a/src/Model/Indices/PutSettings.php b/src/Model/Indices/PutSettings.php index eef25fd8..e59677cb 100644 --- a/src/Model/Indices/PutSettings.php +++ b/src/Model/Indices/PutSettings.php @@ -12,7 +12,7 @@ class PutSettings public function __construct( - \Spameri\Elastic\ClientProvider $clientProvider + \Spameri\Elastic\ClientProvider $clientProvider, ) { $this->clientProvider = $clientProvider; @@ -25,7 +25,7 @@ public function __construct( */ public function execute( string $index, - array $settings + array $settings, ): array { try { @@ -33,9 +33,9 @@ public function execute( ( new \Spameri\ElasticQuery\Document( $index, - new \Spameri\ElasticQuery\Document\Body\Plain($settings) + new \Spameri\ElasticQuery\Document\Body\Plain($settings), ) - )->toArray() + )->toArray(), ) ; diff --git a/src/Model/Indices/RemoveAlias.php b/src/Model/Indices/RemoveAlias.php index d090d1c3..def191b7 100644 --- a/src/Model/Indices/RemoveAlias.php +++ b/src/Model/Indices/RemoveAlias.php @@ -9,7 +9,7 @@ class RemoveAlias public function __construct( - \Spameri\Elastic\ClientProvider $clientProvider + \Spameri\Elastic\ClientProvider $clientProvider, ) { $this->clientProvider = $clientProvider; @@ -31,15 +31,15 @@ public function execute(string $alias, string $index): array 'alias' => $alias, ], ], - ] + ], ), NULL, NULL, [ 'name' => $index, - ] + ], ) - )->toArray() + )->toArray(), ) ; diff --git a/src/Model/InitializeIndex.php b/src/Model/InitializeIndex.php index 17401e7c..0547dc55 100644 --- a/src/Model/InitializeIndex.php +++ b/src/Model/InitializeIndex.php @@ -18,7 +18,7 @@ public function __construct( \Spameri\Elastic\Provider\DateTimeProvider $dateTimeProvider, \Spameri\Elastic\Model\Indices\Get $get, \Spameri\Elastic\Model\Indices\Create $create, - \Spameri\Elastic\Model\Indices\AddAlias $addAlias + \Spameri\Elastic\Model\Indices\AddAlias $addAlias, ) { $this->dateTimeProvider = $dateTimeProvider; diff --git a/src/Model/Insert.php b/src/Model/Insert.php index 5b8ea860..5ae8b791 100644 --- a/src/Model/Insert.php +++ b/src/Model/Insert.php @@ -21,7 +21,7 @@ class Insert public function __construct( \Spameri\Elastic\Model\Insert\PrepareEntityArray $prepareEntityArray, \Spameri\Elastic\ClientProvider $clientProvider, - \Spameri\Elastic\Model\VersionProvider $versionProvider + \Spameri\Elastic\Model\VersionProvider $versionProvider, ) { $this->prepareEntityArray = $prepareEntityArray; @@ -37,7 +37,7 @@ public function __construct( public function execute( \Spameri\Elastic\Entity\ElasticEntityInterface $entity, string $index, - ?string $type = NULL + string|null $type = NULL, ): string { if ($type === NULL) { @@ -58,9 +58,9 @@ public function execute( $index, new \Spameri\ElasticQuery\Document\Body\Plain($entityArray), $type, - $entity->id()->value() + $entity->id()->value(), ) - )->toArray() + )->toArray(), ) ; @@ -73,7 +73,7 @@ public function execute( ( new \Spameri\ElasticQuery\Document($index) ) - ->toArray() + ->toArray(), ) ; diff --git a/src/Model/Insert/PrepareEntityArray.php b/src/Model/Insert/PrepareEntityArray.php index f04bda94..7561a503 100644 --- a/src/Model/Insert/PrepareEntityArray.php +++ b/src/Model/Insert/PrepareEntityArray.php @@ -14,7 +14,7 @@ class PrepareEntityArray public function __construct( - \Spameri\Elastic\Model\ServiceLocatorInterface $serviceLocator + \Spameri\Elastic\Model\ServiceLocatorInterface $serviceLocator, ) { $this->serviceLocator = $serviceLocator; @@ -25,7 +25,7 @@ public function __construct( * @return array */ public function prepare( - \Spameri\Elastic\Entity\ElasticEntityInterface $entity + \Spameri\Elastic\Entity\ElasticEntityInterface $entity, ): array { $this->insertedEntities = []; @@ -40,7 +40,7 @@ public function prepare( * @return array */ public function iterateVariables( - array $variables + array $variables, ): array { $preparedArray = []; @@ -125,12 +125,12 @@ public function iterateVariables( } else { if (\is_object($property)) { throw new \Spameri\Elastic\Exception\EntityIsNotValid( - 'Property ' . $key . ' in ' . \get_class($property) . ' is not supported.' + 'Property ' . $key . ' in ' . \get_class($property) . ' is not supported.', ); } throw new \Spameri\Elastic\Exception\EntityIsNotValid( - 'Property ' . $key . ' with value' . $property . ' is not supported.' + 'Property ' . $key . ' with value' . $property . ' is not supported.', ); } } diff --git a/src/Model/InsertMultiple.php b/src/Model/InsertMultiple.php index c38fd7d4..ea1c9551 100644 --- a/src/Model/InsertMultiple.php +++ b/src/Model/InsertMultiple.php @@ -27,7 +27,7 @@ public function __construct( \Spameri\Elastic\Model\Insert\PrepareEntityArray $prepareEntityArray, \Spameri\Elastic\ClientProvider $clientProvider, \Spameri\ElasticQuery\Response\ResultMapper $resultMapper, - \Spameri\Elastic\Model\VersionProvider $versionProvider + \Spameri\Elastic\Model\VersionProvider $versionProvider, ) { $this->prepareEntityArray = $prepareEntityArray; @@ -44,7 +44,7 @@ public function __construct( public function execute( \Spameri\Elastic\Entity\ElasticEntityCollectionInterface $entityCollection, string $index, - ?string $type = NULL + string|null $type = NULL, ): \Spameri\ElasticQuery\Response\ResultBulk { if ($type === NULL) { @@ -83,7 +83,7 @@ public function execute( ( new \Spameri\ElasticQuery\Document($index) ) - ->toArray() + ->toArray(), ) ; } catch (\Elasticsearch\Common\Exceptions\ElasticsearchException $exception) { diff --git a/src/Model/RestoreIndex.php b/src/Model/RestoreIndex.php index f540569f..29ff9c74 100644 --- a/src/Model/RestoreIndex.php +++ b/src/Model/RestoreIndex.php @@ -17,7 +17,7 @@ class RestoreIndex public function __construct( - \Spameri\Elastic\ClientProvider $clientProvider + \Spameri\Elastic\ClientProvider $clientProvider, ) { $this->clientProvider = $clientProvider; @@ -25,7 +25,7 @@ public function __construct( public function setOutput( - \Symfony\Component\Console\Output\OutputInterface $output + \Symfony\Component\Console\Output\OutputInterface $output, ): void { $this->output = $output; @@ -34,7 +34,7 @@ public function setOutput( public function execute( string $filename, - int $step + int $step, ): void { $this->output->writeln('Starting import.'); @@ -52,9 +52,9 @@ public function execute( $this->clientProvider->client()->bulk( ( new \Spameri\ElasticQuery\Document\Bulk( - [$bulkData] + [$bulkData], ) - )->toArray() + )->toArray(), ) ; $bulkData = ''; diff --git a/src/Model/Scroll.php b/src/Model/Scroll.php index a291f6fe..33eea623 100644 --- a/src/Model/Scroll.php +++ b/src/Model/Scroll.php @@ -21,7 +21,7 @@ class Scroll public function __construct( \Spameri\Elastic\ClientProvider $clientProvider, \Spameri\ElasticQuery\Response\ResultMapper $resultMapper, - VersionProvider $versionProvider + VersionProvider $versionProvider, ) { $this->clientProvider = $clientProvider; @@ -36,7 +36,7 @@ public function __construct( public function execute( \Spameri\ElasticQuery\ElasticQuery $elasticQuery, string $index, - ?string $type = NULL + string|null $type = NULL, ): \Spameri\ElasticQuery\Response\ResultSearch { if ($type === NULL) { @@ -58,10 +58,10 @@ public function execute( NULL, [ 'scroll' => $elasticQuery->options()->scroll(), - ] + ], ) ) - ->toArray() + ->toArray(), ) ; @@ -70,7 +70,7 @@ public function execute( } else { throw new \Spameri\Elastic\Exception\ScrollNotInitialized( - 'ElasticSearch did not return scroll id.' + 'ElasticSearch did not return scroll id.', ); } @@ -85,10 +85,10 @@ public function execute( [ 'scroll' => $elasticQuery->options()->scroll(), 'scroll_id' => $elasticQuery->options()->scrollId(), - ] + ], ) ) - ->toArray() + ->toArray(), ) ; } @@ -102,7 +102,7 @@ public function execute( public function closeScroll( - \Spameri\ElasticQuery\ElasticQuery $elasticQuery + \Spameri\ElasticQuery\ElasticQuery $elasticQuery, ): void { try { @@ -115,10 +115,10 @@ public function closeScroll( NULL, [ 'scroll_id' => $elasticQuery->options()->scrollId(), - ] + ], ) ) - ->toArray() + ->toArray(), ) ; diff --git a/src/Model/Search.php b/src/Model/Search.php index 66b95ba8..783eef7d 100644 --- a/src/Model/Search.php +++ b/src/Model/Search.php @@ -21,7 +21,7 @@ class Search public function __construct( \Spameri\Elastic\ClientProvider $clientProvider, \Spameri\ElasticQuery\Response\ResultMapper $resultMapper, - VersionProvider $versionProvider + VersionProvider $versionProvider, ) { $this->clientProvider = $clientProvider; @@ -36,7 +36,7 @@ public function __construct( public function execute( \Spameri\ElasticQuery\ElasticQuery $elasticQuery, string $index, - ?string $type = NULL + string|null $type = NULL, ): \Spameri\ElasticQuery\Response\ResultSearch { if ($type === NULL) { @@ -53,10 +53,10 @@ public function execute( new \Spameri\ElasticQuery\Document( $index, new \Spameri\ElasticQuery\Document\Body\Plain($elasticQuery->toArray()), - $type + $type, ) ) - ->toArray() + ->toArray(), ) ; diff --git a/src/Model/ServiceInterface.php b/src/Model/ServiceInterface.php index e7c2d84d..05fef17f 100644 --- a/src/Model/ServiceInterface.php +++ b/src/Model/ServiceInterface.php @@ -6,32 +6,32 @@ interface ServiceInterface { public function insert( - \Spameri\Elastic\Entity\ElasticEntityInterface $entity + \Spameri\Elastic\Entity\ElasticEntityInterface $entity, ): string; public function get( - \Spameri\Elastic\Entity\Property\ElasticId $id + \Spameri\Elastic\Entity\Property\ElasticId $id, ): \Spameri\Elastic\Entity\ElasticEntityInterface; public function getBy( - \Spameri\ElasticQuery\ElasticQuery $elasticQuery + \Spameri\ElasticQuery\ElasticQuery $elasticQuery, ): \Spameri\Elastic\Entity\ElasticEntityInterface; public function getAllBy( - \Spameri\ElasticQuery\ElasticQuery $elasticQuery + \Spameri\ElasticQuery\ElasticQuery $elasticQuery, ): \Spameri\Elastic\Entity\ElasticEntityCollectionInterface; public function delete( - \Spameri\Elastic\Entity\Property\ElasticIdInterface $id + \Spameri\Elastic\Entity\Property\ElasticIdInterface $id, ): bool; public function aggregate( - \Spameri\ElasticQuery\ElasticQuery $elasticQuery + \Spameri\ElasticQuery\ElasticQuery $elasticQuery, ): \Spameri\ElasticQuery\Response\ResultSearch; } diff --git a/src/Model/ServiceLocator.php b/src/Model/ServiceLocator.php index 137e24ec..b1b910ed 100644 --- a/src/Model/ServiceLocator.php +++ b/src/Model/ServiceLocator.php @@ -17,7 +17,7 @@ class ServiceLocator implements ServiceLocatorInterface public function __construct( - \Nette\DI\Container $container + \Nette\DI\Container $container, ) { $this->container = $container; @@ -26,7 +26,7 @@ public function __construct( public function locate( - \Spameri\Elastic\Entity\ElasticEntityInterface $entity + \Spameri\Elastic\Entity\ElasticEntityInterface $entity, ): \Spameri\Elastic\Model\ServiceInterface { $entityName = \get_class($entity); @@ -40,7 +40,7 @@ public function locate( public function locateByEntityClass( - string $entityClass + string $entityClass, ): \Spameri\Elastic\Model\ServiceInterface { $serviceName = \str_replace('Entity', 'Model', $entityClass . 'Service'); diff --git a/src/Model/ServiceLocatorInterface.php b/src/Model/ServiceLocatorInterface.php index 9fd86000..cdf30ea4 100644 --- a/src/Model/ServiceLocatorInterface.php +++ b/src/Model/ServiceLocatorInterface.php @@ -6,12 +6,12 @@ interface ServiceLocatorInterface { public function locate( - \Spameri\Elastic\Entity\ElasticEntityInterface $entity + \Spameri\Elastic\Entity\ElasticEntityInterface $entity, ): \Spameri\Elastic\Model\ServiceInterface; public function locateByEntityClass( - string $entityClass + string $entityClass, ): \Spameri\Elastic\Model\ServiceInterface; } diff --git a/src/Model/TypeToNewIndex/DocumentMigrateStatus.php b/src/Model/TypeToNewIndex/DocumentMigrateStatus.php index 4ffda67e..07163592 100644 --- a/src/Model/TypeToNewIndex/DocumentMigrateStatus.php +++ b/src/Model/TypeToNewIndex/DocumentMigrateStatus.php @@ -13,7 +13,7 @@ class DocumentMigrateStatus public function add( string $documentId, - int $version + int $version, ): void { $this->storage[$documentId] = $version; @@ -22,7 +22,7 @@ public function add( public function isChanged( string $documentId, - int $version + int $version, ): bool { if ( ! isset($this->storage[$documentId])) { diff --git a/src/Model/TypeToNewIndex/Migrate.php b/src/Model/TypeToNewIndex/Migrate.php index 3bcdf08e..33fdd0b8 100644 --- a/src/Model/TypeToNewIndex/Migrate.php +++ b/src/Model/TypeToNewIndex/Migrate.php @@ -83,7 +83,7 @@ public function __construct( \Spameri\Elastic\Model\Indices\Create $create, \Spameri\Elastic\Model\Indices\Get $indicesGet, \Spameri\Elastic\Model\Indices\AddAlias $addAlias, - \Spameri\Elastic\Model\VersionProvider $versionProvider + \Spameri\Elastic\Model\VersionProvider $versionProvider, ) { $this->documentMigrateStatus = $documentMigrateStatus; @@ -103,7 +103,7 @@ public function __construct( public function setOutput( - \Symfony\Component\Console\Output\OutputInterface $output + \Symfony\Component\Console\Output\OutputInterface $output, ): void { $this->output = $output; @@ -118,8 +118,8 @@ public function execute( string $typeFrom, string $indexTo, string $aliasTo, - ?string $typeTo, - bool $allowClose + string|null $typeTo, + bool $allowClose, ): void { // 1. Close index @@ -199,7 +199,7 @@ public function execute( $response = $this->get->execute( new \Spameri\Elastic\Entity\Property\ElasticId((string) $documentId), $indexFrom, - $typeFrom + $typeFrom, ); if ($this->documentMigrateStatus->isChanged((string) $documentId, $response->hit()->version())) { @@ -232,7 +232,7 @@ public function execute( // 9. Write info $this->output->writeln( 'Migration done. All old data remains in old index: ' . $indexFrom . ' with type: ' . $typeFrom - . ' it is recommended to manually delete data after this command' + . ' it is recommended to manually delete data after this command', ); // 10. Done @@ -244,10 +244,10 @@ public function execute( */ public function processHit( string $indexTo, - ?string $typeTo, + string|null $typeTo, string $indexFrom, \Spameri\ElasticQuery\Response\Result\Hit $hit, - bool $allowClose + bool $allowClose, ): void { if ($this->versionProvider->provide() >= \Spameri\ElasticQuery\Response\Result\Version::ELASTIC_VERSION_ID_7) { @@ -260,9 +260,9 @@ public function processHit( $indexTo, new \Spameri\ElasticQuery\Document\Body\Plain($hit->source()), $typeTo, - $hit->id() + $hit->id(), ) - )->toArray() + )->toArray(), ) ; @@ -273,7 +273,7 @@ public function processHit( if ($allowClose === TRUE) { $this->delete->execute( new \Spameri\Elastic\Entity\Property\ElasticId($hit->id()), - $indexFrom + $indexFrom, ); } } diff --git a/src/Model/VersionProvider.php b/src/Model/VersionProvider.php index 8ed8fc67..c2de2b96 100644 --- a/src/Model/VersionProvider.php +++ b/src/Model/VersionProvider.php @@ -9,7 +9,7 @@ class VersionProvider public function __construct( - int $versionNumber = \Spameri\ElasticQuery\Response\Result\Version::ELASTIC_VERSION_ID_7 + int $versionNumber = \Spameri\ElasticQuery\Response\Result\Version::ELASTIC_VERSION_ID_7, ) { $this->versionNumber = $versionNumber; diff --git a/src/Provider/DateTimeProvider.php b/src/Provider/DateTimeProvider.php index 8bc5d5f2..e125fff5 100644 --- a/src/Provider/DateTimeProvider.php +++ b/src/Provider/DateTimeProvider.php @@ -12,7 +12,7 @@ class DateTimeProvider public function __construct( - \DateTimeImmutable $constant + \DateTimeImmutable $constant, ) { $this->constant = $constant; diff --git a/src/Settings.php b/src/Settings.php index 08980cd4..04dbc8a3 100644 --- a/src/Settings.php +++ b/src/Settings.php @@ -27,7 +27,7 @@ class Settings public function __construct( string $host, int $port, - array $headers + array $headers, ) { $this->host = $host; diff --git a/src/Settings/NeonSettingsProvider.php b/src/Settings/NeonSettingsProvider.php index 36950cd5..dd8d104f 100644 --- a/src/Settings/NeonSettingsProvider.php +++ b/src/Settings/NeonSettingsProvider.php @@ -27,7 +27,7 @@ class NeonSettingsProvider implements \Spameri\Elastic\SettingsProviderInterface public function __construct( string $host, int $port, - array $headers = [] + array $headers = [], ) { $this->host = $host; @@ -41,7 +41,7 @@ public function provide(): \Spameri\Elastic\Settings return new \Spameri\Elastic\Settings( $this->host, $this->port, - $this->headers + $this->headers, ); } diff --git a/tests/SpameriTests/Elastic/Data/Entity/Person.php b/tests/SpameriTests/Elastic/Data/Entity/Person.php index c9ddb7a0..25ffbb02 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Person.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Person.php @@ -56,11 +56,11 @@ public function __construct( \SpameriTests\Elastic\Data\Entity\Video\Identification $identification, \SpameriTests\Elastic\Data\Entity\Property\Name $name, \SpameriTests\Elastic\Data\Entity\Property\Description $description, - ?\Spameri\Elastic\Entity\Property\Date $birth, - ?\Spameri\Elastic\Entity\Property\Date $death, + \Spameri\Elastic\Entity\Property\Date|null $birth, + \Spameri\Elastic\Entity\Property\Date|null $death, \SpameriTests\Elastic\Data\Entity\Property\Name $alias, \SpameriTests\Elastic\Data\Entity\Person\CharacterCollectionElastic $characters, - \SpameriTests\Elastic\Data\Entity\Person\JobCollectionElastic $jobs + \SpameriTests\Elastic\Data\Entity\Person\JobCollectionElastic $jobs, ) { $this->id = $id; @@ -117,25 +117,25 @@ public function changeDescription(\SpameriTests\Elastic\Data\Entity\Property\Des } - public function birth(): ?\Spameri\Elastic\Entity\Property\Date + public function birth(): \Spameri\Elastic\Entity\Property\Date|null { return $this->birth; } - public function setBirth(?\Spameri\Elastic\Entity\Property\Date $birth): void + public function setBirth(\Spameri\Elastic\Entity\Property\Date|null $birth): void { $this->birth = $birth; } - public function death(): ?\Spameri\Elastic\Entity\Property\Date + public function death(): \Spameri\Elastic\Entity\Property\Date|null { return $this->death; } - public function setDeath(?\Spameri\Elastic\Entity\Property\Date $death): void + public function setDeath(\Spameri\Elastic\Entity\Property\Date|null $death): void { $this->death = $death; } diff --git a/tests/SpameriTests/Elastic/Data/Entity/Person/Character.php b/tests/SpameriTests/Elastic/Data/Entity/Person/Character.php index 48fb5a9e..7e6c95f7 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Person/Character.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Person/Character.php @@ -38,11 +38,11 @@ class Character implements \Spameri\Elastic\Entity\EntityInterface public function __construct( \SpameriTests\Elastic\Data\Entity\Property\ImdbId $id, - ?\SpameriTests\Elastic\Data\Entity\Property\ImdbId $episode, + \SpameriTests\Elastic\Data\Entity\Property\ImdbId|null $episode, \SpameriTests\Elastic\Data\Entity\Property\Name $name, \SpameriTests\Elastic\Data\Entity\Property\Name $alias, \SpameriTests\Elastic\Data\Entity\Video\Identification $identification, - \SpameriTests\Elastic\Data\Entity\Property\Description $biography + \SpameriTests\Elastic\Data\Entity\Property\Description $biography, ) { $this->id = $id; @@ -72,13 +72,13 @@ public function id(): \SpameriTests\Elastic\Data\Entity\Property\ImdbId } - public function episode(): ?\SpameriTests\Elastic\Data\Entity\Property\ImdbId + public function episode(): \SpameriTests\Elastic\Data\Entity\Property\ImdbId|null { return $this->episode; } - public function setEpisode(?\SpameriTests\Elastic\Data\Entity\Property\ImdbId $episode): void + public function setEpisode(\SpameriTests\Elastic\Data\Entity\Property\ImdbId|null $episode): void { $this->episode = $episode; } diff --git a/tests/SpameriTests/Elastic/Data/Entity/Person/CharacterCollectionElastic.php b/tests/SpameriTests/Elastic/Data/Entity/Person/CharacterCollectionElastic.php index 0bb546d4..0f7f8e1c 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Person/CharacterCollectionElastic.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Person/CharacterCollectionElastic.php @@ -7,7 +7,7 @@ class CharacterCollectionElastic extends \Spameri\Elastic\Entity\Collection\Abst public function character( \SpameriTests\Elastic\Data\Entity\Property\ImdbId $id, - ?\SpameriTests\Elastic\Data\Entity\Property\ImdbId $episode = NULL + \SpameriTests\Elastic\Data\Entity\Property\ImdbId|null $episode = NULL, ): Character { /** @var \SpameriTests\Elastic\Data\Entity\Person\Character $character */ @@ -29,7 +29,7 @@ public function character( } throw new \Nette\InvalidStateException( - 'Character in video: ' . $id->value() . ' not found.' + 'Character in video: ' . $id->value() . ' not found.', ); } diff --git a/tests/SpameriTests/Elastic/Data/Entity/Person/Job.php b/tests/SpameriTests/Elastic/Data/Entity/Person/Job.php index a62c8e53..46656c91 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Person/Job.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Person/Job.php @@ -37,7 +37,7 @@ public function __construct( \SpameriTests\Elastic\Data\Entity\Property\ImdbId $id, \SpameriTests\Elastic\Data\Entity\Property\Name $name, \SpameriTests\Elastic\Data\Entity\Property\Description $description, - ?\SpameriTests\Elastic\Data\Entity\Property\ImdbId $episode + \SpameriTests\Elastic\Data\Entity\Property\ImdbId|null $episode, ) { $this->id = $id; @@ -89,7 +89,7 @@ public function id(): \SpameriTests\Elastic\Data\Entity\Property\ImdbId } - public function episode(): ?\SpameriTests\Elastic\Data\Entity\Property\ImdbId + public function episode(): \SpameriTests\Elastic\Data\Entity\Property\ImdbId|null { return $this->episode; } diff --git a/tests/SpameriTests/Elastic/Data/Entity/Person/JobCollectionElastic.php b/tests/SpameriTests/Elastic/Data/Entity/Person/JobCollectionElastic.php index 6391434c..5fee11eb 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Person/JobCollectionElastic.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Person/JobCollectionElastic.php @@ -7,7 +7,7 @@ class JobCollectionElastic extends \Spameri\Elastic\Entity\Collection\AbstractEn public function job( \SpameriTests\Elastic\Data\Entity\Property\ImdbId $imdbId, - ?\SpameriTests\Elastic\Data\Entity\Property\ImdbId $episode = NULL + \SpameriTests\Elastic\Data\Entity\Property\ImdbId|null $episode = NULL, ): Job { /** @var \SpameriTests\Elastic\Data\Entity\Person\Job $job */ @@ -29,7 +29,7 @@ public function job( } throw new \Nette\InvalidStateException( - 'Job in video: ' . $imdbId->value() . ' not found.' + 'Job in video: ' . $imdbId->value() . ' not found.', ); } diff --git a/tests/SpameriTests/Elastic/Data/Entity/Property/CountryShort.php b/tests/SpameriTests/Elastic/Data/Entity/Property/CountryShort.php index f8eaf388..d228c5ce 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Property/CountryShort.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Property/CountryShort.php @@ -12,7 +12,7 @@ class CountryShort implements \Spameri\Elastic\Entity\ValueInterface public function __construct( - ?string $value + string|null $value, ) { if ($value === '' || $value === NULL) { diff --git a/tests/SpameriTests/Elastic/Data/Entity/Property/Description.php b/tests/SpameriTests/Elastic/Data/Entity/Property/Description.php index e0bde170..ebe3e9f0 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Property/Description.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Property/Description.php @@ -12,14 +12,14 @@ class Description implements \Spameri\Elastic\Entity\ValueInterface public function __construct( - ?string $description + string|null $description, ) { $this->value = $description; } - public function value(): ?string + public function value(): string|null { return $this->value; } diff --git a/tests/SpameriTests/Elastic/Data/Entity/Property/ElasticIdCollection.php b/tests/SpameriTests/Elastic/Data/Entity/Property/ElasticIdCollection.php index 50176fbf..d80d6cfc 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Property/ElasticIdCollection.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Property/ElasticIdCollection.php @@ -12,7 +12,7 @@ class ElasticIdCollection implements \Spameri\Elastic\Entity\ValueCollectionInte public function __construct( - \Spameri\Elastic\Entity\Property\ElasticIdInterface ...$collection + \Spameri\Elastic\Entity\Property\ElasticIdInterface ...$collection, ) { $this->collection = $collection; diff --git a/tests/SpameriTests/Elastic/Data/Entity/Property/ImdbId.php b/tests/SpameriTests/Elastic/Data/Entity/Property/ImdbId.php index 06be7bb6..d634f20c 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Property/ImdbId.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Property/ImdbId.php @@ -12,7 +12,7 @@ class ImdbId implements \Spameri\Elastic\Entity\ValueInterface public function __construct( - int $value + int $value, ) { if ($value < 1) { diff --git a/tests/SpameriTests/Elastic/Data/Entity/Property/ImdbIdCollection.php b/tests/SpameriTests/Elastic/Data/Entity/Property/ImdbIdCollection.php index 2fcee027..356e1f8e 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Property/ImdbIdCollection.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Property/ImdbIdCollection.php @@ -12,7 +12,7 @@ class ImdbIdCollection implements \Spameri\Elastic\Entity\ValueCollectionInterfa public function __construct( - ImdbId ...$collection + ImdbId ...$collection, ) { $this->collection = []; @@ -23,7 +23,7 @@ public function __construct( public function add( - ImdbId $imdbId + ImdbId $imdbId, ): void { $this->collection[$imdbId->value()] = $imdbId; @@ -31,8 +31,8 @@ public function add( public function find( - ImdbId $imdbId - ): ?ImdbId + ImdbId $imdbId, + ): ImdbId|null { foreach ($this->collection as $value) { if ($imdbId->value() === $value->value()) { @@ -50,7 +50,7 @@ public function keys(): array } - public function first(): ?ImdbId + public function first(): ImdbId|null { $first = \reset($this->collection); diff --git a/tests/SpameriTests/Elastic/Data/Entity/Property/Name.php b/tests/SpameriTests/Elastic/Data/Entity/Property/Name.php index 43935a35..a0ceb943 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Property/Name.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Property/Name.php @@ -12,7 +12,7 @@ class Name implements \Spameri\Elastic\Entity\ValueInterface public function __construct( - string $value + string $value, ) { if (\strlen($value) <= 0) { diff --git a/tests/SpameriTests/Elastic/Data/Entity/Property/Text.php b/tests/SpameriTests/Elastic/Data/Entity/Property/Text.php index 746f3a3d..3746528d 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Property/Text.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Property/Text.php @@ -12,7 +12,7 @@ class Text implements \Spameri\Elastic\Entity\ValueInterface public function __construct( - string $value + string $value, ) { $this->value = $value; diff --git a/tests/SpameriTests/Elastic/Data/Entity/Property/Url.php b/tests/SpameriTests/Elastic/Data/Entity/Property/Url.php index 6e6ed6cf..0fa9c198 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Property/Url.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Property/Url.php @@ -12,7 +12,7 @@ class Url implements \Spameri\Elastic\Entity\ValueInterface public function __construct( - string $value + string $value, ) { if ( ! \Nette\Utils\Validators::isUrl($value)) { diff --git a/tests/SpameriTests/Elastic/Data/Entity/Property/Year.php b/tests/SpameriTests/Elastic/Data/Entity/Property/Year.php index ab721446..184eee57 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Property/Year.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Property/Year.php @@ -12,7 +12,7 @@ class Year implements \Spameri\Elastic\Entity\ValueInterface public function __construct( - int $year + int $year, ) { if ($year < 1800) { diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video.php b/tests/SpameriTests/Elastic/Data/Entity/Video.php index 0630b63c..da8a4f01 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video.php @@ -72,7 +72,7 @@ public function __construct( \SpameriTests\Elastic\Data\Entity\Video\HighLights $highLights, \SpameriTests\Elastic\Data\Entity\Video\Connections $connections, \SpameriTests\Elastic\Data\Entity\Video\People $people, - \SpameriTests\Elastic\Data\Entity\Video\SeasonCollection $season = NULL + \SpameriTests\Elastic\Data\Entity\Video\SeasonCollection $season = NULL, ) { $this->id = $id; diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Alias.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Alias.php index 9817eb21..d67e5187 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Alias.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Alias.php @@ -18,7 +18,7 @@ class Alias public function __construct( \SpameriTests\Elastic\Data\Entity\Property\Name $name, - \SpameriTests\Elastic\Data\Entity\Property\CountryShort $country + \SpameriTests\Elastic\Data\Entity\Property\CountryShort $country, ) { $this->name = $name; diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Connections.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Connections.php index baf723e7..1edf37c2 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Connections.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Connections.php @@ -78,7 +78,7 @@ public function __construct( \SpameriTests\Elastic\Data\Entity\Video\Connections\FollowsCollection $follows, \SpameriTests\Elastic\Data\Entity\Video\Connections\SpunOffCollection $spunOff, \SpameriTests\Elastic\Data\Entity\Video\Connections\VersionOfCollection $versionOf, - \SpameriTests\Elastic\Data\Entity\Video\Connections\EditedFromCollection $editedFrom + \SpameriTests\Elastic\Data\Entity\Video\Connections\EditedFromCollection $editedFrom, ) { $this->followed = $followed; diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/EditedFrom.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/EditedFrom.php index c3f70f6a..b65c1354 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/EditedFrom.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/EditedFrom.php @@ -18,7 +18,7 @@ class EditedFrom implements \Spameri\Elastic\Entity\EntityInterface public function __construct( \SpameriTests\Elastic\Data\Entity\Property\ImdbId $id, - \SpameriTests\Elastic\Data\Entity\Property\Text $note + \SpameriTests\Elastic\Data\Entity\Property\Text $note, ) { $this->id = $id; diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/EditedInto.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/EditedInto.php index 02b4b9b5..cd011ac8 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/EditedInto.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/EditedInto.php @@ -18,7 +18,7 @@ class EditedInto implements \Spameri\Elastic\Entity\EntityInterface public function __construct( \SpameriTests\Elastic\Data\Entity\Property\ImdbId $id, - \SpameriTests\Elastic\Data\Entity\Property\Text $note + \SpameriTests\Elastic\Data\Entity\Property\Text $note, ) { $this->id = $id; diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/Featured.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/Featured.php index 437e858e..a74d7e6f 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/Featured.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/Featured.php @@ -18,7 +18,7 @@ class Featured implements \Spameri\Elastic\Entity\EntityInterface public function __construct( \SpameriTests\Elastic\Data\Entity\Property\ImdbId $id, - \SpameriTests\Elastic\Data\Entity\Property\Text $note + \SpameriTests\Elastic\Data\Entity\Property\Text $note, ) { $this->id = $id; diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/Followed.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/Followed.php index 97a8ffb0..eff96461 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/Followed.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/Followed.php @@ -18,7 +18,7 @@ class Followed implements \Spameri\Elastic\Entity\EntityInterface public function __construct( \SpameriTests\Elastic\Data\Entity\Property\ImdbId $id, - \SpameriTests\Elastic\Data\Entity\Property\Text $note + \SpameriTests\Elastic\Data\Entity\Property\Text $note, ) { $this->id = $id; diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/Follows.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/Follows.php index 8aa71a32..c03b009d 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/Follows.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/Follows.php @@ -18,7 +18,7 @@ class Follows implements \Spameri\Elastic\Entity\EntityInterface public function __construct( \SpameriTests\Elastic\Data\Entity\Property\ImdbId $id, - \SpameriTests\Elastic\Data\Entity\Property\Text $note + \SpameriTests\Elastic\Data\Entity\Property\Text $note, ) { $this->id = $id; diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/Reference.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/Reference.php index b2eb392a..c0d9a7bb 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/Reference.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/Reference.php @@ -18,7 +18,7 @@ class Reference implements \Spameri\Elastic\Entity\EntityInterface public function __construct( \SpameriTests\Elastic\Data\Entity\Property\ImdbId $id, - \SpameriTests\Elastic\Data\Entity\Property\Text $note + \SpameriTests\Elastic\Data\Entity\Property\Text $note, ) { $this->id = $id; diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/Referenced.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/Referenced.php index a472b8b3..2347e4c8 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/Referenced.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/Referenced.php @@ -18,7 +18,7 @@ class Referenced implements \Spameri\Elastic\Entity\EntityInterface public function __construct( \SpameriTests\Elastic\Data\Entity\Property\ImdbId $id, - \SpameriTests\Elastic\Data\Entity\Property\Text $note + \SpameriTests\Elastic\Data\Entity\Property\Text $note, ) { $this->id = $id; diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/Remade.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/Remade.php index 3e3ca84a..4243296e 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/Remade.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/Remade.php @@ -18,7 +18,7 @@ class Remade implements \Spameri\Elastic\Entity\EntityInterface public function __construct( \SpameriTests\Elastic\Data\Entity\Property\ImdbId $id, - \SpameriTests\Elastic\Data\Entity\Property\Text $note + \SpameriTests\Elastic\Data\Entity\Property\Text $note, ) { $this->id = $id; diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/SpinOff.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/SpinOff.php index 811d0264..b16d3100 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/SpinOff.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/SpinOff.php @@ -18,7 +18,7 @@ class SpinOff implements \Spameri\Elastic\Entity\EntityInterface public function __construct( \SpameriTests\Elastic\Data\Entity\Property\ImdbId $id, - \SpameriTests\Elastic\Data\Entity\Property\Text $note + \SpameriTests\Elastic\Data\Entity\Property\Text $note, ) { $this->id = $id; diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/Spoofed.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/Spoofed.php index babf3df9..b848b4cd 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/Spoofed.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/Spoofed.php @@ -18,7 +18,7 @@ class Spoofed implements \Spameri\Elastic\Entity\EntityInterface public function __construct( \SpameriTests\Elastic\Data\Entity\Property\ImdbId $id, - \SpameriTests\Elastic\Data\Entity\Property\Text $note + \SpameriTests\Elastic\Data\Entity\Property\Text $note, ) { $this->id = $id; diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/SpunOff.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/SpunOff.php index b79ad4c0..b8053091 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/SpunOff.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/SpunOff.php @@ -18,7 +18,7 @@ class SpunOff implements \Spameri\Elastic\Entity\EntityInterface public function __construct( \SpameriTests\Elastic\Data\Entity\Property\ImdbId $id, - \SpameriTests\Elastic\Data\Entity\Property\Text $note + \SpameriTests\Elastic\Data\Entity\Property\Text $note, ) { $this->id = $id; diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/VersionOf.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/VersionOf.php index 485ee63c..ac5c4506 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/VersionOf.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Connections/VersionOf.php @@ -18,7 +18,7 @@ class VersionOf implements \Spameri\Elastic\Entity\EntityInterface public function __construct( \SpameriTests\Elastic\Data\Entity\Property\ImdbId $id, - \SpameriTests\Elastic\Data\Entity\Property\Text $note + \SpameriTests\Elastic\Data\Entity\Property\Text $note, ) { $this->id = $id; diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Details.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Details.php index a8a26210..292e1691 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Details.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Details.php @@ -30,7 +30,7 @@ public function __construct( \SpameriTests\Elastic\Data\Entity\Video\Details\GenreCollection $genres, \SpameriTests\Elastic\Data\Entity\Video\Details\AliasCollectionElastic $aliases, \SpameriTests\Elastic\Data\Entity\Video\Details\ReleaseCollectionElastic $releases, - \SpameriTests\Elastic\Data\Entity\Video\Details\Ratings $ratings + \SpameriTests\Elastic\Data\Entity\Video\Details\Ratings $ratings, ) { $this->genres = $genres; diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Details/Alias.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Details/Alias.php index f700ef5d..6411c6f0 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Details/Alias.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Details/Alias.php @@ -18,7 +18,7 @@ class Alias implements \Spameri\Elastic\Entity\EntityInterface public function __construct( \SpameriTests\Elastic\Data\Entity\Property\CountryShort $country, - \SpameriTests\Elastic\Data\Entity\Property\Text $name + \SpameriTests\Elastic\Data\Entity\Property\Text $name, ) { $this->country = $country; diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Details/Genre.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Details/Genre.php index 35782f0b..73fb4acf 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Details/Genre.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Details/Genre.php @@ -12,7 +12,7 @@ class Genre implements \Spameri\Elastic\Entity\ValueInterface public function __construct( - string $value + string $value, ) { if ($value === '') { diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Details/GenreCollection.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Details/GenreCollection.php index 6a3e790e..81591aee 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Details/GenreCollection.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Details/GenreCollection.php @@ -12,7 +12,7 @@ class GenreCollection implements \Spameri\Elastic\Entity\ValueCollectionInterfac public function __construct( - Genre ...$collection + Genre ...$collection, ) { $this->collection = []; @@ -29,7 +29,7 @@ public function getIterator(): \ArrayIterator public function add( - Genre $genre + Genre $genre, ): void { $this->collection[$genre->value()] = $genre; diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Details/Ratings.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Details/Ratings.php index 9dd030ad..8c5ba3a7 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Details/Ratings.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Details/Ratings.php @@ -12,7 +12,7 @@ class Ratings implements \Spameri\Elastic\Entity\EntityInterface public function __construct( - RatingsCount $imdbRatings + RatingsCount $imdbRatings, ) { $this->imdbRatings = $imdbRatings; diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Details/RatingsCount.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Details/RatingsCount.php index b8c39524..5df97f22 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Details/RatingsCount.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Details/RatingsCount.php @@ -12,7 +12,7 @@ class RatingsCount implements \Spameri\Elastic\Entity\ValueInterface public function __construct( - ?int $value + int|null $value, ) { if ($value === NULL) { diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Details/Release.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Details/Release.php index fd9b4b0f..4a568899 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Details/Release.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Details/Release.php @@ -24,7 +24,7 @@ class Release implements \Spameri\Elastic\Entity\EntityInterface public function __construct( \SpameriTests\Elastic\Data\Entity\Property\CountryShort $country, \Spameri\Elastic\Entity\Property\Date $date, - \SpameriTests\Elastic\Data\Entity\Property\Text $note + \SpameriTests\Elastic\Data\Entity\Property\Text $note, ) { $this->country = $country; diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/HighLights.php b/tests/SpameriTests/Elastic/Data/Entity/Video/HighLights.php index 5ee04f58..6e829bcb 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/HighLights.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/HighLights.php @@ -48,7 +48,7 @@ public function __construct( \SpameriTests\Elastic\Data\Entity\Video\HighLights\QuoteCollection $quotes, \SpameriTests\Elastic\Data\Entity\Video\HighLights\LocationCollection $locations, \SpameriTests\Elastic\Data\Entity\Video\HighLights\AlternateVersionCollection $alternateVersions, - \SpameriTests\Elastic\Data\Entity\Video\HighLights\CompanyCreditCollection $companyCredit + \SpameriTests\Elastic\Data\Entity\Video\HighLights\CompanyCreditCollection $companyCredit, ) { $this->trivia = $trivia; diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/HighLights/AlternateVersion.php b/tests/SpameriTests/Elastic/Data/Entity/Video/HighLights/AlternateVersion.php index 2b7d9915..22bf10cd 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/HighLights/AlternateVersion.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/HighLights/AlternateVersion.php @@ -12,7 +12,7 @@ class AlternateVersion implements \Spameri\Elastic\Entity\EntityInterface public function __construct( - \SpameriTests\Elastic\Data\Entity\Property\Text $text + \SpameriTests\Elastic\Data\Entity\Property\Text $text, ) { $this->text = $text; diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/HighLights/CompanyCredit.php b/tests/SpameriTests/Elastic/Data/Entity/Video/HighLights/CompanyCredit.php index 539862b1..7366605f 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/HighLights/CompanyCredit.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/HighLights/CompanyCredit.php @@ -18,7 +18,7 @@ class CompanyCredit implements \Spameri\Elastic\Entity\EntityInterface public function __construct( \SpameriTests\Elastic\Data\Entity\Property\Text $group, - \SpameriTests\Elastic\Data\Entity\Video\HighLights\CompanyCredit\CompanyCollection $company + \SpameriTests\Elastic\Data\Entity\Video\HighLights\CompanyCredit\CompanyCollection $company, ) { $this->group = $group; diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/HighLights/CompanyCredit/Company.php b/tests/SpameriTests/Elastic/Data/Entity/Video/HighLights/CompanyCredit/Company.php index 4ab33119..6daf7bbf 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/HighLights/CompanyCredit/Company.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/HighLights/CompanyCredit/Company.php @@ -24,7 +24,7 @@ class Company implements \Spameri\Elastic\Entity\EntityInterface public function __construct( \SpameriTests\Elastic\Data\Entity\Property\ImdbId $id, \SpameriTests\Elastic\Data\Entity\Property\Text $name, - \SpameriTests\Elastic\Data\Entity\Property\Text $note + \SpameriTests\Elastic\Data\Entity\Property\Text $note, ) { $this->id = $id; diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/HighLights/CrazyCredit.php b/tests/SpameriTests/Elastic/Data/Entity/Video/HighLights/CrazyCredit.php index d98fa95c..f1b74cf3 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/HighLights/CrazyCredit.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/HighLights/CrazyCredit.php @@ -24,7 +24,7 @@ class CrazyCredit implements \Spameri\Elastic\Entity\EntityInterface public function __construct( \SpameriTests\Elastic\Data\Entity\Property\ImdbId $id, \SpameriTests\Elastic\Data\Entity\Property\Text $text, - Relevancy $relevancy + Relevancy $relevancy, ) { $this->id = $id; diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/HighLights/Goof.php b/tests/SpameriTests/Elastic/Data/Entity/Video/HighLights/Goof.php index 513aa71c..3ed5be32 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/HighLights/Goof.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/HighLights/Goof.php @@ -24,7 +24,7 @@ class Goof implements \Spameri\Elastic\Entity\EntityInterface public function __construct( \SpameriTests\Elastic\Data\Entity\Property\ImdbId $id, \SpameriTests\Elastic\Data\Entity\Property\Text $text, - Relevancy $relevancy + Relevancy $relevancy, ) { $this->id = $id; diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/HighLights/Location.php b/tests/SpameriTests/Elastic/Data/Entity/Video/HighLights/Location.php index 6a0d8bc3..a7dd0c49 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/HighLights/Location.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/HighLights/Location.php @@ -18,7 +18,7 @@ class Location implements \Spameri\Elastic\Entity\EntityInterface public function __construct( \SpameriTests\Elastic\Data\Entity\Property\Text $name, - \SpameriTests\Elastic\Data\Entity\Property\Text $note + \SpameriTests\Elastic\Data\Entity\Property\Text $note, ) { $this->name = $name; diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/HighLights/Quote.php b/tests/SpameriTests/Elastic/Data/Entity/Video/HighLights/Quote.php index 6bf8393c..3e098f64 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/HighLights/Quote.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/HighLights/Quote.php @@ -24,7 +24,7 @@ class Quote implements \Spameri\Elastic\Entity\EntityInterface public function __construct( \SpameriTests\Elastic\Data\Entity\Property\ImdbId $id, \SpameriTests\Elastic\Data\Entity\Property\Text $text, - Relevancy $relevancy + Relevancy $relevancy, ) { $this->id = $id; diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/HighLights/Relevancy.php b/tests/SpameriTests/Elastic/Data/Entity/Video/HighLights/Relevancy.php index 3919e50e..2f3981c6 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/HighLights/Relevancy.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/HighLights/Relevancy.php @@ -12,7 +12,7 @@ class Relevancy implements \Spameri\Elastic\Entity\ValueInterface public function __construct( - int $value + int $value, ) { if ($value < 0) { diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/HighLights/Trivia.php b/tests/SpameriTests/Elastic/Data/Entity/Video/HighLights/Trivia.php index 2e57ab21..1e509b1b 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/HighLights/Trivia.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/HighLights/Trivia.php @@ -24,7 +24,7 @@ class Trivia implements \Spameri\Elastic\Entity\EntityInterface public function __construct( \SpameriTests\Elastic\Data\Entity\Property\ImdbId $id, \SpameriTests\Elastic\Data\Entity\Property\Text $text, - Relevancy $relevancy + Relevancy $relevancy, ) { $this->id = $id; diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Identification.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Identification.php index 7bdd3b50..dc8cfb19 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Identification.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Identification.php @@ -7,14 +7,14 @@ class Identification implements \Spameri\Elastic\Entity\EntityInterface /** * @var \SpameriTests\Elastic\Data\Entity\Property\ImdbId - * @type(keyword) - * @analyzer(keyword) + * @type(\SpameriTests\Elastic\Data\Entity\Video\keyword) + * @analyzer(\SpameriTests\Elastic\Data\Entity\Video\keyword) */ private $imdb; public function __construct( - \SpameriTests\Elastic\Data\Entity\Property\ImdbId $imdb + \SpameriTests\Elastic\Data\Entity\Property\ImdbId $imdb, ) { $this->imdb = $imdb; diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/People.php b/tests/SpameriTests/Elastic/Data/Entity/Video/People.php index 7d945c8f..377c7350 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/People.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/People.php @@ -6,8 +6,8 @@ class People extends \Spameri\Elastic\Entity\Collection\AbstractElasticEntityCol { public function personByImdb( - \SpameriTests\Elastic\Data\Entity\Property\ImdbId $imdb - ): ?\SpameriTests\Elastic\Data\Entity\Person + \SpameriTests\Elastic\Data\Entity\Property\ImdbId $imdb, + ): \SpameriTests\Elastic\Data\Entity\Person|null { /** @var \SpameriTests\Elastic\Data\Entity\Person $entity */ foreach ($this->collection() as $entity) { diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Season.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Season.php index facbf275..b07f6264 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Season.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Season.php @@ -18,7 +18,7 @@ class Season implements \Spameri\Elastic\Entity\EntityInterface public function __construct( \SpameriTests\Elastic\Data\Entity\Property\ImdbId $number, - \SpameriTests\Elastic\Data\Entity\Video\Season\EpisodeCollection $episodes + \SpameriTests\Elastic\Data\Entity\Video\Season\EpisodeCollection $episodes, ) { $this->number = $number; diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Season/Episode.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Season/Episode.php index 7eaed63e..90bd397a 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Season/Episode.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Season/Episode.php @@ -30,7 +30,7 @@ public function __construct( \SpameriTests\Elastic\Data\Entity\Property\ImdbId $id, \SpameriTests\Elastic\Data\Entity\Property\ImdbId $number, \SpameriTests\Elastic\Data\Entity\Property\Name $name, - \SpameriTests\Elastic\Data\Entity\Property\Description $description + \SpameriTests\Elastic\Data\Entity\Property\Description $description, ) { $this->id = $id; diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Season/EpisodeCollection.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Season/EpisodeCollection.php index 4ed713ed..023ef435 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Season/EpisodeCollection.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Season/EpisodeCollection.php @@ -5,7 +5,7 @@ class EpisodeCollection extends \Spameri\Elastic\Entity\Collection\AbstractEntityCollection { - public function episode(\SpameriTests\Elastic\Data\Entity\Property\ImdbId $id): ?Episode + public function episode(\SpameriTests\Elastic\Data\Entity\Property\ImdbId $id): Episode|null { /** @var \SpameriTests\Elastic\Data\Entity\Video\Season\Episode $episode */ foreach ($this->collection() as $episode) { diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/SeasonCollection.php b/tests/SpameriTests/Elastic/Data/Entity/Video/SeasonCollection.php index 4b04e24d..7754e782 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/SeasonCollection.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/SeasonCollection.php @@ -5,7 +5,7 @@ class SeasonCollection extends \Spameri\Elastic\Entity\Collection\AbstractEntityCollection { - public function season(\SpameriTests\Elastic\Data\Entity\Property\ImdbId $id): ?Season + public function season(\SpameriTests\Elastic\Data\Entity\Property\ImdbId $id): Season|null { /** @var \SpameriTests\Elastic\Data\Entity\Video\Season $season */ foreach ($this->collection() as $season) { diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Story.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Story.php index d56ce42d..90238dbc 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Story.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Story.php @@ -36,7 +36,7 @@ public function __construct( \SpameriTests\Elastic\Data\Entity\Video\Story\TagLineCollection $tagLines, \SpameriTests\Elastic\Data\Entity\Video\Story\PlotSummaryCollection $plots, \SpameriTests\Elastic\Data\Entity\Video\Story\KeyWordCollection $keyWord, - ?\SpameriTests\Elastic\Data\Entity\Video\Story\Synopsis $synopsis = NULL + \SpameriTests\Elastic\Data\Entity\Video\Story\Synopsis|null $synopsis = NULL, ) { $this->description = $description; @@ -66,7 +66,7 @@ public function description(): \SpameriTests\Elastic\Data\Entity\Property\Descri public function changeDescription( - \SpameriTests\Elastic\Data\Entity\Property\Description $description + \SpameriTests\Elastic\Data\Entity\Property\Description $description, ): void { $this->description = $description; @@ -86,14 +86,14 @@ public function plots(): \SpameriTests\Elastic\Data\Entity\Video\Story\PlotSumma public function setSynopsis( - ?\SpameriTests\Elastic\Data\Entity\Video\Story\Synopsis $synopsis + \SpameriTests\Elastic\Data\Entity\Video\Story\Synopsis|null $synopsis, ): void { $this->synopsis = $synopsis; } - public function synopsis(): ?\SpameriTests\Elastic\Data\Entity\Video\Story\Synopsis + public function synopsis(): \SpameriTests\Elastic\Data\Entity\Video\Story\Synopsis|null { return $this->synopsis; } diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Story/KeyWord.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Story/KeyWord.php index fd6144c5..b3dbfaf9 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Story/KeyWord.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Story/KeyWord.php @@ -12,7 +12,7 @@ class KeyWord implements \Spameri\Elastic\Entity\ValueInterface public function __construct( - string $value + string $value, ) { if ($value === '') { diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Story/KeyWordCollection.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Story/KeyWordCollection.php index cb214cdd..4dcaa993 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Story/KeyWordCollection.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Story/KeyWordCollection.php @@ -12,7 +12,7 @@ class KeyWordCollection implements \Spameri\Elastic\Entity\ValueCollectionInterf public function __construct( - KeyWord ...$entities + KeyWord ...$entities, ) { $this->collection = []; @@ -23,7 +23,7 @@ public function __construct( public function add( - KeyWord $keyWord + KeyWord $keyWord, ): void { $this->collection[$keyWord->value()] = $keyWord; diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Story/PlotSummary.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Story/PlotSummary.php index f1472b0e..5906681e 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Story/PlotSummary.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Story/PlotSummary.php @@ -12,7 +12,7 @@ class PlotSummary implements \Spameri\Elastic\Entity\ValueInterface public function __construct( - string $plot + string $plot, ) { if ($plot === '') { diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Story/PlotSummaryCollection.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Story/PlotSummaryCollection.php index 2e90d2fc..5e867f88 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Story/PlotSummaryCollection.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Story/PlotSummaryCollection.php @@ -12,7 +12,7 @@ class PlotSummaryCollection implements \Spameri\Elastic\Entity\ValueCollectionIn public function __construct( - PlotSummary ...$collection + PlotSummary ...$collection, ) { $this->collection = []; @@ -23,14 +23,14 @@ public function __construct( public function add( - PlotSummary $plotSummary + PlotSummary $plotSummary, ): void { $this->collection[\md5($plotSummary->value())] = $plotSummary; } - public function first(): ?PlotSummary + public function first(): PlotSummary|null { $first = \reset($this->collection); diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Story/Synopsis.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Story/Synopsis.php index 2b79c531..f24e2498 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Story/Synopsis.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Story/Synopsis.php @@ -12,14 +12,14 @@ class Synopsis implements \Spameri\Elastic\Entity\ValueInterface public function __construct( - ?string $value + string|null $value, ) { $this->value = $value; } - public function value(): ?string + public function value(): string|null { return $this->value; } diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Story/TagLine.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Story/TagLine.php index 2717dfde..f19f0381 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Story/TagLine.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Story/TagLine.php @@ -12,7 +12,7 @@ class TagLine implements \Spameri\Elastic\Entity\ValueInterface public function __construct( - string $tagLine + string $tagLine, ) { if ($tagLine === '') { diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Story/TagLineCollection.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Story/TagLineCollection.php index 20d55480..35488cab 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Story/TagLineCollection.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Story/TagLineCollection.php @@ -12,7 +12,7 @@ class TagLineCollection implements \Spameri\Elastic\Entity\ValueCollectionInterf public function __construct( - \SpameriTests\Elastic\Data\Entity\Video\Story\TagLine ...$collection + \SpameriTests\Elastic\Data\Entity\Video\Story\TagLine ...$collection, ) { $this->collection = []; @@ -23,7 +23,7 @@ public function __construct( public function add( - \SpameriTests\Elastic\Data\Entity\Video\Story\TagLine $tagLine + \SpameriTests\Elastic\Data\Entity\Video\Story\TagLine $tagLine, ): void { $this->collection[\md5($tagLine->value())] = $tagLine; diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Technical.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Technical.php index bea2a0ac..e39c390f 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Technical.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Technical.php @@ -52,15 +52,15 @@ class Technical implements \Spameri\Elastic\Entity\EntityInterface public function __construct( - ?\SpameriTests\Elastic\Data\Entity\Video\Technical\Camera $camera = NULL, - ?\SpameriTests\Elastic\Data\Entity\Video\Technical\Runtime $runtime = NULL, - ?\SpameriTests\Elastic\Data\Entity\Video\Technical\Color $color = NULL, - ?\SpameriTests\Elastic\Data\Entity\Video\Technical\Ratio $ratio = NULL, - ?\SpameriTests\Elastic\Data\Entity\Video\Technical\Laboratory $laboratory = NULL, - ?\SpameriTests\Elastic\Data\Entity\Video\Technical\FilmLength $filmLength = NULL, - ?\SpameriTests\Elastic\Data\Entity\Video\Technical\NegativeFormat $negativeFormat = NULL, - ?\SpameriTests\Elastic\Data\Entity\Video\Technical\CineProcess $cineProcess = NULL, - ?\SpameriTests\Elastic\Data\Entity\Video\Technical\Printed $printed = NULL + \SpameriTests\Elastic\Data\Entity\Video\Technical\Camera|null $camera = NULL, + \SpameriTests\Elastic\Data\Entity\Video\Technical\Runtime|null $runtime = NULL, + \SpameriTests\Elastic\Data\Entity\Video\Technical\Color|null $color = NULL, + \SpameriTests\Elastic\Data\Entity\Video\Technical\Ratio|null $ratio = NULL, + \SpameriTests\Elastic\Data\Entity\Video\Technical\Laboratory|null $laboratory = NULL, + \SpameriTests\Elastic\Data\Entity\Video\Technical\FilmLength|null $filmLength = NULL, + \SpameriTests\Elastic\Data\Entity\Video\Technical\NegativeFormat|null $negativeFormat = NULL, + \SpameriTests\Elastic\Data\Entity\Video\Technical\CineProcess|null $cineProcess = NULL, + \SpameriTests\Elastic\Data\Entity\Video\Technical\Printed|null $printed = NULL, ) { $this->camera = $camera; @@ -93,55 +93,55 @@ public function key(): string } - public function camera(): ?\SpameriTests\Elastic\Data\Entity\Video\Technical\Camera + public function camera(): \SpameriTests\Elastic\Data\Entity\Video\Technical\Camera|null { return $this->camera; } - public function runtime(): ?\SpameriTests\Elastic\Data\Entity\Video\Technical\Runtime + public function runtime(): \SpameriTests\Elastic\Data\Entity\Video\Technical\Runtime|null { return $this->runtime; } - public function color(): ?\SpameriTests\Elastic\Data\Entity\Video\Technical\Color + public function color(): \SpameriTests\Elastic\Data\Entity\Video\Technical\Color|null { return $this->color; } - public function ratio(): ?\SpameriTests\Elastic\Data\Entity\Video\Technical\Ratio + public function ratio(): \SpameriTests\Elastic\Data\Entity\Video\Technical\Ratio|null { return $this->ratio; } - public function laboratory(): ?\SpameriTests\Elastic\Data\Entity\Video\Technical\Laboratory + public function laboratory(): \SpameriTests\Elastic\Data\Entity\Video\Technical\Laboratory|null { return $this->laboratory; } - public function filmLength(): ?\SpameriTests\Elastic\Data\Entity\Video\Technical\FilmLength + public function filmLength(): \SpameriTests\Elastic\Data\Entity\Video\Technical\FilmLength|null { return $this->filmLength; } - public function negativeFormat(): ?\SpameriTests\Elastic\Data\Entity\Video\Technical\NegativeFormat + public function negativeFormat(): \SpameriTests\Elastic\Data\Entity\Video\Technical\NegativeFormat|null { return $this->negativeFormat; } - public function cineProcess(): ?\SpameriTests\Elastic\Data\Entity\Video\Technical\CineProcess + public function cineProcess(): \SpameriTests\Elastic\Data\Entity\Video\Technical\CineProcess|null { return $this->cineProcess; } - public function printed(): ?\SpameriTests\Elastic\Data\Entity\Video\Technical\Printed + public function printed(): \SpameriTests\Elastic\Data\Entity\Video\Technical\Printed|null { return $this->printed; } diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Technical/Camera.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Technical/Camera.php index c0e70633..a1890cdb 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Technical/Camera.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Technical/Camera.php @@ -12,7 +12,7 @@ class Camera implements \Spameri\Elastic\Entity\ValueInterface public function __construct( - ?string $value + string|null $value, ) { if ($value !== NULL && \strlen($value) > 255) { @@ -23,7 +23,7 @@ public function __construct( } - public function value(): ?string + public function value(): string|null { return $this->value; } diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Technical/CineProcess.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Technical/CineProcess.php index 1c58bfd5..c01ca58d 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Technical/CineProcess.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Technical/CineProcess.php @@ -12,7 +12,7 @@ class CineProcess implements \Spameri\Elastic\Entity\ValueInterface public function __construct( - ?string $value + string|null $value, ) { if ($value !== NULL && \strlen($value) > 255) { @@ -23,7 +23,7 @@ public function __construct( } - public function value(): ?string + public function value(): string|null { return $this->value; } diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Technical/Color.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Technical/Color.php index 62f3905e..f5bbb6c9 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Technical/Color.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Technical/Color.php @@ -12,7 +12,7 @@ class Color implements \Spameri\Elastic\Entity\ValueInterface public function __construct( - ?string $value + string|null $value, ) { if ($value !== NULL && \strlen($value) > 255) { @@ -23,7 +23,7 @@ public function __construct( } - public function value(): ?string + public function value(): string|null { return $this->value; } diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Technical/FilmLength.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Technical/FilmLength.php index 05eb138c..8beb5414 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Technical/FilmLength.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Technical/FilmLength.php @@ -12,7 +12,7 @@ class FilmLength implements \Spameri\Elastic\Entity\ValueInterface public function __construct( - ?string $value + string|null $value, ) { if ($value !== NULL && \strlen($value) > 255) { @@ -23,7 +23,7 @@ public function __construct( } - public function value(): ?string + public function value(): string|null { return $this->value; } diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Technical/Laboratory.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Technical/Laboratory.php index 67e74e55..e52a4059 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Technical/Laboratory.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Technical/Laboratory.php @@ -12,7 +12,7 @@ class Laboratory implements \Spameri\Elastic\Entity\ValueInterface public function __construct( - ?string $value + string|null $value, ) { if ($value !== NULL && \strlen($value) > 255) { @@ -23,7 +23,7 @@ public function __construct( } - public function value(): ?string + public function value(): string|null { return $this->value; } diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Technical/NegativeFormat.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Technical/NegativeFormat.php index 3a514601..0fcd64ec 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Technical/NegativeFormat.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Technical/NegativeFormat.php @@ -12,7 +12,7 @@ class NegativeFormat implements \Spameri\Elastic\Entity\ValueInterface public function __construct( - ?string $value + string|null $value, ) { if ($value !== NULL && \strlen($value) > 255) { @@ -23,7 +23,7 @@ public function __construct( } - public function value(): ?string + public function value(): string|null { return $this->value; } diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Technical/Printed.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Technical/Printed.php index 962f997b..3047f50e 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Technical/Printed.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Technical/Printed.php @@ -12,7 +12,7 @@ class Printed implements \Spameri\Elastic\Entity\ValueInterface public function __construct( - ?string $value + string|null $value, ) { if ($value !== NULL && \strlen($value) > 255) { @@ -23,7 +23,7 @@ public function __construct( } - public function value(): ?string + public function value(): string|null { return $this->value; } diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Technical/Ratio.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Technical/Ratio.php index e58389a8..8351952e 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Technical/Ratio.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Technical/Ratio.php @@ -12,7 +12,7 @@ class Ratio implements \Spameri\Elastic\Entity\ValueInterface public function __construct( - ?string $value + string|null $value, ) { if ($value !== NULL && \strlen($value) > 255) { @@ -23,7 +23,7 @@ public function __construct( } - public function value(): ?string + public function value(): string|null { return $this->value; } diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Technical/Runtime.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Technical/Runtime.php index 7e02c58f..b2f5c4b3 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Technical/Runtime.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Technical/Runtime.php @@ -12,7 +12,7 @@ class Runtime implements \Spameri\Elastic\Entity\ValueInterface public function __construct( - ?int $value + int|null $value, ) { if ($value < 0) { @@ -26,7 +26,7 @@ public function __construct( } - public function value(): ?int + public function value(): int|null { return $this->value; } diff --git a/tests/SpameriTests/Elastic/Data/Model/PersonCollectionFactory.php b/tests/SpameriTests/Elastic/Data/Model/PersonCollectionFactory.php index e9e55f87..a29f571f 100644 --- a/tests/SpameriTests/Elastic/Data/Model/PersonCollectionFactory.php +++ b/tests/SpameriTests/Elastic/Data/Model/PersonCollectionFactory.php @@ -12,13 +12,13 @@ class PersonCollectionFactory implements \Spameri\Elastic\Factory\CollectionFact public function create( \Spameri\Elastic\Model\ServiceInterface $service, array $elasticIds = [], - \Spameri\Elastic\Entity\ElasticEntityInterface ...$entityCollection + \Spameri\Elastic\Entity\ElasticEntityInterface ...$entityCollection, ): \Spameri\Elastic\Entity\ElasticEntityCollectionInterface { return new \SpameriTests\Elastic\Data\Model\PersonCollection( $service, $elasticIds, - ... $entityCollection + ... $entityCollection, ); } diff --git a/tests/SpameriTests/Elastic/Data/Model/PersonFactory.php b/tests/SpameriTests/Elastic/Data/Model/PersonFactory.php index 065acef4..4ce10283 100644 --- a/tests/SpameriTests/Elastic/Data/Model/PersonFactory.php +++ b/tests/SpameriTests/Elastic/Data/Model/PersonFactory.php @@ -13,7 +13,7 @@ public function create(\Spameri\ElasticQuery\Response\Result\Hit $hit): \Generat yield new \SpameriTests\Elastic\Data\Entity\Person( new \Spameri\Elastic\Entity\Property\ElasticId($hit->id()), new \SpameriTests\Elastic\Data\Entity\Video\Identification( - $hit->getValue('identification.imdb') + $hit->getValue('identification.imdb'), ), new \SpameriTests\Elastic\Data\Entity\Property\Name($hit->getValue('name')), new \SpameriTests\Elastic\Data\Entity\Property\Description($hit->getValue('description')), @@ -21,7 +21,7 @@ public function create(\Spameri\ElasticQuery\Response\Result\Hit $hit): \Generat new \Spameri\Elastic\Entity\Property\Date($hit->getValue('death')), new \SpameriTests\Elastic\Data\Entity\Property\Name($hit->getValue('alias')), new \SpameriTests\Elastic\Data\Entity\Person\CharacterCollectionElastic(), - new \SpameriTests\Elastic\Data\Entity\Person\JobCollectionElastic() + new \SpameriTests\Elastic\Data\Entity\Person\JobCollectionElastic(), ); } diff --git a/tests/SpameriTests/Elastic/Data/Model/PersonMapping.php b/tests/SpameriTests/Elastic/Data/Model/PersonMapping.php index 54321910..621b3d13 100644 --- a/tests/SpameriTests/Elastic/Data/Model/PersonMapping.php +++ b/tests/SpameriTests/Elastic/Data/Model/PersonMapping.php @@ -9,7 +9,7 @@ class PersonMapping implements \Spameri\Elastic\Settings\IndexConfigInterface public function __construct( - string $index + string $index, ) { $this->index = $index; diff --git a/tests/SpameriTests/Elastic/Data/Model/PersonService.php b/tests/SpameriTests/Elastic/Data/Model/PersonService.php index f58d1cfc..4016b792 100644 --- a/tests/SpameriTests/Elastic/Data/Model/PersonService.php +++ b/tests/SpameriTests/Elastic/Data/Model/PersonService.php @@ -10,7 +10,7 @@ class PersonService extends \Spameri\Elastic\Model\AbstractBaseService * @return string */ public function insert( - \Spameri\Elastic\Entity\ElasticEntityInterface $entity + \Spameri\Elastic\Entity\ElasticEntityInterface $entity, ): string { return parent::insert($entity); @@ -22,7 +22,7 @@ public function insert( * @return \Spameri\Elastic\Entity\ElasticEntityInterface|\SpameriTests\Elastic\Data\Entity\Person */ public function get( - \Spameri\Elastic\Entity\Property\ElasticId $id + \Spameri\Elastic\Entity\Property\ElasticId $id, ): \Spameri\Elastic\Entity\ElasticEntityInterface { return parent::get($id); @@ -34,7 +34,7 @@ public function get( * @return \Spameri\Elastic\Entity\ElasticEntityInterface|\SpameriTests\Elastic\Data\Entity\Person */ public function getBy( - \Spameri\ElasticQuery\ElasticQuery $elasticQuery + \Spameri\ElasticQuery\ElasticQuery $elasticQuery, ): \Spameri\Elastic\Entity\ElasticEntityInterface { return parent::getBy($elasticQuery); @@ -46,7 +46,7 @@ public function getBy( * @return \Spameri\Elastic\Entity\ElasticEntityCollectionInterface<\SpameriTests\Elastic\Data\Entity\Person> */ public function getAllBy( - \Spameri\ElasticQuery\ElasticQuery $elasticQuery + \Spameri\ElasticQuery\ElasticQuery $elasticQuery, ): \Spameri\Elastic\Entity\ElasticEntityCollectionInterface { return parent::getAllBy($elasticQuery); diff --git a/tests/SpameriTests/Elastic/Data/Model/VideoCollectionFactory.php b/tests/SpameriTests/Elastic/Data/Model/VideoCollectionFactory.php index e9e7c05a..9c663825 100644 --- a/tests/SpameriTests/Elastic/Data/Model/VideoCollectionFactory.php +++ b/tests/SpameriTests/Elastic/Data/Model/VideoCollectionFactory.php @@ -12,13 +12,13 @@ class VideoCollectionFactory implements \Spameri\Elastic\Factory\CollectionFacto public function create( \Spameri\Elastic\Model\ServiceInterface $service, array $elasticIds = [], - \Spameri\Elastic\Entity\ElasticEntityInterface ...$entityCollection + \Spameri\Elastic\Entity\ElasticEntityInterface ...$entityCollection, ): \Spameri\Elastic\Entity\ElasticEntityCollectionInterface { return new \SpameriTests\Elastic\Data\Model\VideoCollection( $service, $elasticIds, - ... $entityCollection + ... $entityCollection, ); } diff --git a/tests/SpameriTests/Elastic/Data/Model/VideoFactory.php b/tests/SpameriTests/Elastic/Data/Model/VideoFactory.php index af88cc7a..d09918a2 100644 --- a/tests/SpameriTests/Elastic/Data/Model/VideoFactory.php +++ b/tests/SpameriTests/Elastic/Data/Model/VideoFactory.php @@ -9,7 +9,7 @@ class VideoFactory implements \Spameri\Elastic\Factory\EntityFactoryInterface public function __construct( - \SpameriTests\Elastic\Data\Model\PersonService $personService + \SpameriTests\Elastic\Data\Model\PersonService $personService, ) { $this->personService = $personService; @@ -24,7 +24,7 @@ public function create(\Spameri\ElasticQuery\Response\Result\Hit $hit): \Generat yield new \SpameriTests\Elastic\Data\Entity\Video( new \Spameri\Elastic\Entity\Property\ElasticId($hit->id()), new \SpameriTests\Elastic\Data\Entity\Video\Identification( - new \SpameriTests\Elastic\Data\Entity\Property\ImdbId($hit->getValue('identification.imdb')) + new \SpameriTests\Elastic\Data\Entity\Property\ImdbId($hit->getValue('identification.imdb')), ), new \SpameriTests\Elastic\Data\Entity\Property\Name($hit->getValue('name')), new \SpameriTests\Elastic\Data\Entity\Property\Year($hit->getValue('year')), @@ -32,19 +32,19 @@ public function create(\Spameri\ElasticQuery\Response\Result\Hit $hit): \Generat new \SpameriTests\Elastic\Data\Entity\Video\Story( new \SpameriTests\Elastic\Data\Entity\Property\Description($hit->getValue('story.description')), new \SpameriTests\Elastic\Data\Entity\Video\Story\TagLineCollection( - new \SpameriTests\Elastic\Data\Entity\Video\Story\TagLine($hit->getValue('story.tagline')) + new \SpameriTests\Elastic\Data\Entity\Video\Story\TagLine($hit->getValue('story.tagline')), ), new \SpameriTests\Elastic\Data\Entity\Video\Story\PlotSummaryCollection(), new \SpameriTests\Elastic\Data\Entity\Video\Story\KeyWordCollection(), - new \SpameriTests\Elastic\Data\Entity\Video\Story\Synopsis($hit->getValue('synopsis')) + new \SpameriTests\Elastic\Data\Entity\Video\Story\Synopsis($hit->getValue('synopsis')), ), new \SpameriTests\Elastic\Data\Entity\Video\Details( new \SpameriTests\Elastic\Data\Entity\Video\Details\GenreCollection(), new \SpameriTests\Elastic\Data\Entity\Video\Details\AliasCollectionElastic(), new \SpameriTests\Elastic\Data\Entity\Video\Details\ReleaseCollectionElastic(), new \SpameriTests\Elastic\Data\Entity\Video\Details\Ratings( - new \SpameriTests\Elastic\Data\Entity\Video\Details\RatingsCount(1000) - ) + new \SpameriTests\Elastic\Data\Entity\Video\Details\RatingsCount(1000), + ), ), new \SpameriTests\Elastic\Data\Entity\Video\HighLights( new \SpameriTests\Elastic\Data\Entity\Video\HighLights\TriviaCollection(), @@ -53,7 +53,7 @@ public function create(\Spameri\ElasticQuery\Response\Result\Hit $hit): \Generat new \SpameriTests\Elastic\Data\Entity\Video\HighLights\QuoteCollection(), new \SpameriTests\Elastic\Data\Entity\Video\HighLights\LocationCollection(), new \SpameriTests\Elastic\Data\Entity\Video\HighLights\AlternateVersionCollection(), - new \SpameriTests\Elastic\Data\Entity\Video\HighLights\CompanyCreditCollection() + new \SpameriTests\Elastic\Data\Entity\Video\HighLights\CompanyCreditCollection(), ), new \SpameriTests\Elastic\Data\Entity\Video\Connections( new \SpameriTests\Elastic\Data\Entity\Video\Connections\FollowedCollection(), @@ -67,10 +67,10 @@ public function create(\Spameri\ElasticQuery\Response\Result\Hit $hit): \Generat new \SpameriTests\Elastic\Data\Entity\Video\Connections\FollowsCollection(), new \SpameriTests\Elastic\Data\Entity\Video\Connections\SpunOffCollection(), new \SpameriTests\Elastic\Data\Entity\Video\Connections\VersionOfCollection(), - new \SpameriTests\Elastic\Data\Entity\Video\Connections\EditedFromCollection() + new \SpameriTests\Elastic\Data\Entity\Video\Connections\EditedFromCollection(), ), new \SpameriTests\Elastic\Data\Entity\Video\People($this->personService), - new \SpameriTests\Elastic\Data\Entity\Video\SeasonCollection() + new \SpameriTests\Elastic\Data\Entity\Video\SeasonCollection(), ); } diff --git a/tests/SpameriTests/Elastic/Data/Model/VideoMapping.php b/tests/SpameriTests/Elastic/Data/Model/VideoMapping.php index 8da98a37..753f3751 100644 --- a/tests/SpameriTests/Elastic/Data/Model/VideoMapping.php +++ b/tests/SpameriTests/Elastic/Data/Model/VideoMapping.php @@ -9,7 +9,7 @@ class VideoMapping implements \Spameri\Elastic\Settings\IndexConfigInterface public function __construct( - string $index + string $index, ) { $this->index = $index; @@ -22,25 +22,25 @@ public function provide(): \Spameri\ElasticQuery\Mapping\Settings $nameFields = new \Spameri\ElasticQuery\Mapping\Settings\Mapping\SubFields( 'name', - \Spameri\Elastic\Model\ValidateMapping\AllowedValues::TYPE_TEXT + \Spameri\Elastic\Model\ValidateMapping\AllowedValues::TYPE_TEXT, ); $nameFields->addMappingField( new \Spameri\ElasticQuery\Mapping\Settings\Mapping\Field( 'edgeNgram', - \Spameri\Elastic\Model\ValidateMapping\AllowedValues::TYPE_TEXT - ) + \Spameri\Elastic\Model\ValidateMapping\AllowedValues::TYPE_TEXT, + ), ); $nameFields->addMappingField( new \Spameri\ElasticQuery\Mapping\Settings\Mapping\Field( 'wordSplit', - \Spameri\Elastic\Model\ValidateMapping\AllowedValues::TYPE_TEXT - ) + \Spameri\Elastic\Model\ValidateMapping\AllowedValues::TYPE_TEXT, + ), ); $nameFields->addMappingField( new \Spameri\ElasticQuery\Mapping\Settings\Mapping\Field( 'wordJoin', - \Spameri\Elastic\Model\ValidateMapping\AllowedValues::TYPE_TEXT - ) + \Spameri\Elastic\Model\ValidateMapping\AllowedValues::TYPE_TEXT, + ), ); $settings->addMappingSubField($nameFields); @@ -49,13 +49,13 @@ public function provide(): \Spameri\ElasticQuery\Mapping\Settings new \Spameri\ElasticQuery\Mapping\Settings\Mapping\FieldCollection( new \Spameri\ElasticQuery\Mapping\Settings\Mapping\Field( 'description', - \Spameri\Elastic\Model\ValidateMapping\AllowedValues::TYPE_TEXT + \Spameri\Elastic\Model\ValidateMapping\AllowedValues::TYPE_TEXT, ), new \Spameri\ElasticQuery\Mapping\Settings\Mapping\Field( 'tagLine', - \Spameri\Elastic\Model\ValidateMapping\AllowedValues::TYPE_KEYWORD - ) - ) + \Spameri\Elastic\Model\ValidateMapping\AllowedValues::TYPE_KEYWORD, + ), + ), ); $settings->addMappingFieldObject($story); @@ -64,30 +64,30 @@ public function provide(): \Spameri\ElasticQuery\Mapping\Settings new \Spameri\ElasticQuery\Mapping\Settings\Mapping\FieldCollection( new \Spameri\ElasticQuery\Mapping\Settings\Mapping\Field( 'number', - \Spameri\Elastic\Model\ValidateMapping\AllowedValues::TYPE_KEYWORD + \Spameri\Elastic\Model\ValidateMapping\AllowedValues::TYPE_KEYWORD, ), new \Spameri\ElasticQuery\Mapping\Settings\Mapping\FieldObject( 'episodes', new \Spameri\ElasticQuery\Mapping\Settings\Mapping\FieldCollection( new \Spameri\ElasticQuery\Mapping\Settings\Mapping\Field( 'id', - \Spameri\Elastic\Model\ValidateMapping\AllowedValues::TYPE_KEYWORD + \Spameri\Elastic\Model\ValidateMapping\AllowedValues::TYPE_KEYWORD, ), new \Spameri\ElasticQuery\Mapping\Settings\Mapping\Field( 'number', - \Spameri\Elastic\Model\ValidateMapping\AllowedValues::TYPE_KEYWORD + \Spameri\Elastic\Model\ValidateMapping\AllowedValues::TYPE_KEYWORD, ), new \Spameri\ElasticQuery\Mapping\Settings\Mapping\Field( 'name', - \Spameri\Elastic\Model\ValidateMapping\AllowedValues::TYPE_TEXT + \Spameri\Elastic\Model\ValidateMapping\AllowedValues::TYPE_TEXT, ), new \Spameri\ElasticQuery\Mapping\Settings\Mapping\Field( 'description', - \Spameri\Elastic\Model\ValidateMapping\AllowedValues::TYPE_TEXT - ) - ) - ) - ) + \Spameri\Elastic\Model\ValidateMapping\AllowedValues::TYPE_TEXT, + ), + ), + ), + ), ); $settings->addMappingFieldObject($season); @@ -96,52 +96,52 @@ public function provide(): \Spameri\ElasticQuery\Mapping\Settings new \Spameri\ElasticQuery\Mapping\Settings\Mapping\FieldCollection( new \Spameri\ElasticQuery\Mapping\Settings\Mapping\Field( 'imdb', - \Spameri\ElasticQuery\Mapping\AllowedValues::TYPE_KEYWORD - ) - ) + \Spameri\ElasticQuery\Mapping\AllowedValues::TYPE_KEYWORD, + ), + ), ); $settings->addMappingFieldObject($identification); $settings->addMappingField( new \Spameri\ElasticQuery\Mapping\Settings\Mapping\Field( 'year', - \Spameri\Elastic\Model\ValidateMapping\AllowedValues::TYPE_LONG - ) + \Spameri\Elastic\Model\ValidateMapping\AllowedValues::TYPE_LONG, + ), ); $settings->addMappingFieldObject( new \Spameri\ElasticQuery\Mapping\Settings\Mapping\FieldObject( 'technical', - new \Spameri\ElasticQuery\Mapping\Settings\Mapping\FieldCollection() - ) + new \Spameri\ElasticQuery\Mapping\Settings\Mapping\FieldCollection(), + ), ); $settings->addMappingFieldObject( new \Spameri\ElasticQuery\Mapping\Settings\Mapping\FieldObject( 'details', - new \Spameri\ElasticQuery\Mapping\Settings\Mapping\FieldCollection() - ) + new \Spameri\ElasticQuery\Mapping\Settings\Mapping\FieldCollection(), + ), ); $settings->addMappingFieldObject( new \Spameri\ElasticQuery\Mapping\Settings\Mapping\FieldObject( 'highLights', - new \Spameri\ElasticQuery\Mapping\Settings\Mapping\FieldCollection() - ) + new \Spameri\ElasticQuery\Mapping\Settings\Mapping\FieldCollection(), + ), ); $settings->addMappingFieldObject( new \Spameri\ElasticQuery\Mapping\Settings\Mapping\FieldObject( 'connections', - new \Spameri\ElasticQuery\Mapping\Settings\Mapping\FieldCollection() - ) + new \Spameri\ElasticQuery\Mapping\Settings\Mapping\FieldCollection(), + ), ); $settings->addMappingFieldObject( new \Spameri\ElasticQuery\Mapping\Settings\Mapping\FieldObject( 'people', - new \Spameri\ElasticQuery\Mapping\Settings\Mapping\FieldCollection() - ) + new \Spameri\ElasticQuery\Mapping\Settings\Mapping\FieldCollection(), + ), ); return $settings; diff --git a/tests/SpameriTests/Elastic/Data/Model/VideoService.php b/tests/SpameriTests/Elastic/Data/Model/VideoService.php index fe6f99d2..22381960 100644 --- a/tests/SpameriTests/Elastic/Data/Model/VideoService.php +++ b/tests/SpameriTests/Elastic/Data/Model/VideoService.php @@ -10,7 +10,7 @@ class VideoService extends \Spameri\Elastic\Model\AbstractBaseService * @return string */ public function insert( - \Spameri\Elastic\Entity\ElasticEntityInterface $entity + \Spameri\Elastic\Entity\ElasticEntityInterface $entity, ): string { return parent::insert($entity); @@ -22,7 +22,7 @@ public function insert( * @return \Spameri\Elastic\Entity\ElasticEntityInterface|\SpameriTests\Elastic\Data\Entity\Video */ public function get( - \Spameri\Elastic\Entity\Property\ElasticId $id + \Spameri\Elastic\Entity\Property\ElasticId $id, ): \Spameri\Elastic\Entity\ElasticEntityInterface { return parent::get($id); @@ -35,7 +35,7 @@ public function get( * @throws \Spameri\Elastic\Exception\DocumentNotFound */ public function getBy( - \Spameri\ElasticQuery\ElasticQuery $elasticQuery + \Spameri\ElasticQuery\ElasticQuery $elasticQuery, ): \Spameri\Elastic\Entity\ElasticEntityInterface { return parent::getBy($elasticQuery); @@ -47,7 +47,7 @@ public function getBy( * @return \Spameri\Elastic\Entity\ElasticEntityCollectionInterface<\SpameriTests\Elastic\Data\Entity\Video> */ public function getAllBy( - \Spameri\ElasticQuery\ElasticQuery $elasticQuery + \Spameri\ElasticQuery\ElasticQuery $elasticQuery, ): \Spameri\Elastic\Entity\ElasticEntityCollectionInterface { return parent::getAllBy($elasticQuery); diff --git a/tests/SpameriTests/Elastic/Model/Indices/CreateTest.php b/tests/SpameriTests/Elastic/Model/Indices/CreateTest.php index 324566be..a9e93b8b 100644 --- a/tests/SpameriTests/Elastic/Model/Indices/CreateTest.php +++ b/tests/SpameriTests/Elastic/Model/Indices/CreateTest.php @@ -21,60 +21,60 @@ public function testProcess(): void $create = new \Spameri\Elastic\Model\Indices\Create( $this->container->getByType(\Spameri\Elastic\ClientProvider::class), - $this->container->getByType(\Spameri\Elastic\Model\VersionProvider::class) + $this->container->getByType(\Spameri\Elastic\Model\VersionProvider::class), ); $create->execute( \SpameriTests\Elastic\Config::INDEX_CREATE, $videoMapping->provide()->toArray(), - \SpameriTests\Elastic\Config::INDEX_CREATE + \SpameriTests\Elastic\Config::INDEX_CREATE, ); $response = $getMapping->execute(\SpameriTests\Elastic\Config::INDEX_CREATE); if ($versionProvider->provide() < \Spameri\ElasticQuery\Response\Result\Version::ELASTIC_VERSION_ID_7) { \Tester\Assert::true( - isset($response[\SpameriTests\Elastic\Config::INDEX_CREATE]['mappings'][\SpameriTests\Elastic\Config::INDEX_CREATE]) + isset($response[\SpameriTests\Elastic\Config::INDEX_CREATE]['mappings'][\SpameriTests\Elastic\Config::INDEX_CREATE]), ); $existingMapping = $response[\SpameriTests\Elastic\Config::INDEX_CREATE]['mappings'][\SpameriTests\Elastic\Config::INDEX_CREATE]; \Tester\Assert::same( \Spameri\Elastic\Model\ValidateMapping\AllowedValues::TYPE_STRING, - $existingMapping['properties']['name']['type'] + $existingMapping['properties']['name']['type'], ); \Tester\Assert::same( \Spameri\Elastic\Model\ValidateMapping\AllowedValues::TYPE_STRING, - $existingMapping['properties']['name']['fields']['edgeNgram']['type'] + $existingMapping['properties']['name']['fields']['edgeNgram']['type'], ); \Tester\Assert::same( \Spameri\Elastic\Model\ValidateMapping\AllowedValues::TYPE_STRING, - $existingMapping['properties']['season']['properties']['number']['type'] + $existingMapping['properties']['season']['properties']['number']['type'], ); \Tester\Assert::same( \Spameri\Elastic\Model\ValidateMapping\AllowedValues::TYPE_STRING, - $existingMapping['properties']['story']['properties']['description']['type'] + $existingMapping['properties']['story']['properties']['description']['type'], ); } else { \Tester\Assert::true( - isset($response[\SpameriTests\Elastic\Config::INDEX_CREATE]['mappings']) + isset($response[\SpameriTests\Elastic\Config::INDEX_CREATE]['mappings']), ); $existingMapping = $response[\SpameriTests\Elastic\Config::INDEX_CREATE]['mappings']; \Tester\Assert::same( \Spameri\Elastic\Model\ValidateMapping\AllowedValues::TYPE_TEXT, - $existingMapping['properties']['name']['type'] + $existingMapping['properties']['name']['type'], ); \Tester\Assert::same( \Spameri\Elastic\Model\ValidateMapping\AllowedValues::TYPE_TEXT, - $existingMapping['properties']['name']['fields']['edgeNgram']['type'] + $existingMapping['properties']['name']['fields']['edgeNgram']['type'], ); \Tester\Assert::same( \Spameri\Elastic\Model\ValidateMapping\AllowedValues::TYPE_KEYWORD, - $existingMapping['properties']['season']['properties']['number']['type'] + $existingMapping['properties']['season']['properties']['number']['type'], ); \Tester\Assert::same( \Spameri\Elastic\Model\ValidateMapping\AllowedValues::TYPE_TEXT, - $existingMapping['properties']['story']['properties']['description']['type'] + $existingMapping['properties']['story']['properties']['description']['type'], ); } } From 4c204ba4faad78f257050fbcfa1bedc694d77fc1 Mon Sep 17 00:00:00 2001 From: Spamer Date: Sat, 6 Jan 2024 00:57:25 +0100 Subject: [PATCH 18/37] Added EntityRepository - First draft of entity repository - class that accepts entity class and does magic to return ElasticEntityInterface - In future can replace service approach --- composer.json | 7 +- makefile | 6 +- ruleset.xml | 120 ++++++++++++++++++ src/ClientProvider.php | 12 +- src/Config/Elastic.neon | 13 +- src/Entity/Property/Date.php | 2 +- src/EntityRepository.php | 108 ++++++++++++++++ src/Exception/InvalidArgument.php | 10 ++ src/Factory/EntityFactory.php | 80 ++++++++++++ src/Factory/EntityFactoryInterface.php | 1 + src/Model/EntityService.php | 12 ++ src/Model/EntitySettingsLocator.php | 28 +++- src/Settings/AbstractIndexConfig.php | 29 +++++ src/Settings/IndexConfigInterface.php | 3 + .../Elastic/Data/Entity/Person.php | 72 ++--------- .../Data/Entity/Property/Description.php | 4 +- .../Elastic/Data/Entity/Property/ImdbId.php | 18 +-- .../Data/Entity/Video/Identification.php | 11 +- .../Elastic/Data/Model/PersonFactory.php | 23 ++-- .../Elastic/Data/Model/PersonMapping.php | 13 +- .../Elastic/Data/Model/VideoFactory.php | 5 +- .../Elastic/Data/Model/VideoMapping.php | 13 +- .../Elastic/Factory/EntityFactory.phpt | 58 +++++++++ 23 files changed, 500 insertions(+), 148 deletions(-) create mode 100644 ruleset.xml create mode 100644 src/EntityRepository.php create mode 100644 src/Exception/InvalidArgument.php create mode 100644 src/Factory/EntityFactory.php create mode 100644 src/Model/EntityService.php create mode 100644 src/Settings/AbstractIndexConfig.php create mode 100644 tests/SpameriTests/Elastic/Factory/EntityFactory.phpt diff --git a/composer.json b/composer.json index 7d40d089..d7a3b8e0 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ } ], "require": { - "php": ">=7.4", + "php": ">=8.2", "ext-json": "*", "ext-curl": "*", "spameri/elastic-query": "^v1.0.0", @@ -37,7 +37,7 @@ "ezimuel/ringphp": "^1.2" }, "require-dev": { - "spameri/coding-standard": "dev-master", + "slevomat/coding-standard": "^8.0", "spameri/dependency-mocker": "^1.3", "nette/tester": "^2.4", "phpstan/phpstan": "0.12.84", @@ -59,7 +59,8 @@ }, "config": { "allow-plugins": { - "dealerdirect/phpcodesniffer-composer-installer": true + "dealerdirect/phpcodesniffer-composer-installer": true, + "php-http/discovery": true } } } diff --git a/makefile b/makefile index 2c531042..94e35709 100644 --- a/makefile +++ b/makefile @@ -28,13 +28,13 @@ phpstan-lowest: vendor/bin/phpstan analyse -l 6 -c phpstan-low.neon src tests cs: - vendor/bin/phpcs --standard=vendor/spameri/coding-standard/src/ruleset.xml --cache=.phpcs-cache src tests/SpameriTests + vendor/bin/phpcs --standard=ruleset.xml --cache=.phpcs-cache src tests/SpameriTests cs-local: - vendor/bin/phpcs --standard=vendor/spameri/coding-standard/src/ruleset.xml src tests/SpameriTests + vendor/bin/phpcs --standard=ruleset.xml src tests/SpameriTests cbf: - vendor/bin/phpcbf --standard=vendor/spameri/coding-standard/src/ruleset.xml src tests/SpameriTests + vendor/bin/phpcbf --standard=ruleset.xml src tests/SpameriTests coverage: vendor/bin/tester $COVERAGE -s -c ./tests/php.ini-unix ./tests diff --git a/ruleset.xml b/ruleset.xml new file mode 100644 index 00000000..d86f1c00 --- /dev/null +++ b/ruleset.xml @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ClientProvider.php b/src/ClientProvider.php index d388f114..eac48daa 100644 --- a/src/ClientProvider.php +++ b/src/ClientProvider.php @@ -6,12 +6,12 @@ class ClientProvider { /** - * @var \Elasticsearch\Client + * @var \Elastic\Elasticsearch\Client */ private $client; /** - * @var \Elasticsearch\ClientBuilder + * @var \Elastic\Elasticsearch\ClientBuilder */ private $clientBuilder; @@ -22,7 +22,7 @@ class ClientProvider public function __construct( - \Elasticsearch\ClientBuilder $clientBuilder, + \Elastic\Elasticsearch\ClientBuilder $clientBuilder, \Spameri\Elastic\SettingsProviderInterface $settingsProvider, ) { @@ -51,11 +51,11 @@ public function init(): void /** - * @throws \Elasticsearch\Common\Exceptions\ElasticsearchException + * @throws \Elastic\Elasticsearch\Exception\ElasticsearchException */ - public function client(): \Elasticsearch\Client + public function client(): \Elastic\Elasticsearch\Client { - if ( ! ($this->client instanceof \Elasticsearch\Client)) { + if ( ! ($this->client instanceof \Elastic\Elasticsearch\Client)) { $this->client = $this->clientBuilder->build(); } diff --git a/src/Config/Elastic.neon b/src/Config/Elastic.neon index 354d76ea..ab6bcca6 100644 --- a/src/Config/Elastic.neon +++ b/src/Config/Elastic.neon @@ -189,12 +189,12 @@ services: # ### clientBuilder: - factory: Elasticsearch\ClientBuilder + factory: \Elastic\Elasticsearch\ClientBuilder setup: - setLogger(@spameriElasticSearch.elasticPanelLogger) client: - class: Elasticsearch\Client + class: \Elastic\Elasticsearch\Client factory: @spameriElasticSearch.clientBuilder::build dateTimeProvider: @@ -217,3 +217,12 @@ services: nullAfterImport: factory: Spameri\Elastic\Import\AfterImport\NullAfterImport + + entityFactory: + factory: Spameri\Elastic\Factory\EntityFactory + + entityService: + factory: Spameri\Elastic\Model\EntityService + + entityRepository: + factory: Spameri\Elastic\EntityRepository diff --git a/src/Entity/Property/Date.php b/src/Entity/Property/Date.php index d2b5b40f..b0924cd6 100644 --- a/src/Entity/Property/Date.php +++ b/src/Entity/Property/Date.php @@ -12,7 +12,7 @@ class Date extends \Nette\Utils\DateTime implements \Spameri\Elastic\Entity\Date * @param string|null $format * @return string */ - public function format($format = NULL) + public function format($format = NULL): string { if ( ! $format) { $format = self::FORMAT; diff --git a/src/EntityRepository.php b/src/EntityRepository.php new file mode 100644 index 00000000..77c8b940 --- /dev/null +++ b/src/EntityRepository.php @@ -0,0 +1,108 @@ +addMustQuery( + new \Spameri\ElasticQuery\Query\Term( + '_id', + $id, + ), + ); + + return $this->findOneBy($elasticQuery, $class); + } + + + public function findOneBy( + \Spameri\ElasticQuery\ElasticQuery $elasticQuery, + string $class, + ): \Spameri\Elastic\Entity\ElasticEntityInterface + { + $elasticQuery->options()->changeSize(1); + + $entities = $this->findBy($elasticQuery, $class); + + if (\count($entities) === 0) { + throw new \Spameri\Elastic\Exception\DocumentNotFound('Entity ' . $class . ' not found.'); + } + + return \reset($entities); + } + + + public function findBy( + \Spameri\ElasticQuery\ElasticQuery $elasticQuery, + string $class, + ): array + { + $indexConfig = $this->entitySettingsLocator->locateByEntityClass($class); + + try { + $resultSearch = $this->getAllBy->execute($elasticQuery, $indexConfig->indexName()); + + } catch (\Spameri\Elastic\Exception\ElasticSearch $exception) { + \Tracy\Debugger::log($exception->getMessage(), \Tracy\ILogger::CRITICAL); + + throw $exception; + } + + $entities = []; + foreach ($resultSearch->hits() as $hit) { + try { + $entities[] = $this->entityFactory->create($hit, $class)->current(); + + } catch (\Spameri\Elastic\Exception\ElasticSearch $exception) { + \Tracy\Debugger::log($exception->getMessage(), \Tracy\ILogger::CRITICAL); + } + } + + // TODO univerzální kolekce + return $entities; + } + + + public function findAll(string $class): array + { + return $this->findBy(new \Spameri\ElasticQuery\ElasticQuery(), $class); + } + + + public function persist( + \Spameri\Elastic\Entity\ElasticEntityInterface $entity + ): string + { + $indexConfig = $this->entitySettingsLocator->locateByEntityClass($entity::class); + + return $this->insert->execute($entity, $indexConfig->indexName()); + } + + + public function remove(\Spameri\Elastic\Entity\ElasticEntityInterface $entity): bool + { + $indexConfig = $this->entitySettingsLocator->locateByEntityClass($entity::class); + + return $this->delete->execute($entity->id(), $indexConfig->indexName()); + } + +} diff --git a/src/Exception/InvalidArgument.php b/src/Exception/InvalidArgument.php new file mode 100644 index 00000000..28621328 --- /dev/null +++ b/src/Exception/InvalidArgument.php @@ -0,0 +1,10 @@ + + */ + public function create( + \Spameri\ElasticQuery\Response\Result\Hit $hit, + string|null $class = null, + ): \Generator + { + if ($class === null) { + throw new \Spameri\Elastic\Exception\InvalidArgument('Class must be set.'); + } + + $properties = $this->resolveProperties($hit, $class); + + yield new $class( + ... $properties, + ); + } + + protected function resolveProperties( + \Spameri\ElasticQuery\Response\Result\Hit $hit, + string $class, + string|null $parentFieldName = null + ): array + { + $reflection = new \ReflectionClass($class); + + $resolvedProperties = []; + foreach ($reflection->getProperties() as $property) { + $hitKey = $property->getName(); + if ($parentFieldName !== null) { + $hitKey = $parentFieldName . '.' . $hitKey; + } + + if ($property->getType() === null) { + $resolvedProperties[$property->getName()] = $hit->getValue($parentFieldName); + continue; + } + + $propertyTypeName = $property->getType()->getName(); + if ($propertyTypeName === \Spameri\Elastic\Entity\Property\Date::class) { + $value = $hit->getValue($hitKey); + if ($value !== null) { + $propertyValue = new \Spameri\Elastic\Entity\Property\Date( + datetime: $value, + ); + + } else { + $propertyValue = null; + } + + } elseif (\is_subclass_of($propertyTypeName, \Spameri\Elastic\Entity\Collection\AbstractEntityCollection::class)) { + // TODO collections + + } elseif (\interface_exists($propertyTypeName)) { + $propertyValue = new \Spameri\Elastic\Entity\Property\ElasticId($hit->id()); + + } elseif (\class_exists($propertyTypeName)) { + $propertyValue = new $propertyTypeName( + ... $this->resolveProperties($hit, $propertyTypeName, $hitKey) + ); + + } else { + $propertyValue = $hit->getValue($hitKey); + } + + $resolvedProperties[$property->getName()] = $propertyValue; + } + + return $resolvedProperties; + } + +} diff --git a/src/Factory/EntityFactoryInterface.php b/src/Factory/EntityFactoryInterface.php index 34b6fbe8..168b7989 100644 --- a/src/Factory/EntityFactoryInterface.php +++ b/src/Factory/EntityFactoryInterface.php @@ -7,6 +7,7 @@ interface EntityFactoryInterface public function create( \Spameri\ElasticQuery\Response\Result\Hit $hit, + string|null $class = null, ): \Generator; } diff --git a/src/Model/EntityService.php b/src/Model/EntityService.php new file mode 100644 index 00000000..d4d5fd79 --- /dev/null +++ b/src/Model/EntityService.php @@ -0,0 +1,12 @@ +container = $container; } @@ -20,8 +18,9 @@ public function locate(string $indexName): \Spameri\ElasticQuery\Mapping\Setting { $indexConfigs = $this->locateAll(); + /** @var \Spameri\Elastic\Settings\IndexConfigInterface $indexConfig */ foreach ($indexConfigs as $indexConfig) { - if (\strpos($indexConfig->provide()->indexName(), $indexName) !== FALSE) { + if (\str_contains($indexConfig->provide()->indexName(), $indexName)) { return $indexConfig->provide(); } } @@ -30,6 +29,21 @@ public function locate(string $indexName): \Spameri\ElasticQuery\Mapping\Setting } + public function locateByEntityClass(string $entityClass): \Spameri\ElasticQuery\Mapping\Settings + { + $indexConfigs = $this->locateAll(); + + /** @var \Spameri\Elastic\Settings\AbstractIndexConfig $indexConfig */ + foreach ($indexConfigs as $indexConfig) { +if ($indexConfig->entityClass() === $entityClass) { +return $indexConfig->provide(); + } + } + + throw new \Spameri\Elastic\Exception\SettingsNotLocated($entityClass); + } + + /** * @return \Generator<\Spameri\Elastic\Settings\IndexConfigInterface> */ diff --git a/src/Settings/AbstractIndexConfig.php b/src/Settings/AbstractIndexConfig.php new file mode 100644 index 00000000..de3f79c3 --- /dev/null +++ b/src/Settings/AbstractIndexConfig.php @@ -0,0 +1,29 @@ +entityClass; + } + + public function indexName(): string + { + return $this->index; + } + +} diff --git a/src/Settings/IndexConfigInterface.php b/src/Settings/IndexConfigInterface.php index e3ff8574..c7d8a27e 100644 --- a/src/Settings/IndexConfigInterface.php +++ b/src/Settings/IndexConfigInterface.php @@ -7,4 +7,7 @@ interface IndexConfigInterface public function provide(): \Spameri\ElasticQuery\Mapping\Settings; + public function entityClass(): string; + + public function indexName(): string; } diff --git a/tests/SpameriTests/Elastic/Data/Entity/Person.php b/tests/SpameriTests/Elastic/Data/Entity/Person.php index 25ffbb02..742a8736 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Person.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Person.php @@ -5,73 +5,19 @@ class Person implements \Spameri\Elastic\Entity\ElasticEntityInterface { - /** - * @var \Spameri\Elastic\Entity\Property\ElasticIdInterface - */ - public $id; - - /** - * @var \SpameriTests\Elastic\Data\Entity\Video\Identification - */ - private $identification; - - /** - * @var \SpameriTests\Elastic\Data\Entity\Property\Name - */ - private $name; - - /** - * @var \SpameriTests\Elastic\Data\Entity\Property\Description - */ - private $description; - - /** - * @var \Spameri\Elastic\Entity\Property\Date|NULL - */ - private $birth; - - /** - * @var \Spameri\Elastic\Entity\Property\Date|NULL - */ - private $death; - - /** - * @var \SpameriTests\Elastic\Data\Entity\Property\Name - */ - private $alias; - - /** - * @var \SpameriTests\Elastic\Data\Entity\Person\CharacterCollectionElastic - */ - private $characters; - - /** - * @var \SpameriTests\Elastic\Data\Entity\Person\JobCollectionElastic - */ - private $jobs; - public function __construct( - \Spameri\Elastic\Entity\Property\ElasticIdInterface $id, - \SpameriTests\Elastic\Data\Entity\Video\Identification $identification, - \SpameriTests\Elastic\Data\Entity\Property\Name $name, - \SpameriTests\Elastic\Data\Entity\Property\Description $description, - \Spameri\Elastic\Entity\Property\Date|null $birth, - \Spameri\Elastic\Entity\Property\Date|null $death, - \SpameriTests\Elastic\Data\Entity\Property\Name $alias, - \SpameriTests\Elastic\Data\Entity\Person\CharacterCollectionElastic $characters, - \SpameriTests\Elastic\Data\Entity\Person\JobCollectionElastic $jobs, + public \Spameri\Elastic\Entity\Property\ElasticIdInterface $id, + private \SpameriTests\Elastic\Data\Entity\Video\Identification $identification, + private \SpameriTests\Elastic\Data\Entity\Property\Name $name, + private \SpameriTests\Elastic\Data\Entity\Property\Description $description, + private \Spameri\Elastic\Entity\Property\Date|null $birth, + private \Spameri\Elastic\Entity\Property\Date|null $death, + private \SpameriTests\Elastic\Data\Entity\Property\Name $alias, +// private \SpameriTests\Elastic\Data\Entity\Person\CharacterCollectionElastic $characters, +// private \SpameriTests\Elastic\Data\Entity\Person\JobCollectionElastic $jobs, ) { - $this->id = $id; - $this->identification = $identification; - $this->name = $name; - $this->description = $description; - $this->birth = $birth; - $this->death = $death; - $this->alias = $alias; - $this->characters = $characters; - $this->jobs = $jobs; } diff --git a/tests/SpameriTests/Elastic/Data/Entity/Property/Description.php b/tests/SpameriTests/Elastic/Data/Entity/Property/Description.php index ebe3e9f0..e8083f08 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Property/Description.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Property/Description.php @@ -12,10 +12,10 @@ class Description implements \Spameri\Elastic\Entity\ValueInterface public function __construct( - string|null $description, + string|null $value, ) { - $this->value = $description; + $this->value = $value; } diff --git a/tests/SpameriTests/Elastic/Data/Entity/Property/ImdbId.php b/tests/SpameriTests/Elastic/Data/Entity/Property/ImdbId.php index d634f20c..54767faf 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Property/ImdbId.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Property/ImdbId.php @@ -5,28 +5,14 @@ class ImdbId implements \Spameri\Elastic\Entity\ValueInterface { - /** - * @var int - */ - private $value; - - public function __construct( - int $value, + private string $value, ) { - if ($value < 1) { - throw new \InvalidArgumentException(); - } - if ($value > 99999999) { - throw new \InvalidArgumentException(); - } - - $this->value = $value; } - public function value(): int + public function value(): string { return $this->value; } diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Identification.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Identification.php index dc8cfb19..e80d61d7 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Identification.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Identification.php @@ -5,19 +5,10 @@ class Identification implements \Spameri\Elastic\Entity\EntityInterface { - /** - * @var \SpameriTests\Elastic\Data\Entity\Property\ImdbId - * @type(\SpameriTests\Elastic\Data\Entity\Video\keyword) - * @analyzer(\SpameriTests\Elastic\Data\Entity\Video\keyword) - */ - private $imdb; - - public function __construct( - \SpameriTests\Elastic\Data\Entity\Property\ImdbId $imdb, + private \SpameriTests\Elastic\Data\Entity\Property\ImdbId $imdb, ) { - $this->imdb = $imdb; } diff --git a/tests/SpameriTests/Elastic/Data/Model/PersonFactory.php b/tests/SpameriTests/Elastic/Data/Model/PersonFactory.php index 4ce10283..8918895a 100644 --- a/tests/SpameriTests/Elastic/Data/Model/PersonFactory.php +++ b/tests/SpameriTests/Elastic/Data/Model/PersonFactory.php @@ -8,20 +8,23 @@ class PersonFactory implements \Spameri\Elastic\Factory\EntityFactoryInterface /** * @return \Generator<\SpameriTests\Elastic\Data\Entity\Person> */ - public function create(\Spameri\ElasticQuery\Response\Result\Hit $hit): \Generator + public function create( + \Spameri\ElasticQuery\Response\Result\Hit $hit, + string|null $class = null, + ): \Generator { yield new \SpameriTests\Elastic\Data\Entity\Person( - new \Spameri\Elastic\Entity\Property\ElasticId($hit->id()), - new \SpameriTests\Elastic\Data\Entity\Video\Identification( + id: new \Spameri\Elastic\Entity\Property\ElasticId($hit->id()), + identification: new \SpameriTests\Elastic\Data\Entity\Video\Identification( $hit->getValue('identification.imdb'), ), - new \SpameriTests\Elastic\Data\Entity\Property\Name($hit->getValue('name')), - new \SpameriTests\Elastic\Data\Entity\Property\Description($hit->getValue('description')), - new \Spameri\Elastic\Entity\Property\Date($hit->getValue('birth')), - new \Spameri\Elastic\Entity\Property\Date($hit->getValue('death')), - new \SpameriTests\Elastic\Data\Entity\Property\Name($hit->getValue('alias')), - new \SpameriTests\Elastic\Data\Entity\Person\CharacterCollectionElastic(), - new \SpameriTests\Elastic\Data\Entity\Person\JobCollectionElastic(), + name: new \SpameriTests\Elastic\Data\Entity\Property\Name($hit->getValue('name')), + description: new \SpameriTests\Elastic\Data\Entity\Property\Description($hit->getValue('description')), + birth: new \Spameri\Elastic\Entity\Property\Date($hit->getValue('birth')), + death: new \Spameri\Elastic\Entity\Property\Date($hit->getValue('death')), + alias: new \SpameriTests\Elastic\Data\Entity\Property\Name($hit->getValue('alias')), +// characters: new \SpameriTests\Elastic\Data\Entity\Person\CharacterCollectionElastic(), +// jobs: new \SpameriTests\Elastic\Data\Entity\Person\JobCollectionElastic(), ); } diff --git a/tests/SpameriTests/Elastic/Data/Model/PersonMapping.php b/tests/SpameriTests/Elastic/Data/Model/PersonMapping.php index 621b3d13..787748a0 100644 --- a/tests/SpameriTests/Elastic/Data/Model/PersonMapping.php +++ b/tests/SpameriTests/Elastic/Data/Model/PersonMapping.php @@ -2,20 +2,9 @@ namespace SpameriTests\Elastic\Data\Model; -class PersonMapping implements \Spameri\Elastic\Settings\IndexConfigInterface +class PersonMapping extends \Spameri\Elastic\Settings\AbstractIndexConfig { - private string $index; - - - public function __construct( - string $index, - ) - { - $this->index = $index; - } - - public function provide(): \Spameri\ElasticQuery\Mapping\Settings { return new \Spameri\ElasticQuery\Mapping\Settings($this->index); diff --git a/tests/SpameriTests/Elastic/Data/Model/VideoFactory.php b/tests/SpameriTests/Elastic/Data/Model/VideoFactory.php index d09918a2..d3a8205d 100644 --- a/tests/SpameriTests/Elastic/Data/Model/VideoFactory.php +++ b/tests/SpameriTests/Elastic/Data/Model/VideoFactory.php @@ -19,7 +19,10 @@ public function __construct( /** * @return \Generator<\SpameriTests\Elastic\Data\Entity\Video> */ - public function create(\Spameri\ElasticQuery\Response\Result\Hit $hit): \Generator + public function create( + \Spameri\ElasticQuery\Response\Result\Hit $hit, + string|null $class = null, + ): \Generator { yield new \SpameriTests\Elastic\Data\Entity\Video( new \Spameri\Elastic\Entity\Property\ElasticId($hit->id()), diff --git a/tests/SpameriTests/Elastic/Data/Model/VideoMapping.php b/tests/SpameriTests/Elastic/Data/Model/VideoMapping.php index 753f3751..5b864d61 100644 --- a/tests/SpameriTests/Elastic/Data/Model/VideoMapping.php +++ b/tests/SpameriTests/Elastic/Data/Model/VideoMapping.php @@ -2,20 +2,9 @@ namespace SpameriTests\Elastic\Data\Model; -class VideoMapping implements \Spameri\Elastic\Settings\IndexConfigInterface +class VideoMapping extends \Spameri\Elastic\Settings\AbstractIndexConfig { - private string $index; - - - public function __construct( - string $index, - ) - { - $this->index = $index; - } - - public function provide(): \Spameri\ElasticQuery\Mapping\Settings { $settings = new \Spameri\ElasticQuery\Mapping\Settings($this->index); diff --git a/tests/SpameriTests/Elastic/Factory/EntityFactory.phpt b/tests/SpameriTests/Elastic/Factory/EntityFactory.phpt new file mode 100644 index 00000000..55fa0df2 --- /dev/null +++ b/tests/SpameriTests/Elastic/Factory/EntityFactory.phpt @@ -0,0 +1,58 @@ + [ + 'imdb' => 'nm0000001', + ], + 'name' => 'John Doe', + 'description' => 'John Doe is a great actor.', + 'birth' => '1970-01-01', + 'death' => NULL, + 'alias' => 'Johny', + 'characters' => [ + [ + 'character' => 'Victor Doe', + 'video' => '1', + ], + ], + ], + position: 0, + index: '', + type: '', + id: 'asd123', + score: 0.0, + version: 0, + ); + + /** @var \SpameriTests\Elastic\Data\Entity\Person $entity */ + $entity = $entityFactory->create($hit, \SpameriTests\Elastic\Data\Entity\Person::class)->current(); + + \var_dump($entity); + + \Tester\Assert::same('asd123', $entity->id->value()); + \Tester\Assert::same('nm0000001', $entity->identification()->imdb()->value()); + \Tester\Assert::same('John Doe', $entity->name()->value()); + \Tester\Assert::same('John Doe is a great actor.', $entity->description()->value()); + \Tester\Assert::same('1970-01-01', $entity->birth()->format('Y-m-d')); + \Tester\Assert::null($entity->death()); + \Tester\Assert::same('Johny', $entity->alias()->value()); + } + +} + +(new EntityFactory())->run(); From 9ef632a2c73bc52066b3e2ef0374f36fcecf8350 Mon Sep 17 00:00:00 2001 From: Spamer Date: Sun, 7 Jan 2024 02:14:46 +0100 Subject: [PATCH 19/37] EntityFactory can handle EntityCollections Solved by adding attribute to specified property ie #[\Spameri\Elastic\Mapping\Entity(class: \Spameri\Elastic\Entity\Property\ElasticId::class)] or #[\Spameri\Elastic\Mapping\Collection(class: \SpameriTests\Elastic\Data\Entity\Person\Character::class)] That means create that specified entity class instead of whatever is defined --- src/ClientProvider.php | 7 -- src/Config/Elastic.neon | 4 +- .../Collection/AbstractEntityCollection.php | 4 +- .../Collection/ElasticEntityCollection.php | 11 ++ src/Entity/Collection/EntityCollection.php | 11 ++ src/EntityRepository.php | 5 +- src/Factory/EntityFactory.php | 69 ++++++++++-- src/Mapping/Collection.php | 18 +++ src/Mapping/ElasticCollection.php | 18 +++ src/Mapping/Entity.php | 18 +++ src/Model/GetAllBy.php | 4 +- .../Elastic/Data/Config/Common.neon | 4 +- .../Elastic/Data/Entity/Person.php | 9 +- .../Elastic/Data/Entity/Person/Character.php | 103 +----------------- .../Elastic/Factory/EntityFactory.phpt | 58 ++++++---- 15 files changed, 194 insertions(+), 149 deletions(-) create mode 100644 src/Entity/Collection/ElasticEntityCollection.php create mode 100644 src/Entity/Collection/EntityCollection.php create mode 100644 src/Mapping/Collection.php create mode 100644 src/Mapping/ElasticCollection.php create mode 100644 src/Mapping/Entity.php diff --git a/src/ClientProvider.php b/src/ClientProvider.php index eac48daa..d74f10cb 100644 --- a/src/ClientProvider.php +++ b/src/ClientProvider.php @@ -40,13 +40,6 @@ public function init(): void $settings->host() . ':' . $settings->port(), ], ); - $this->clientBuilder->setConnectionParams( - [ - 'client' => [ - 'headers' => $settings->headers(), - ], - ], - ); } diff --git a/src/Config/Elastic.neon b/src/Config/Elastic.neon index ab6bcca6..d5fe362b 100644 --- a/src/Config/Elastic.neon +++ b/src/Config/Elastic.neon @@ -221,8 +221,8 @@ services: entityFactory: factory: Spameri\Elastic\Factory\EntityFactory - entityService: - factory: Spameri\Elastic\Model\EntityService +# entityService: +# factory: Spameri\Elastic\Model\EntityService entityRepository: factory: Spameri\Elastic\EntityRepository diff --git a/src/Entity/Collection/AbstractEntityCollection.php b/src/Entity/Collection/AbstractEntityCollection.php index 03a1e609..941f0a24 100644 --- a/src/Entity/Collection/AbstractEntityCollection.php +++ b/src/Entity/Collection/AbstractEntityCollection.php @@ -12,11 +12,11 @@ abstract class AbstractEntityCollection implements \Spameri\Elastic\Entity\Entit public function __construct( - \Spameri\Elastic\Entity\EntityInterface ...$entityCollection, + \Spameri\Elastic\Entity\EntityInterface ...$collection, ) { $this->collection = []; - foreach ($entityCollection as $elasticEntity) { + foreach ($collection as $elasticEntity) { $this->add($elasticEntity); } } diff --git a/src/Entity/Collection/ElasticEntityCollection.php b/src/Entity/Collection/ElasticEntityCollection.php new file mode 100644 index 00000000..fa24f550 --- /dev/null +++ b/src/Entity/Collection/ElasticEntityCollection.php @@ -0,0 +1,11 @@ +findBy(new \Spameri\ElasticQuery\ElasticQuery(), $class); + $elasticQuery = new \Spameri\ElasticQuery\ElasticQuery(); + $elasticQuery->options()->changeSize(10000); + + return $this->findBy($elasticQuery, $class); } diff --git a/src/Factory/EntityFactory.php b/src/Factory/EntityFactory.php index af5a571b..5bb3e0b7 100644 --- a/src/Factory/EntityFactory.php +++ b/src/Factory/EntityFactory.php @@ -1,4 +1,6 @@ -id()); + } elseif (\count($property->getAttributes()) > 0) { + foreach ($property->getAttributes() as $attribute) { + if ( + \in_array( + $attribute->getName(), + [ + \Spameri\Elastic\Mapping\Collection::class, + \Spameri\Elastic\Mapping\Entity::class, + ] + ) === true + ) { + $arguments = $attribute->getArguments(); + + if ($arguments['class'] === \Spameri\Elastic\Entity\Property\ElasticId::class) { + $propertyValue = new $arguments['class']( + $hit->id(), + ); + + } elseif ($attribute->getName() === \Spameri\Elastic\Mapping\Collection::class) { + $propertyValue = new \Spameri\Elastic\Entity\Collection\EntityCollection(); + foreach ($hit->getValue($hitKey) as $collectionItemKey => $collectionItem) { + $propertyValue->add(new $arguments['class']( + ... $this->resolveProperties($hit, $arguments['class'], $hitKey . '.' . $collectionItemKey), + )); + } + + } elseif ($attribute->getName() === \Spameri\Elastic\Mapping\ElasticCollection::class) { + $propertyValue = new \Spameri\Elastic\Entity\Collection\ElasticEntityCollection( + // TODO musíme předat service nebo udělat novou kolekci co implementuje ElasticEntityCollectionInterface + ); + foreach ($hit->getValue($hitKey) as $collectionItemKey => $collectionItem) { + $propertyValue->add(new $arguments['class']( + ... $this->resolveProperties($hit, $arguments['class'], $hitKey . '.' . $collectionItemKey), + )); + } + + } else { + $propertyValue = new $arguments['class']( + ... $this->resolveProperties($hit, $propertyTypeName, $hitKey), + ); + } + } + } } elseif (\class_exists($propertyTypeName)) { - $propertyValue = new $propertyTypeName( - ... $this->resolveProperties($hit, $propertyTypeName, $hitKey) - ); + if (isset(\class_implements($propertyTypeName)[\Spameri\Elastic\Entity\ValueInterface::class]) === true) { + $propertyValue = new $propertyTypeName( + $hit->getValue($hitKey), + ); + + } else { + $propertyValue = new $propertyTypeName( + ... $this->resolveProperties($hit, $propertyTypeName, $hitKey), + ); + } } else { $propertyValue = $hit->getValue($hitKey); } $resolvedProperties[$property->getName()] = $propertyValue; + + unset($propertyValue); } return $resolvedProperties; diff --git a/src/Mapping/Collection.php b/src/Mapping/Collection.php new file mode 100644 index 00000000..20076c52 --- /dev/null +++ b/src/Mapping/Collection.php @@ -0,0 +1,18 @@ +toArray(), - ) + )->asArray() ; - } catch (\Elasticsearch\Common\Exceptions\ElasticsearchException $exception) { + } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { throw new \Spameri\Elastic\Exception\ElasticSearch($exception->getMessage()); } diff --git a/tests/SpameriTests/Elastic/Data/Config/Common.neon b/tests/SpameriTests/Elastic/Data/Config/Common.neon index 295e9082..ef391b66 100644 --- a/tests/SpameriTests/Elastic/Data/Config/Common.neon +++ b/tests/SpameriTests/Elastic/Data/Config/Common.neon @@ -16,7 +16,7 @@ parameters: services: elastic.person.personMapping: - factory: SpameriTests\Elastic\Data\Model\PersonMapping(%elasticSearch.personIndex%) + factory: SpameriTests\Elastic\Data\Model\PersonMapping(%elasticSearch.personIndex%, SpameriTests\Elastic\Data\Entity\Person::class) elastic.person.personFactory: factory: SpameriTests\Elastic\Data\Model\PersonFactory @@ -35,7 +35,7 @@ services: ######################################################################################################################## elastic.video.videoMapping: - factory: SpameriTests\Elastic\Data\Model\VideoMapping(%elasticSearch.personIndex%) + factory: SpameriTests\Elastic\Data\Model\VideoMapping(%elasticSearch.personIndex%, SpameriTests\Elastic\Data\Entity\Video::class) elastic.video.videoFactory: factory: SpameriTests\Elastic\Data\Model\VideoFactory diff --git a/tests/SpameriTests/Elastic/Data/Entity/Person.php b/tests/SpameriTests/Elastic/Data/Entity/Person.php index 742a8736..6a0b1738 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Person.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Person.php @@ -7,6 +7,7 @@ class Person implements \Spameri\Elastic\Entity\ElasticEntityInterface public function __construct( + #[\Spameri\Elastic\Mapping\Entity(class: \Spameri\Elastic\Entity\Property\ElasticId::class)] public \Spameri\Elastic\Entity\Property\ElasticIdInterface $id, private \SpameriTests\Elastic\Data\Entity\Video\Identification $identification, private \SpameriTests\Elastic\Data\Entity\Property\Name $name, @@ -14,8 +15,12 @@ public function __construct( private \Spameri\Elastic\Entity\Property\Date|null $birth, private \Spameri\Elastic\Entity\Property\Date|null $death, private \SpameriTests\Elastic\Data\Entity\Property\Name $alias, -// private \SpameriTests\Elastic\Data\Entity\Person\CharacterCollectionElastic $characters, -// private \SpameriTests\Elastic\Data\Entity\Person\JobCollectionElastic $jobs, + + #[\Spameri\Elastic\Mapping\Collection(class: \SpameriTests\Elastic\Data\Entity\Person\Character::class)] + private \Spameri\Elastic\Entity\Collection\AbstractEntityCollection $characters, + + #[\Spameri\Elastic\Mapping\Collection(class: \SpameriTests\Elastic\Data\Entity\Person\Job::class)] + private \Spameri\Elastic\Entity\Collection\EntityCollection $jobs, ) { } diff --git a/tests/SpameriTests/Elastic/Data/Entity/Person/Character.php b/tests/SpameriTests/Elastic/Data/Entity/Person/Character.php index 7e6c95f7..376933b3 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Person/Character.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Person/Character.php @@ -5,52 +5,15 @@ class Character implements \Spameri\Elastic\Entity\EntityInterface { - /** - * @var \SpameriTests\Elastic\Data\Entity\Property\ImdbId - */ - private $id; - - /** - * @var \SpameriTests\Elastic\Data\Entity\Property\ImdbId|null - */ - private $episode; - - /** - * @var \SpameriTests\Elastic\Data\Entity\Property\Name - */ - private $name; - - /** - * @var \SpameriTests\Elastic\Data\Entity\Video\Identification - */ - private $identification; - - /** - * @var \SpameriTests\Elastic\Data\Entity\Property\Description - */ - private $biography; - - /** - * @var \SpameriTests\Elastic\Data\Entity\Property\Name - */ - private $alias; - - public function __construct( - \SpameriTests\Elastic\Data\Entity\Property\ImdbId $id, - \SpameriTests\Elastic\Data\Entity\Property\ImdbId|null $episode, - \SpameriTests\Elastic\Data\Entity\Property\Name $name, - \SpameriTests\Elastic\Data\Entity\Property\Name $alias, - \SpameriTests\Elastic\Data\Entity\Video\Identification $identification, - \SpameriTests\Elastic\Data\Entity\Property\Description $biography, + public string $id, + public \SpameriTests\Elastic\Data\Entity\Property\ImdbId $episode, + public \SpameriTests\Elastic\Data\Entity\Property\Name $name, + public \SpameriTests\Elastic\Data\Entity\Property\Name $alias, + public \SpameriTests\Elastic\Data\Entity\Video\Identification $identification, + public \SpameriTests\Elastic\Data\Entity\Property\Description $biography, ) { - $this->id = $id; - $this->episode = $episode; - $this->name = $name; - $this->identification = $identification; - $this->biography = $biography; - $this->alias = $alias; } @@ -61,62 +24,8 @@ public function entityVariables(): array public function key(): string - { - return (string) $this->id->value(); - } - - - public function id(): \SpameriTests\Elastic\Data\Entity\Property\ImdbId { return $this->id; } - - public function episode(): \SpameriTests\Elastic\Data\Entity\Property\ImdbId|null - { - return $this->episode; - } - - - public function setEpisode(\SpameriTests\Elastic\Data\Entity\Property\ImdbId|null $episode): void - { - $this->episode = $episode; - } - - - public function name(): \SpameriTests\Elastic\Data\Entity\Property\Name - { - return $this->name; - } - - - public function setName(\SpameriTests\Elastic\Data\Entity\Property\Name $name): void - { - $this->name = $name; - } - - - public function alias(): \SpameriTests\Elastic\Data\Entity\Property\Name - { - return $this->alias; - } - - - public function setAlias(\SpameriTests\Elastic\Data\Entity\Property\Name $alias): void - { - $this->alias = $alias; - } - - - public function identification(): \SpameriTests\Elastic\Data\Entity\Video\Identification - { - return $this->identification; - } - - - public function biography(): \SpameriTests\Elastic\Data\Entity\Property\Description - { - return $this->biography; - } - } diff --git a/tests/SpameriTests/Elastic/Factory/EntityFactory.phpt b/tests/SpameriTests/Elastic/Factory/EntityFactory.phpt index 55fa0df2..340404c8 100644 --- a/tests/SpameriTests/Elastic/Factory/EntityFactory.phpt +++ b/tests/SpameriTests/Elastic/Factory/EntityFactory.phpt @@ -13,24 +13,36 @@ class EntityFactory extends \SpameriTests\Elastic\AbstractTestCase public function testCreate() { $entityFactory = new \Spameri\Elastic\Factory\EntityFactory(); + $prepareEntityArray = new \Spameri\Elastic\Model\Insert\PrepareEntityArray( + \Mockery::mock(\Spameri\Elastic\Model\ServiceLocator::class) + ); + $person = new \SpameriTests\Elastic\Data\Entity\Person( + new \Spameri\Elastic\Entity\Property\ElasticId('asd123'), + new \SpameriTests\Elastic\Data\Entity\Video\Identification( + new \SpameriTests\Elastic\Data\Entity\Property\ImdbId('nm0000001') + ), + new \SpameriTests\Elastic\Data\Entity\Property\Name('John Doe'), + new \SpameriTests\Elastic\Data\Entity\Property\Description('John Doe is a great actor.'), + new \Spameri\Elastic\Entity\Property\Date('1970-01-01'), + NULL, + new \SpameriTests\Elastic\Data\Entity\Property\Name('Johny'), + new \Spameri\Elastic\Entity\Collection\EntityCollection( + new \SpameriTests\Elastic\Data\Entity\Person\Character( + 'ch0000001', + new \SpameriTests\Elastic\Data\Entity\Property\ImdbId('ep0000001'), + new \SpameriTests\Elastic\Data\Entity\Property\Name('John Doe'), + new \SpameriTests\Elastic\Data\Entity\Property\Name('Johny'), + new \SpameriTests\Elastic\Data\Entity\Video\Identification( + new \SpameriTests\Elastic\Data\Entity\Property\ImdbId('nm0000002') + ), + new \SpameriTests\Elastic\Data\Entity\Property\Description('John Doe is a great actor.') + ) + ), + new \Spameri\Elastic\Entity\Collection\EntityCollection(), + ); $hit = new \Spameri\ElasticQuery\Response\Result\Hit( - source: [ - 'identification' => [ - 'imdb' => 'nm0000001', - ], - 'name' => 'John Doe', - 'description' => 'John Doe is a great actor.', - 'birth' => '1970-01-01', - 'death' => NULL, - 'alias' => 'Johny', - 'characters' => [ - [ - 'character' => 'Victor Doe', - 'video' => '1', - ], - ], - ], + source: $prepareEntityArray->prepare($person), position: 0, index: '', type: '', @@ -42,15 +54,13 @@ class EntityFactory extends \SpameriTests\Elastic\AbstractTestCase /** @var \SpameriTests\Elastic\Data\Entity\Person $entity */ $entity = $entityFactory->create($hit, \SpameriTests\Elastic\Data\Entity\Person::class)->current(); - \var_dump($entity); - - \Tester\Assert::same('asd123', $entity->id->value()); - \Tester\Assert::same('nm0000001', $entity->identification()->imdb()->value()); - \Tester\Assert::same('John Doe', $entity->name()->value()); - \Tester\Assert::same('John Doe is a great actor.', $entity->description()->value()); - \Tester\Assert::same('1970-01-01', $entity->birth()->format('Y-m-d')); + \Tester\Assert::same($person->id->value(), $entity->id->value()); + \Tester\Assert::same($person->identification()->imdb()->value(), $entity->identification()->imdb()->value()); + \Tester\Assert::same($person->name()->value(), $entity->name()->value()); + \Tester\Assert::same($person->description()->value(), $entity->description()->value()); + \Tester\Assert::same($person->birth()->format('Y-m-d'), $entity->birth()->format('Y-m-d')); \Tester\Assert::null($entity->death()); - \Tester\Assert::same('Johny', $entity->alias()->value()); + \Tester\Assert::same($person->alias()->value(), $entity->alias()->value()); } } From 06b012d610bd77d75ccd359fad17c38ba1e08b59 Mon Sep 17 00:00:00 2001 From: Spamer Date: Sun, 7 Jan 2024 02:15:23 +0100 Subject: [PATCH 20/37] temporary for development --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d7a3b8e0..5d505cdf 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ "php": ">=8.2", "ext-json": "*", "ext-curl": "*", - "spameri/elastic-query": "^v1.0.0", + "spameri/elastic-query": "dev-master", "elasticsearch/elasticsearch": "^7.12|^8", "nette/di": "^3.0.5", "nette/utils": "^3.2.5", From eb4c97c0f462a5afc1cbd9cbca5da8cb20ede9eb Mon Sep 17 00:00:00 2001 From: Spamer Date: Thu, 4 Apr 2024 16:20:49 +0200 Subject: [PATCH 21/37] changed to promoted properties --- src/ClientProvider.php | 21 +--- src/Commands/AddAlias.php | 5 +- src/Commands/CreateIndex.php | 10 +- src/Commands/DeleteIndex.php | 5 +- src/Commands/DumpIndex.php | 9 +- src/Commands/InitializeIndexes.php | 15 +-- src/Commands/LoadDump.php | 9 +- src/Commands/RemoveAlias.php | 5 +- src/Commands/TypeToNewIndex.php | 5 +- src/Diagnostics/Panel.php | 11 +- src/Diagnostics/PanelLogger.php | 14 +-- src/Entity/AbstractImport.php | 14 +-- src/Entity/AbstractValueCollection.php | 2 +- .../AbstractElasticEntityCollection.php | 23 +--- src/Entity/Import/ArrayValue.php | 19 +--- src/Entity/Import/BoolValue.php | 19 +--- src/Entity/Import/DateValue.php | 27 +---- src/Entity/Import/EmptyValue.php | 13 +-- src/Entity/Import/FloatValue.php | 19 +--- src/Entity/Import/IntegerValue.php | 19 +--- src/Entity/Import/NoValue.php | 12 +- src/Entity/Import/StringValue.php | 19 +--- src/Entity/Property/ElasticId.php | 14 +-- src/Entity/Property/EmptyElasticId.php | 13 +-- src/Entity/Value/BoolValue.php | 11 +- src/Entity/Value/IntegerValue.php | 11 +- src/Entity/Value/NullValue.php | 15 +-- src/Entity/Value/StringValue.php | 11 +- src/Import/Lock/FileLock.php | 13 +-- src/Import/Response/SimpleResponse.php | 19 +--- src/Import/ResponseInterface.php | 5 +- src/Import/Run.php | 79 ++----------- src/Import/Run/LoggerHandler.php | 11 +- src/Import/Run/Options.php | 11 +- src/Model/Aggregate.php | 24 +--- src/Model/CreateIndex.php | 23 +--- src/Model/Delete.php | 16 +-- src/Model/DeleteIndex.php | 13 +-- src/Model/DeleteMultiple.php | 24 +--- src/Model/DumpIndex.php | 18 +-- src/Model/EntitySettingsLocator.php | 2 +- src/Model/Get.php | 24 +--- src/Model/GetAllBy.php | 24 +--- src/Model/GetBy.php | 24 +--- src/Model/Index.php | 13 +-- src/Model/Indices/AddAlias.php | 8 +- src/Model/Indices/Close.php | 10 +- src/Model/Indices/Create.php | 13 +-- src/Model/Indices/Delete.php | 11 +- src/Model/Indices/Exists.php | 8 +- src/Model/Indices/Get.php | 11 +- src/Model/Indices/GetFieldMapping.php | 8 +- src/Model/Indices/GetMapping.php | 16 +-- src/Model/Indices/MoveAlias.php | 8 +- src/Model/Indices/Open.php | 11 +- src/Model/Indices/PutMapping.php | 16 +-- src/Model/Indices/PutSettings.php | 11 +- src/Model/Indices/RemoveAlias.php | 8 +- src/Model/InitializeIndex.php | 23 +--- src/Model/Insert.php | 24 +--- src/Model/Insert/PrepareEntityArray.php | 8 +- src/Model/InsertMultiple.php | 32 +----- src/Model/RestoreIndex.php | 13 +-- src/Model/Scroll.php | 24 +--- src/Model/Search.php | 24 +--- src/Model/ServiceLocator.php | 9 +- .../TypeToNewIndex/DocumentMigrateStatus.php | 2 +- src/Model/TypeToNewIndex/Migrate.php | 104 +++--------------- src/Model/VersionProvider.php | 8 +- src/Provider/DateTimeProvider.php | 11 +- src/Settings.php | 27 +---- src/Settings/NeonSettingsProvider.php | 27 +---- 72 files changed, 215 insertions(+), 973 deletions(-) diff --git a/src/ClientProvider.php b/src/ClientProvider.php index d74f10cb..241463f5 100644 --- a/src/ClientProvider.php +++ b/src/ClientProvider.php @@ -5,29 +5,14 @@ class ClientProvider { - /** - * @var \Elastic\Elasticsearch\Client - */ - private $client; - - /** - * @var \Elastic\Elasticsearch\ClientBuilder - */ - private $clientBuilder; - - /** - * @var \Spameri\Elastic\SettingsProviderInterface - */ - private $settingsProvider; + private \Elastic\Elasticsearch\Client $client; public function __construct( - \Elastic\Elasticsearch\ClientBuilder $clientBuilder, - \Spameri\Elastic\SettingsProviderInterface $settingsProvider, + private readonly \Elastic\Elasticsearch\ClientBuilder $clientBuilder, + private readonly \Spameri\Elastic\SettingsProviderInterface $settingsProvider, ) { - $this->clientBuilder = $clientBuilder; - $this->settingsProvider = $settingsProvider; $this->init(); } diff --git a/src/Commands/AddAlias.php b/src/Commands/AddAlias.php index 5848e20d..edbd2886 100644 --- a/src/Commands/AddAlias.php +++ b/src/Commands/AddAlias.php @@ -7,15 +7,12 @@ class AddAlias extends \Symfony\Component\Console\Command\Command protected static $defaultName = 'spameri:elastic:add-alias'; - private \Spameri\Elastic\Model\Indices\AddAlias $addAlias; - public function __construct( - \Spameri\Elastic\Model\Indices\AddAlias $addAlias, + private readonly \Spameri\Elastic\Model\Indices\AddAlias $addAlias, ) { parent::__construct(NULL); - $this->addAlias = $addAlias; } diff --git a/src/Commands/CreateIndex.php b/src/Commands/CreateIndex.php index a53f9a9b..587957d5 100644 --- a/src/Commands/CreateIndex.php +++ b/src/Commands/CreateIndex.php @@ -7,19 +7,13 @@ class CreateIndex extends \Symfony\Component\Console\Command\Command protected static $defaultName = 'spameri:elastic:create-index'; - private \Spameri\Elastic\Model\CreateIndex $createIndex; - - private \Spameri\Elastic\Model\DeleteIndex $deleteIndex; - public function __construct( - \Spameri\Elastic\Model\CreateIndex $createIndex, - \Spameri\Elastic\Model\DeleteIndex $deleteIndex, + private readonly \Spameri\Elastic\Model\CreateIndex $createIndex, + private readonly \Spameri\Elastic\Model\DeleteIndex $deleteIndex, ) { parent::__construct(NULL); - $this->createIndex = $createIndex; - $this->deleteIndex = $deleteIndex; } diff --git a/src/Commands/DeleteIndex.php b/src/Commands/DeleteIndex.php index 6136ee20..f4c24700 100644 --- a/src/Commands/DeleteIndex.php +++ b/src/Commands/DeleteIndex.php @@ -7,15 +7,12 @@ class DeleteIndex extends \Symfony\Component\Console\Command\Command protected static $defaultName = 'spameri:elastic:delete-index'; - private \Spameri\Elastic\Model\Indices\Delete $delete; - public function __construct( - \Spameri\Elastic\Model\Indices\Delete $delete, + private readonly \Spameri\Elastic\Model\Indices\Delete $delete, ) { parent::__construct(NULL); - $this->delete = $delete; } diff --git a/src/Commands/DumpIndex.php b/src/Commands/DumpIndex.php index 477607d2..ca60f404 100644 --- a/src/Commands/DumpIndex.php +++ b/src/Commands/DumpIndex.php @@ -7,15 +7,12 @@ class DumpIndex extends \Symfony\Component\Console\Command\Command protected static $defaultName = 'spameri:elastic:dump-index'; - private \Spameri\Elastic\Model\DumpIndex $dumpIndex; - public function __construct( - \Spameri\Elastic\Model\DumpIndex $migrate, + private readonly \Spameri\Elastic\Model\DumpIndex $migrate, ) { parent::__construct(NULL); - $this->dumpIndex = $migrate; } @@ -44,8 +41,8 @@ protected function execute( $index = $input->getArgument('index'); $filename = $input->getArgument('filename'); - $this->dumpIndex->setOutput($output); - $this->dumpIndex->execute($index, $filename); + $this->migrate->setOutput($output); + $this->migrate->execute($index, $filename); $output->writeln('Done'); diff --git a/src/Commands/InitializeIndexes.php b/src/Commands/InitializeIndexes.php index 9774fd72..9a13346c 100644 --- a/src/Commands/InitializeIndexes.php +++ b/src/Commands/InitializeIndexes.php @@ -7,23 +7,14 @@ class InitializeIndexes extends \Symfony\Component\Console\Command\Command protected static $defaultName = 'spameri:elastic:initialize-index'; - private \Spameri\Elastic\Model\DeleteIndex $deleteIndex; - - private \Spameri\Elastic\Model\InitializeIndex $initializeIndex; - - private \Spameri\Elastic\Model\EntitySettingsLocator $entitySettingsLocator; - public function __construct( - \Spameri\Elastic\Model\EntitySettingsLocator $entitySettingsLocator, - \Spameri\Elastic\Model\DeleteIndex $deleteIndex, - \Spameri\Elastic\Model\InitializeIndex $initializeIndex, + private readonly \Spameri\Elastic\Model\EntitySettingsLocator $entitySettingsLocator, + private readonly \Spameri\Elastic\Model\DeleteIndex $deleteIndex, + private readonly \Spameri\Elastic\Model\InitializeIndex $initializeIndex, ) { parent::__construct(NULL); - $this->entitySettingsLocator = $entitySettingsLocator; - $this->deleteIndex = $deleteIndex; - $this->initializeIndex = $initializeIndex; } diff --git a/src/Commands/LoadDump.php b/src/Commands/LoadDump.php index 72acb2e9..199f9e2e 100644 --- a/src/Commands/LoadDump.php +++ b/src/Commands/LoadDump.php @@ -7,15 +7,12 @@ class LoadDump extends \Symfony\Component\Console\Command\Command protected static $defaultName = 'spameri:elastic:load-dump'; - private \Spameri\Elastic\Model\RestoreIndex $restoreIndex; - public function __construct( - \Spameri\Elastic\Model\RestoreIndex $migrate, + private readonly \Spameri\Elastic\Model\RestoreIndex $migrate, ) { parent::__construct(NULL); - $this->restoreIndex = $migrate; } @@ -48,8 +45,8 @@ protected function execute( $filename = $input->getArgument('filename'); $step = (int) $input->getArgument('step'); - $this->restoreIndex->setOutput($output); - $this->restoreIndex->execute($filename, $step); + $this->migrate->setOutput($output); + $this->migrate->execute($filename, $step); $output->writeln('Done'); diff --git a/src/Commands/RemoveAlias.php b/src/Commands/RemoveAlias.php index 378e329e..fdbab6fe 100644 --- a/src/Commands/RemoveAlias.php +++ b/src/Commands/RemoveAlias.php @@ -7,15 +7,12 @@ class RemoveAlias extends \Symfony\Component\Console\Command\Command protected static $defaultName = 'spameri:elastic:remove-alias'; - private \Spameri\Elastic\Model\Indices\RemoveAlias $removeAlias; - public function __construct( - \Spameri\Elastic\Model\Indices\RemoveAlias $removeAlias, + private readonly \Spameri\Elastic\Model\Indices\RemoveAlias $removeAlias, ) { parent::__construct(NULL); - $this->removeAlias = $removeAlias; } diff --git a/src/Commands/TypeToNewIndex.php b/src/Commands/TypeToNewIndex.php index 35f6e7c4..219a7ffe 100644 --- a/src/Commands/TypeToNewIndex.php +++ b/src/Commands/TypeToNewIndex.php @@ -7,15 +7,12 @@ class TypeToNewIndex extends \Symfony\Component\Console\Command\Command protected static $defaultName = 'spameri:elastic:move-type'; - private \Spameri\Elastic\Model\TypeToNewIndex\Migrate $migrate; - public function __construct( - \Spameri\Elastic\Model\TypeToNewIndex\Migrate $migrate, + private readonly \Spameri\Elastic\Model\TypeToNewIndex\Migrate $migrate, ) { parent::__construct(NULL); - $this->migrate = $migrate; } diff --git a/src/Diagnostics/Panel.php b/src/Diagnostics/Panel.php index a7207ec0..c8d9c5ea 100644 --- a/src/Diagnostics/Panel.php +++ b/src/Diagnostics/Panel.php @@ -2,20 +2,13 @@ namespace Spameri\Elastic\Diagnostics; -class Panel implements \Tracy\IBarPanel +readonly class Panel implements \Tracy\IBarPanel { - /** - * @var \Spameri\Elastic\Diagnostics\PanelLogger - */ - private $logger; - - public function __construct( - \Spameri\Elastic\Diagnostics\PanelLogger $logger, + private \Spameri\Elastic\Diagnostics\PanelLogger $logger, ) { - $this->logger = $logger; } diff --git a/src/Diagnostics/PanelLogger.php b/src/Diagnostics/PanelLogger.php index 94a20257..f049a4e2 100644 --- a/src/Diagnostics/PanelLogger.php +++ b/src/Diagnostics/PanelLogger.php @@ -5,32 +5,26 @@ class PanelLogger implements \Psr\Log\LoggerInterface { - /** - * @var \Psr\Log\LoggerInterface - */ - private $logger; - /** * @var array */ - private $queries = []; + private array $queries = []; /** * @var array */ - private $requestBodies = []; + private array $requestBodies = []; /** * @var array */ - private $responseBodies = []; + private array $responseBodies = []; public function __construct( - \Psr\Log\LoggerInterface $logger, + private \Psr\Log\LoggerInterface $logger, ) { - $this->logger = $logger; } diff --git a/src/Entity/AbstractImport.php b/src/Entity/AbstractImport.php index c50f1417..adda3a22 100644 --- a/src/Entity/AbstractImport.php +++ b/src/Entity/AbstractImport.php @@ -2,23 +2,13 @@ namespace Spameri\Elastic\Entity; -abstract class AbstractImport implements \Spameri\Elastic\Entity\Import\ValidationObjectInterface +abstract readonly class AbstractImport implements \Spameri\Elastic\Entity\Import\ValidationObjectInterface { - /** - * @var int|string - */ - private $key; - - - /** - * @param int|string $key - */ public function __construct( - $key, + private int|string $key, ) { - $this->key = $key; } diff --git a/src/Entity/AbstractValueCollection.php b/src/Entity/AbstractValueCollection.php index 69597c9c..af2f72ef 100644 --- a/src/Entity/AbstractValueCollection.php +++ b/src/Entity/AbstractValueCollection.php @@ -8,7 +8,7 @@ abstract class AbstractValueCollection implements ValueCollectionInterface /** * @var array<\Spameri\Elastic\Entity\ValueInterface> */ - protected $collection; + protected array $collection; public function __construct( diff --git a/src/Entity/Collection/AbstractElasticEntityCollection.php b/src/Entity/Collection/AbstractElasticEntityCollection.php index f5f3710d..dc64a644 100644 --- a/src/Entity/Collection/AbstractElasticEntityCollection.php +++ b/src/Entity/Collection/AbstractElasticEntityCollection.php @@ -8,33 +8,18 @@ abstract class AbstractElasticEntityCollection implements \Spameri\Elastic\Entit /** * @var array<\Spameri\Elastic\Entity\ElasticEntityInterface> */ - protected $collection; + protected array $collection; - /** - * @var \Spameri\Elastic\Model\ServiceInterface - */ - protected $service; - - /** - * @var array - */ - protected $elasticIds; - - /** - * @var bool - */ - protected $initialized; + protected bool $initialized; public function __construct( - \Spameri\Elastic\Model\ServiceInterface $service, - array $elasticIds = [], + protected \Spameri\Elastic\Model\ServiceInterface $service, + protected array $elasticIds = [], \Spameri\Elastic\Entity\ElasticEntityInterface ...$entityCollection, ) { $this->collection = []; - $this->service = $service; - $this->elasticIds = $elasticIds; $this->initialized = FALSE; if ( diff --git a/src/Entity/Import/ArrayValue.php b/src/Entity/Import/ArrayValue.php index bb704d7d..3652c510 100644 --- a/src/Entity/Import/ArrayValue.php +++ b/src/Entity/Import/ArrayValue.php @@ -2,30 +2,17 @@ namespace Spameri\Elastic\Entity\Import; -class ArrayValue implements ValidationPropertyInterface +readonly class ArrayValue implements ValidationPropertyInterface { - /** - * @var array - */ - private $array; - - /** - * @var string - */ - private $key; - - /** * @param array $array */ public function __construct( - array $array, - string $key, + private array $array, + private string $key, ) { - $this->array = $array; - $this->key = $key; } diff --git a/src/Entity/Import/BoolValue.php b/src/Entity/Import/BoolValue.php index 7c10fba9..9babb629 100644 --- a/src/Entity/Import/BoolValue.php +++ b/src/Entity/Import/BoolValue.php @@ -2,27 +2,14 @@ namespace Spameri\Elastic\Entity\Import; -class BoolValue implements ValidationPropertyInterface +readonly class BoolValue implements ValidationPropertyInterface { - /** - * @var bool - */ - private $value; - - /** - * @var string - */ - private $key; - - public function __construct( - bool $value, - string $key, + private bool $value, + private string $key, ) { - $this->value = $value; - $this->key = $key; } diff --git a/src/Entity/Import/DateValue.php b/src/Entity/Import/DateValue.php index 390d6b2d..c1002f24 100644 --- a/src/Entity/Import/DateValue.php +++ b/src/Entity/Import/DateValue.php @@ -2,34 +2,15 @@ namespace Spameri\Elastic\Entity\Import; -class DateValue implements ValidationPropertyInterface +readonly class DateValue implements ValidationPropertyInterface { - /** - * @var \DateTime - */ - private $value; - - /** - * @var string - */ - private $key; - - /** - * @var string - */ - private $format; - - public function __construct( - \DateTime $value, - string $key, - string $format = 'Y-m-d H:i:s', + private \DateTime $value, + private string $key, + private string $format = 'Y-m-d H:i:s', ) { - $this->value = $value; - $this->key = $key; - $this->format = $format; } diff --git a/src/Entity/Import/EmptyValue.php b/src/Entity/Import/EmptyValue.php index 2fdb1974..bf62b762 100644 --- a/src/Entity/Import/EmptyValue.php +++ b/src/Entity/Import/EmptyValue.php @@ -2,20 +2,13 @@ namespace Spameri\Elastic\Entity\Import; -class EmptyValue implements ValidationPropertyInterface +readonly class EmptyValue implements ValidationPropertyInterface { - /** - * @var string - */ - private $key; - - public function __construct( - string $key, + private string $key, ) { - $this->key = $key; } @@ -25,7 +18,7 @@ public function key(): string } - public function getValue() + public function getValue(): null { return NULL; } diff --git a/src/Entity/Import/FloatValue.php b/src/Entity/Import/FloatValue.php index 000da9d6..ad2ae2f4 100644 --- a/src/Entity/Import/FloatValue.php +++ b/src/Entity/Import/FloatValue.php @@ -2,27 +2,14 @@ namespace Spameri\Elastic\Entity\Import; -class FloatValue implements ValidationPropertyInterface +readonly class FloatValue implements ValidationPropertyInterface { - /** - * @var float - */ - private $value; - - /** - * @var string - */ - private $key; - - public function __construct( - float $value, - string $key, + private float $value, + private string $key, ) { - $this->value = $value; - $this->key = $key; } diff --git a/src/Entity/Import/IntegerValue.php b/src/Entity/Import/IntegerValue.php index 24db539c..0af762a0 100644 --- a/src/Entity/Import/IntegerValue.php +++ b/src/Entity/Import/IntegerValue.php @@ -2,27 +2,14 @@ namespace Spameri\Elastic\Entity\Import; -class IntegerValue implements ValidationPropertyInterface +readonly class IntegerValue implements ValidationPropertyInterface { - /** - * @var int - */ - private $value; - - /** - * @var string - */ - private $key; - - public function __construct( - int $value, - string $key, + private int $value, + private string $key, ) { - $this->value = $value; - $this->key = $key; } diff --git a/src/Entity/Import/NoValue.php b/src/Entity/Import/NoValue.php index bc71a5c5..682dec5a 100644 --- a/src/Entity/Import/NoValue.php +++ b/src/Entity/Import/NoValue.php @@ -2,22 +2,16 @@ namespace Spameri\Elastic\Entity\Import; -class NoValue implements ValidationPropertyInterface +readonly class NoValue implements ValidationPropertyInterface { - /** - * @return NULL - */ - public function key() + public function key(): null { return NULL; } - /** - * @return NULL - */ - public function getValue() + public function getValue(): null { return NULL; } diff --git a/src/Entity/Import/StringValue.php b/src/Entity/Import/StringValue.php index c838c65b..a0cae107 100644 --- a/src/Entity/Import/StringValue.php +++ b/src/Entity/Import/StringValue.php @@ -2,27 +2,14 @@ namespace Spameri\Elastic\Entity\Import; -class StringValue implements ValidationPropertyInterface +readonly class StringValue implements ValidationPropertyInterface { - /** - * @var string - */ - private $value; - - /** - * @var string - */ - private $key; - - public function __construct( - string $value, - string $key, + private string $value, + private string $key, ) { - $this->value = $value; - $this->key = $key; } diff --git a/src/Entity/Property/ElasticId.php b/src/Entity/Property/ElasticId.php index 9843bd98..ab56c62f 100644 --- a/src/Entity/Property/ElasticId.php +++ b/src/Entity/Property/ElasticId.php @@ -2,26 +2,18 @@ namespace Spameri\Elastic\Entity\Property; -class ElasticId implements \Spameri\Elastic\Entity\ValueInterface, \Spameri\Elastic\Entity\Property\ElasticIdInterface +readonly class ElasticId implements \Spameri\Elastic\Entity\ValueInterface, \Spameri\Elastic\Entity\Property\ElasticIdInterface { public const FIELD_NAME = '_id'; - - /** - * @var string - */ - private $value; - - public function __construct( - string $id, + private string $value, ) { - if ($id === '') { + if ($value === '') { throw new \InvalidArgumentException(); } - $this->value = $id; } diff --git a/src/Entity/Property/EmptyElasticId.php b/src/Entity/Property/EmptyElasticId.php index 76b60414..dc9c568b 100644 --- a/src/Entity/Property/EmptyElasticId.php +++ b/src/Entity/Property/EmptyElasticId.php @@ -2,23 +2,16 @@ namespace Spameri\Elastic\Entity\Property; -class EmptyElasticId implements \Spameri\Elastic\Entity\ValueInterface, \Spameri\Elastic\Entity\Property\ElasticIdInterface +readonly class EmptyElasticId implements \Spameri\Elastic\Entity\ValueInterface, \Spameri\Elastic\Entity\Property\ElasticIdInterface { - /** - * @var string - */ - private $value; - - public function __construct( - string $id = '', + private string $value = '', ) { - if ($id !== '') { + if ($value !== '') { throw new \InvalidArgumentException(); } - $this->value = $id; } diff --git a/src/Entity/Value/BoolValue.php b/src/Entity/Value/BoolValue.php index 3a74592a..c79f9301 100644 --- a/src/Entity/Value/BoolValue.php +++ b/src/Entity/Value/BoolValue.php @@ -2,20 +2,13 @@ namespace Spameri\Elastic\Entity\Value; -class BoolValue implements \Spameri\Elastic\Entity\ValueInterface +readonly class BoolValue implements \Spameri\Elastic\Entity\ValueInterface { - /** - * @var bool - */ - private $value; - - public function __construct( - bool $value, + private bool $value, ) { - $this->value = $value; } diff --git a/src/Entity/Value/IntegerValue.php b/src/Entity/Value/IntegerValue.php index 3ab18e08..d4d1f3e1 100644 --- a/src/Entity/Value/IntegerValue.php +++ b/src/Entity/Value/IntegerValue.php @@ -2,20 +2,13 @@ namespace Spameri\Elastic\Entity\Value; -class IntegerValue implements \Spameri\Elastic\Entity\ValueInterface +readonly class IntegerValue implements \Spameri\Elastic\Entity\ValueInterface { - /** - * @var int - */ - private $value; - - public function __construct( - int $value, + private int $value, ) { - $this->value = $value; } diff --git a/src/Entity/Value/NullValue.php b/src/Entity/Value/NullValue.php index fda6b080..31f6e282 100644 --- a/src/Entity/Value/NullValue.php +++ b/src/Entity/Value/NullValue.php @@ -2,26 +2,17 @@ namespace Spameri\Elastic\Entity\Value; -class NullValue implements \Spameri\Elastic\Entity\ValueInterface +readonly class NullValue implements \Spameri\Elastic\Entity\ValueInterface { - /** - * @var NULL - */ - private $value; - - public function __construct() { } - /** - * @return NULL - */ - public function value() + public function value(): null { - return $this->value; + return NULL; } } diff --git a/src/Entity/Value/StringValue.php b/src/Entity/Value/StringValue.php index 13b66404..71614ea0 100644 --- a/src/Entity/Value/StringValue.php +++ b/src/Entity/Value/StringValue.php @@ -2,20 +2,13 @@ namespace Spameri\Elastic\Entity\Value; -class StringValue implements \Spameri\Elastic\Entity\ValueInterface +readonly class StringValue implements \Spameri\Elastic\Entity\ValueInterface { - /** - * @var string - */ - private $value; - - public function __construct( - string $value, + private string $value, ) { - $this->value = $value; } diff --git a/src/Import/Lock/FileLock.php b/src/Import/Lock/FileLock.php index 095e1914..b479c93a 100644 --- a/src/Import/Lock/FileLock.php +++ b/src/Import/Lock/FileLock.php @@ -5,22 +5,13 @@ class FileLock implements \Spameri\Elastic\Import\LockInterface { - /** - * @var string - */ - private $lockDir; - - /** - * @var string - */ - private $runName; + private string $runName; public function __construct( - string $lockDir, + private readonly string $lockDir, ) { - $this->lockDir = $lockDir; } diff --git a/src/Import/Response/SimpleResponse.php b/src/Import/Response/SimpleResponse.php index e2a9d361..faea2cac 100644 --- a/src/Import/Response/SimpleResponse.php +++ b/src/Import/Response/SimpleResponse.php @@ -2,27 +2,14 @@ namespace Spameri\Elastic\Import\Response; -class SimpleResponse implements \Spameri\Elastic\Import\ResponseInterface +readonly class SimpleResponse implements \Spameri\Elastic\Import\ResponseInterface { - /** - * @var mixed - */ - private $response; - - /** - * @var \Spameri\Elastic\Entity\AbstractImport - */ - private $entity; - - public function __construct( - $response, - \Spameri\Elastic\Entity\AbstractImport $entity, + private mixed $response, + private \Spameri\Elastic\Entity\AbstractImport $entity, ) { - $this->response = $response; - $this->entity = $entity; } diff --git a/src/Import/ResponseInterface.php b/src/Import/ResponseInterface.php index 1e5ca392..9c080735 100644 --- a/src/Import/ResponseInterface.php +++ b/src/Import/ResponseInterface.php @@ -5,11 +5,8 @@ interface ResponseInterface { - /** - * @param mixed $response - */ public function __construct( - $response, + mixed $response, \Spameri\Elastic\Entity\AbstractImport $entity, ); diff --git a/src/Import/Run.php b/src/Import/Run.php index 1abf4336..f815ce7c 100644 --- a/src/Import/Run.php +++ b/src/Import/Run.php @@ -5,84 +5,29 @@ class Run { - /** - * @var \Symfony\Component\Console\Output\OutputInterface - */ - private $output; - - /** - * @var \Spameri\Elastic\Import\LockInterface - */ - private $lock; - - /** - * @var \Spameri\Elastic\Import\RunHandlerInterface - */ - private $runHandler; - - /** - * @var \Spameri\Elastic\Import\DataProviderInterface - */ - private $dataProvider; - - /** - * @var \Spameri\Elastic\Import\PrepareImportDataInterface - */ - private $prepareImportData; - - /** - * @var \Spameri\Elastic\Import\DataImportInterface - */ - private $dataImport; + private \Symfony\Component\Console\Output\OutputInterface $output; - /** - * @var \Spameri\Elastic\Import\AfterImportInterface - */ - private $afterImport; + protected string $runName; - /** - * @var string - */ - protected $runName; + protected string $fileName; - /** - * @var string - */ - protected $fileName; - - /** - * @var \Symfony\Component\Console\Helper\ProgressBar - */ - private $progressBar; - - /** - * @var \Spameri\Elastic\Import\LoggerHandlerInterface - */ - private $loggerHandler; + private \Symfony\Component\Console\Helper\ProgressBar $progressBar; /** * @throws \ReflectionException */ public function __construct( - string $logDir, - \Spameri\Elastic\Import\LoggerHandlerInterface $loggerHandler, - \Spameri\Elastic\Import\LockInterface $lock, - \Spameri\Elastic\Import\RunHandlerInterface $runHandler, - \Spameri\Elastic\Import\DataProviderInterface $dataProvider, - \Spameri\Elastic\Import\PrepareImportDataInterface $prepareImportData, - \Spameri\Elastic\Import\DataImportInterface $dataImport, - \Spameri\Elastic\Import\AfterImportInterface $afterImport, + protected string $logDir, + private readonly \Spameri\Elastic\Import\LoggerHandlerInterface $loggerHandler, + private readonly \Spameri\Elastic\Import\LockInterface $lock, + private readonly \Spameri\Elastic\Import\RunHandlerInterface $runHandler, + private readonly \Spameri\Elastic\Import\DataProviderInterface $dataProvider, + private readonly \Spameri\Elastic\Import\PrepareImportDataInterface $prepareImportData, + private readonly \Spameri\Elastic\Import\DataImportInterface $dataImport, + private readonly \Spameri\Elastic\Import\AfterImportInterface $afterImport, ) { - $this->lock = $lock; - $this->loggerHandler = $loggerHandler; - $this->runHandler = $runHandler; - $this->dataProvider = $dataProvider; - $this->prepareImportData = $prepareImportData; - $this->dataImport = $dataImport; - $this->afterImport = $afterImport; - $this->runName = (new \ReflectionClass($this))->getShortName(); $this->lock->setRunName($this->runName); $this->setUpLogger($logDir); diff --git a/src/Import/Run/LoggerHandler.php b/src/Import/Run/LoggerHandler.php index ff3c79d0..b82df332 100644 --- a/src/Import/Run/LoggerHandler.php +++ b/src/Import/Run/LoggerHandler.php @@ -2,20 +2,13 @@ namespace Spameri\Elastic\Import\Run; -class LoggerHandler implements \Spameri\Elastic\Import\LoggerHandlerInterface +readonly class LoggerHandler implements \Spameri\Elastic\Import\LoggerHandlerInterface { - /** - * @var \Psr\Log\LoggerInterface - */ - private $logger; - - public function __construct( - \Psr\Log\LoggerInterface $logger, + private \Psr\Log\LoggerInterface $logger, ) { - $this->logger = $logger; } diff --git a/src/Import/Run/Options.php b/src/Import/Run/Options.php index eab755ab..72dc723c 100644 --- a/src/Import/Run/Options.php +++ b/src/Import/Run/Options.php @@ -2,20 +2,13 @@ namespace Spameri\Elastic\Import\Run; -class Options +readonly class Options { - /** - * @var int - */ - private $lockDuration; - - public function __construct( - int $lockDuration, + private int $lockDuration, ) { - $this->lockDuration = $lockDuration; } diff --git a/src/Model/Aggregate.php b/src/Model/Aggregate.php index b93fdd96..db8a66ce 100644 --- a/src/Model/Aggregate.php +++ b/src/Model/Aggregate.php @@ -2,31 +2,15 @@ namespace Spameri\Elastic\Model; -class Aggregate +readonly class Aggregate { - /** - * @var \Spameri\Elastic\ClientProvider - */ - private $clientProvider; - - /** - * @var \Spameri\ElasticQuery\Response\ResultMapper - */ - private $resultMapper; - - private VersionProvider $versionProvider; - - public function __construct( - \Spameri\Elastic\ClientProvider $clientProvider, - \Spameri\ElasticQuery\Response\ResultMapper $resultMapper, - \Spameri\Elastic\Model\VersionProvider $versionProvider, + private \Spameri\Elastic\ClientProvider $clientProvider, + private \Spameri\ElasticQuery\Response\ResultMapper $resultMapper, + private \Spameri\Elastic\Model\VersionProvider $versionProvider, ) { - $this->clientProvider = $clientProvider; - $this->resultMapper = $resultMapper; - $this->versionProvider = $versionProvider; } diff --git a/src/Model/CreateIndex.php b/src/Model/CreateIndex.php index 2d91a5b6..82fa997b 100644 --- a/src/Model/CreateIndex.php +++ b/src/Model/CreateIndex.php @@ -2,29 +2,16 @@ namespace Spameri\Elastic\Model; -class CreateIndex +readonly class CreateIndex { - private \Spameri\Elastic\Provider\DateTimeProvider $dateTimeProvider; - - private Indices\AddAlias $addAlias; - - private Indices\Get $get; - - private Indices\Create $create; - - public function __construct( - \Spameri\Elastic\Provider\DateTimeProvider $dateTimeProvider, - \Spameri\Elastic\Model\Indices\AddAlias $addAlias, - \Spameri\Elastic\Model\Indices\Get $get, - \Spameri\Elastic\Model\Indices\Create $create, + private \Spameri\Elastic\Provider\DateTimeProvider $dateTimeProvider, + private \Spameri\Elastic\Model\Indices\AddAlias $addAlias, + private \Spameri\Elastic\Model\Indices\Get $get, + private \Spameri\Elastic\Model\Indices\Create $create, ) { - $this->dateTimeProvider = $dateTimeProvider; - $this->addAlias = $addAlias; - $this->get = $get; - $this->create = $create; } diff --git a/src/Model/Delete.php b/src/Model/Delete.php index 12d58d17..71fe91f0 100644 --- a/src/Model/Delete.php +++ b/src/Model/Delete.php @@ -2,24 +2,14 @@ namespace Spameri\Elastic\Model; -class Delete +readonly class Delete { - /** - * @var \Spameri\Elastic\ClientProvider - */ - private $clientProvider; - - private VersionProvider $versionProvider; - - public function __construct( - \Spameri\Elastic\ClientProvider $clientProvider, - VersionProvider $versionProvider, + private \Spameri\Elastic\ClientProvider $clientProvider, + private VersionProvider $versionProvider, ) { - $this->clientProvider = $clientProvider; - $this->versionProvider = $versionProvider; } diff --git a/src/Model/DeleteIndex.php b/src/Model/DeleteIndex.php index b49f941a..01ca24b1 100644 --- a/src/Model/DeleteIndex.php +++ b/src/Model/DeleteIndex.php @@ -2,21 +2,14 @@ namespace Spameri\Elastic\Model; -class DeleteIndex +readonly class DeleteIndex { - private \Spameri\Elastic\Model\Indices\Get $get; - - private \Spameri\Elastic\Model\Indices\Delete $delete; - - public function __construct( - \Spameri\Elastic\Model\Indices\Get $get, - \Spameri\Elastic\Model\Indices\Delete $delete, + private \Spameri\Elastic\Model\Indices\Get $get, + private \Spameri\Elastic\Model\Indices\Delete $delete, ) { - $this->get = $get; - $this->delete = $delete; } diff --git a/src/Model/DeleteMultiple.php b/src/Model/DeleteMultiple.php index 7acbe866..48fefd1c 100644 --- a/src/Model/DeleteMultiple.php +++ b/src/Model/DeleteMultiple.php @@ -2,31 +2,15 @@ namespace Spameri\Elastic\Model; -class DeleteMultiple +readonly class DeleteMultiple { - /** - * @var \Spameri\Elastic\ClientProvider - */ - private $clientProvider; - - /** - * @var \Spameri\ElasticQuery\Response\ResultMapper - */ - private $resultMapper; - - private VersionProvider $versionProvider; - - public function __construct( - \Spameri\Elastic\ClientProvider $clientProvider, - \Spameri\ElasticQuery\Response\ResultMapper $resultMapper, - VersionProvider $versionProvider, + private \Spameri\Elastic\ClientProvider $clientProvider, + private \Spameri\ElasticQuery\Response\ResultMapper $resultMapper, + private VersionProvider $versionProvider, ) { - $this->clientProvider = $clientProvider; - $this->resultMapper = $resultMapper; - $this->versionProvider = $versionProvider; } diff --git a/src/Model/DumpIndex.php b/src/Model/DumpIndex.php index 2aad4a7e..4c107a90 100644 --- a/src/Model/DumpIndex.php +++ b/src/Model/DumpIndex.php @@ -5,28 +5,16 @@ class DumpIndex { - /** - * @var \Symfony\Component\Console\Output\OutputInterface - */ - private $output; + private \Symfony\Component\Console\Output\OutputInterface $output; - /** - * @var string - */ - private $bulkData; - - /** - * @var \Spameri\Elastic\Model\Scroll - */ - private $scroll; + private string $bulkData; public function __construct( - \Spameri\Elastic\Model\Scroll $scroll, + private readonly \Spameri\Elastic\Model\Scroll $scroll, ) { $this->bulkData = ''; - $this->scroll = $scroll; } diff --git a/src/Model/EntitySettingsLocator.php b/src/Model/EntitySettingsLocator.php index 79140f6e..4d1c0866 100644 --- a/src/Model/EntitySettingsLocator.php +++ b/src/Model/EntitySettingsLocator.php @@ -4,7 +4,7 @@ namespace Spameri\Elastic\Model; -class EntitySettingsLocator +readonly class EntitySettingsLocator { public function __construct( diff --git a/src/Model/Get.php b/src/Model/Get.php index 70a9665a..b3135825 100644 --- a/src/Model/Get.php +++ b/src/Model/Get.php @@ -2,31 +2,15 @@ namespace Spameri\Elastic\Model; -class Get +readonly class Get { - /** - * @var \Spameri\Elastic\ClientProvider - */ - private $clientProvider; - - /** - * @var \Spameri\ElasticQuery\Response\ResultMapper - */ - private $resultMapper; - - private VersionProvider $versionProvider; - - public function __construct( - \Spameri\Elastic\ClientProvider $clientProvider, - \Spameri\ElasticQuery\Response\ResultMapper $resultMapper, - VersionProvider $versionProvider, + private \Spameri\Elastic\ClientProvider $clientProvider, + private \Spameri\ElasticQuery\Response\ResultMapper $resultMapper, + private VersionProvider $versionProvider, ) { - $this->clientProvider = $clientProvider; - $this->resultMapper = $resultMapper; - $this->versionProvider = $versionProvider; } diff --git a/src/Model/GetAllBy.php b/src/Model/GetAllBy.php index 141cdb95..bd7c8a18 100644 --- a/src/Model/GetAllBy.php +++ b/src/Model/GetAllBy.php @@ -2,31 +2,15 @@ namespace Spameri\Elastic\Model; -class GetAllBy +readonly class GetAllBy { - /** - * @var \Spameri\Elastic\ClientProvider - */ - private $clientProvider; - - /** - * @var \Spameri\ElasticQuery\Response\ResultMapper - */ - private $resultMapper; - - private VersionProvider $versionProvider; - - public function __construct( - \Spameri\Elastic\ClientProvider $clientProvider, - \Spameri\ElasticQuery\Response\ResultMapper $resultMapper, - VersionProvider $versionProvider, + private \Spameri\Elastic\ClientProvider $clientProvider, + private \Spameri\ElasticQuery\Response\ResultMapper $resultMapper, + private VersionProvider $versionProvider, ) { - $this->clientProvider = $clientProvider; - $this->resultMapper = $resultMapper; - $this->versionProvider = $versionProvider; } diff --git a/src/Model/GetBy.php b/src/Model/GetBy.php index 585e2403..9bfe447a 100644 --- a/src/Model/GetBy.php +++ b/src/Model/GetBy.php @@ -2,31 +2,15 @@ namespace Spameri\Elastic\Model; -class GetBy +readonly class GetBy { - /** - * @var \Spameri\Elastic\ClientProvider - */ - private $clientProvider; - - /** - * @var \Spameri\ElasticQuery\Response\ResultMapper - */ - private $resultMapper; - - private VersionProvider $versionProvider; - - public function __construct( - \Spameri\Elastic\ClientProvider $clientProvider, - \Spameri\ElasticQuery\Response\ResultMapper $resultMapper, - VersionProvider $versionProvider, + private \Spameri\Elastic\ClientProvider $clientProvider, + private \Spameri\ElasticQuery\Response\ResultMapper $resultMapper, + private VersionProvider $versionProvider, ) { - $this->clientProvider = $clientProvider; - $this->resultMapper = $resultMapper; - $this->versionProvider = $versionProvider; } diff --git a/src/Model/Index.php b/src/Model/Index.php index 9c8acd1d..c29aaad0 100644 --- a/src/Model/Index.php +++ b/src/Model/Index.php @@ -2,21 +2,14 @@ namespace Spameri\Elastic\Model; -class Index +readonly class Index { - private \Spameri\Elastic\ClientProvider $clientProvider; - - private \Spameri\Elastic\Model\VersionProvider $versionProvider; - - public function __construct( - \Spameri\Elastic\ClientProvider $clientProvider, - \Spameri\Elastic\Model\VersionProvider $versionProvider, + private \Spameri\Elastic\ClientProvider $clientProvider, + private \Spameri\Elastic\Model\VersionProvider $versionProvider, ) { - $this->clientProvider = $clientProvider; - $this->versionProvider = $versionProvider; } diff --git a/src/Model/Indices/AddAlias.php b/src/Model/Indices/AddAlias.php index c5ecf353..b0a8a4b2 100644 --- a/src/Model/Indices/AddAlias.php +++ b/src/Model/Indices/AddAlias.php @@ -2,17 +2,13 @@ namespace Spameri\Elastic\Model\Indices; -class AddAlias +readonly class AddAlias { - private \Spameri\Elastic\ClientProvider $clientProvider; - - public function __construct( - \Spameri\Elastic\ClientProvider $clientProvider, + private \Spameri\Elastic\ClientProvider $clientProvider, ) { - $this->clientProvider = $clientProvider; } diff --git a/src/Model/Indices/Close.php b/src/Model/Indices/Close.php index a569e34b..2dfc88f0 100644 --- a/src/Model/Indices/Close.php +++ b/src/Model/Indices/Close.php @@ -2,17 +2,11 @@ namespace Spameri\Elastic\Model\Indices; -class Close +readonly class Close { - /** - * @var \Spameri\Elastic\ClientProvider - */ - private $clientProvider; - - public function __construct( - \Spameri\Elastic\ClientProvider $clientProvider, + private \Spameri\Elastic\ClientProvider $clientProvider, ) { $this->clientProvider = $clientProvider; diff --git a/src/Model/Indices/Create.php b/src/Model/Indices/Create.php index 1bf6d287..650151dd 100644 --- a/src/Model/Indices/Create.php +++ b/src/Model/Indices/Create.php @@ -2,21 +2,14 @@ namespace Spameri\Elastic\Model\Indices; -class Create +readonly class Create { - private \Spameri\Elastic\ClientProvider $clientProvider; - - private \Spameri\Elastic\Model\VersionProvider $versionProvider; - - public function __construct( - \Spameri\Elastic\ClientProvider $clientProvider, - \Spameri\Elastic\Model\VersionProvider $versionProvider, + private \Spameri\Elastic\ClientProvider $clientProvider, + private \Spameri\Elastic\Model\VersionProvider $versionProvider, ) { - $this->clientProvider = $clientProvider; - $this->versionProvider = $versionProvider; } diff --git a/src/Model/Indices/Delete.php b/src/Model/Indices/Delete.php index 411d41fc..7327f525 100644 --- a/src/Model/Indices/Delete.php +++ b/src/Model/Indices/Delete.php @@ -2,20 +2,13 @@ namespace Spameri\Elastic\Model\Indices; -class Delete +readonly class Delete { - /** - * @var \Spameri\Elastic\ClientProvider - */ - private $clientProvider; - - public function __construct( - \Spameri\Elastic\ClientProvider $clientProvider, + private \Spameri\Elastic\ClientProvider $clientProvider, ) { - $this->clientProvider = $clientProvider; } diff --git a/src/Model/Indices/Exists.php b/src/Model/Indices/Exists.php index 61216b70..d29a88ee 100644 --- a/src/Model/Indices/Exists.php +++ b/src/Model/Indices/Exists.php @@ -2,17 +2,13 @@ namespace Spameri\Elastic\Model\Indices; -class Exists +readonly class Exists { - private \Spameri\Elastic\ClientProvider $clientProvider; - - public function __construct( - \Spameri\Elastic\ClientProvider $clientProvider, + private \Spameri\Elastic\ClientProvider $clientProvider, ) { - $this->clientProvider = $clientProvider; } diff --git a/src/Model/Indices/Get.php b/src/Model/Indices/Get.php index 146ab99d..5fb58198 100644 --- a/src/Model/Indices/Get.php +++ b/src/Model/Indices/Get.php @@ -2,20 +2,13 @@ namespace Spameri\Elastic\Model\Indices; -class Get +readonly class Get { - /** - * @var \Spameri\Elastic\ClientProvider - */ - private $clientProvider; - - public function __construct( - \Spameri\Elastic\ClientProvider $clientProvider, + private \Spameri\Elastic\ClientProvider $clientProvider, ) { - $this->clientProvider = $clientProvider; } diff --git a/src/Model/Indices/GetFieldMapping.php b/src/Model/Indices/GetFieldMapping.php index fbb6df3e..90ecd4c7 100644 --- a/src/Model/Indices/GetFieldMapping.php +++ b/src/Model/Indices/GetFieldMapping.php @@ -2,17 +2,13 @@ namespace Spameri\Elastic\Model\Indices; -class GetFieldMapping +readonly class GetFieldMapping { - private \Spameri\Elastic\ClientProvider $clientProvider; - - public function __construct( - \Spameri\Elastic\ClientProvider $clientProvider, + private \Spameri\Elastic\ClientProvider $clientProvider, ) { - $this->clientProvider = $clientProvider; } diff --git a/src/Model/Indices/GetMapping.php b/src/Model/Indices/GetMapping.php index ffebc13f..ba4d17d8 100644 --- a/src/Model/Indices/GetMapping.php +++ b/src/Model/Indices/GetMapping.php @@ -2,24 +2,14 @@ namespace Spameri\Elastic\Model\Indices; -class GetMapping +readonly class GetMapping { - /** - * @var \Spameri\Elastic\ClientProvider - */ - private $clientProvider; - - private \Spameri\Elastic\Model\VersionProvider $versionProvider; - - public function __construct( - \Spameri\Elastic\ClientProvider $clientProvider, - \Spameri\Elastic\Model\VersionProvider $versionProvider, + private \Spameri\Elastic\ClientProvider $clientProvider, + private \Spameri\Elastic\Model\VersionProvider $versionProvider, ) { - $this->clientProvider = $clientProvider; - $this->versionProvider = $versionProvider; } diff --git a/src/Model/Indices/MoveAlias.php b/src/Model/Indices/MoveAlias.php index 34889ca5..8f875f93 100644 --- a/src/Model/Indices/MoveAlias.php +++ b/src/Model/Indices/MoveAlias.php @@ -2,17 +2,13 @@ namespace Spameri\Elastic\Model\Indices; -class MoveAlias +readonly class MoveAlias { - private \Spameri\Elastic\ClientProvider $clientProvider; - - public function __construct( - \Spameri\Elastic\ClientProvider $clientProvider, + private \Spameri\Elastic\ClientProvider $clientProvider, ) { - $this->clientProvider = $clientProvider; } diff --git a/src/Model/Indices/Open.php b/src/Model/Indices/Open.php index 749f0f0d..9d9bab0e 100644 --- a/src/Model/Indices/Open.php +++ b/src/Model/Indices/Open.php @@ -2,20 +2,13 @@ namespace Spameri\Elastic\Model\Indices; -class Open +readonly class Open { - /** - * @var \Spameri\Elastic\ClientProvider - */ - private $clientProvider; - - public function __construct( - \Spameri\Elastic\ClientProvider $clientProvider, + private \Spameri\Elastic\ClientProvider $clientProvider, ) { - $this->clientProvider = $clientProvider; } diff --git a/src/Model/Indices/PutMapping.php b/src/Model/Indices/PutMapping.php index 20a9f2b9..43a8023a 100644 --- a/src/Model/Indices/PutMapping.php +++ b/src/Model/Indices/PutMapping.php @@ -2,24 +2,14 @@ namespace Spameri\Elastic\Model\Indices; -class PutMapping +readonly class PutMapping { - /** - * @var \Spameri\Elastic\ClientProvider - */ - private $clientProvider; - - private \Spameri\Elastic\Model\VersionProvider $versionProvider; - - public function __construct( - \Spameri\Elastic\ClientProvider $clientProvider, - \Spameri\Elastic\Model\VersionProvider $versionProvider, + private \Spameri\Elastic\ClientProvider $clientProvider, + private \Spameri\Elastic\Model\VersionProvider $versionProvider, ) { - $this->clientProvider = $clientProvider; - $this->versionProvider = $versionProvider; } diff --git a/src/Model/Indices/PutSettings.php b/src/Model/Indices/PutSettings.php index e59677cb..0100a7d4 100644 --- a/src/Model/Indices/PutSettings.php +++ b/src/Model/Indices/PutSettings.php @@ -2,20 +2,13 @@ namespace Spameri\Elastic\Model\Indices; -class PutSettings +readonly class PutSettings { - /** - * @var \Spameri\Elastic\ClientProvider - */ - private $clientProvider; - - public function __construct( - \Spameri\Elastic\ClientProvider $clientProvider, + private \Spameri\Elastic\ClientProvider $clientProvider, ) { - $this->clientProvider = $clientProvider; } diff --git a/src/Model/Indices/RemoveAlias.php b/src/Model/Indices/RemoveAlias.php index def191b7..da276336 100644 --- a/src/Model/Indices/RemoveAlias.php +++ b/src/Model/Indices/RemoveAlias.php @@ -2,17 +2,13 @@ namespace Spameri\Elastic\Model\Indices; -class RemoveAlias +readonly class RemoveAlias { - private \Spameri\Elastic\ClientProvider $clientProvider; - - public function __construct( - \Spameri\Elastic\ClientProvider $clientProvider, + private \Spameri\Elastic\ClientProvider $clientProvider, ) { - $this->clientProvider = $clientProvider; } diff --git a/src/Model/InitializeIndex.php b/src/Model/InitializeIndex.php index 0547dc55..210f6d8e 100644 --- a/src/Model/InitializeIndex.php +++ b/src/Model/InitializeIndex.php @@ -2,29 +2,16 @@ namespace Spameri\Elastic\Model; -class InitializeIndex +readonly class InitializeIndex { - private \Spameri\Elastic\Provider\DateTimeProvider $dateTimeProvider; - - private \Spameri\Elastic\Model\Indices\Get $get; - - private \Spameri\Elastic\Model\Indices\Create $create; - - private \Spameri\Elastic\Model\Indices\AddAlias $addAlias; - - public function __construct( - \Spameri\Elastic\Provider\DateTimeProvider $dateTimeProvider, - \Spameri\Elastic\Model\Indices\Get $get, - \Spameri\Elastic\Model\Indices\Create $create, - \Spameri\Elastic\Model\Indices\AddAlias $addAlias, + private \Spameri\Elastic\Provider\DateTimeProvider $dateTimeProvider, + private \Spameri\Elastic\Model\Indices\Get $get, + private \Spameri\Elastic\Model\Indices\Create $create, + private \Spameri\Elastic\Model\Indices\AddAlias $addAlias, ) { - $this->dateTimeProvider = $dateTimeProvider; - $this->get = $get; - $this->create = $create; - $this->addAlias = $addAlias; } diff --git a/src/Model/Insert.php b/src/Model/Insert.php index 5ae8b791..6c148473 100644 --- a/src/Model/Insert.php +++ b/src/Model/Insert.php @@ -2,31 +2,15 @@ namespace Spameri\Elastic\Model; -class Insert +readonly class Insert { - /** - * @var \Spameri\Elastic\Model\Insert\PrepareEntityArray - */ - private $prepareEntityArray; - - /** - * @var \Spameri\Elastic\ClientProvider - */ - private $clientProvider; - - private \Spameri\Elastic\Model\VersionProvider $versionProvider; - - public function __construct( - \Spameri\Elastic\Model\Insert\PrepareEntityArray $prepareEntityArray, - \Spameri\Elastic\ClientProvider $clientProvider, - \Spameri\Elastic\Model\VersionProvider $versionProvider, + private \Spameri\Elastic\Model\Insert\PrepareEntityArray $prepareEntityArray, + private \Spameri\Elastic\ClientProvider $clientProvider, + private \Spameri\Elastic\Model\VersionProvider $versionProvider, ) { - $this->prepareEntityArray = $prepareEntityArray; - $this->clientProvider = $clientProvider; - $this->versionProvider = $versionProvider; } diff --git a/src/Model/Insert/PrepareEntityArray.php b/src/Model/Insert/PrepareEntityArray.php index 7561a503..058177b7 100644 --- a/src/Model/Insert/PrepareEntityArray.php +++ b/src/Model/Insert/PrepareEntityArray.php @@ -5,19 +5,15 @@ class PrepareEntityArray { - /** - * @var \Spameri\Elastic\Model\ServiceLocatorInterface - */ - private $serviceLocator; + public const ENTITY_CLASS = 'entityClass'; private array $insertedEntities; public function __construct( - \Spameri\Elastic\Model\ServiceLocatorInterface $serviceLocator, + private readonly \Spameri\Elastic\Model\ServiceLocatorInterface $serviceLocator, ) { - $this->serviceLocator = $serviceLocator; } diff --git a/src/Model/InsertMultiple.php b/src/Model/InsertMultiple.php index ea1c9551..a1d4062f 100644 --- a/src/Model/InsertMultiple.php +++ b/src/Model/InsertMultiple.php @@ -2,38 +2,16 @@ namespace Spameri\Elastic\Model; -class InsertMultiple +readonly class InsertMultiple { - /** - * @var \Spameri\Elastic\Model\Insert\PrepareEntityArray - */ - private $prepareEntityArray; - - /** - * @var \Spameri\Elastic\ClientProvider - */ - private $clientProvider; - - /** - * @var \Spameri\ElasticQuery\Response\ResultMapper - */ - private $resultMapper; - - private VersionProvider $versionProvider; - - public function __construct( - \Spameri\Elastic\Model\Insert\PrepareEntityArray $prepareEntityArray, - \Spameri\Elastic\ClientProvider $clientProvider, - \Spameri\ElasticQuery\Response\ResultMapper $resultMapper, - \Spameri\Elastic\Model\VersionProvider $versionProvider, + private \Spameri\Elastic\Model\Insert\PrepareEntityArray $prepareEntityArray, + private \Spameri\Elastic\ClientProvider $clientProvider, + private \Spameri\ElasticQuery\Response\ResultMapper $resultMapper, + private \Spameri\Elastic\Model\VersionProvider $versionProvider, ) { - $this->prepareEntityArray = $prepareEntityArray; - $this->clientProvider = $clientProvider; - $this->resultMapper = $resultMapper; - $this->versionProvider = $versionProvider; } diff --git a/src/Model/RestoreIndex.php b/src/Model/RestoreIndex.php index 29ff9c74..b913c5d0 100644 --- a/src/Model/RestoreIndex.php +++ b/src/Model/RestoreIndex.php @@ -5,22 +5,13 @@ class RestoreIndex { - /** - * @var \Symfony\Component\Console\Output\OutputInterface - */ - private $output; - - /** - * @var \Spameri\Elastic\ClientProvider - */ - private $clientProvider; + private \Symfony\Component\Console\Output\OutputInterface $output; public function __construct( - \Spameri\Elastic\ClientProvider $clientProvider, + private readonly \Spameri\Elastic\ClientProvider $clientProvider, ) { - $this->clientProvider = $clientProvider; } diff --git a/src/Model/Scroll.php b/src/Model/Scroll.php index 33eea623..c90ae2a1 100644 --- a/src/Model/Scroll.php +++ b/src/Model/Scroll.php @@ -2,31 +2,15 @@ namespace Spameri\Elastic\Model; -class Scroll +readonly class Scroll { - /** - * @var \Spameri\Elastic\ClientProvider - */ - private $clientProvider; - - /** - * @var \Spameri\ElasticQuery\Response\ResultMapper - */ - private $resultMapper; - - private VersionProvider $versionProvider; - - public function __construct( - \Spameri\Elastic\ClientProvider $clientProvider, - \Spameri\ElasticQuery\Response\ResultMapper $resultMapper, - VersionProvider $versionProvider, + private \Spameri\Elastic\ClientProvider $clientProvider, + private \Spameri\ElasticQuery\Response\ResultMapper $resultMapper, + private VersionProvider $versionProvider, ) { - $this->clientProvider = $clientProvider; - $this->resultMapper = $resultMapper; - $this->versionProvider = $versionProvider; } diff --git a/src/Model/Search.php b/src/Model/Search.php index 783eef7d..ffb6ea68 100644 --- a/src/Model/Search.php +++ b/src/Model/Search.php @@ -2,31 +2,15 @@ namespace Spameri\Elastic\Model; -class Search +readonly class Search { - /** - * @var \Spameri\Elastic\ClientProvider - */ - private $clientProvider; - - /** - * @var \Spameri\ElasticQuery\Response\ResultMapper - */ - private $resultMapper; - - private VersionProvider $versionProvider; - - public function __construct( - \Spameri\Elastic\ClientProvider $clientProvider, - \Spameri\ElasticQuery\Response\ResultMapper $resultMapper, - VersionProvider $versionProvider, + private \Spameri\Elastic\ClientProvider $clientProvider, + private \Spameri\ElasticQuery\Response\ResultMapper $resultMapper, + private VersionProvider $versionProvider, ) { - $this->clientProvider = $clientProvider; - $this->resultMapper = $resultMapper; - $this->versionProvider = $versionProvider; } diff --git a/src/Model/ServiceLocator.php b/src/Model/ServiceLocator.php index b1b910ed..0839ea73 100644 --- a/src/Model/ServiceLocator.php +++ b/src/Model/ServiceLocator.php @@ -5,11 +5,6 @@ class ServiceLocator implements ServiceLocatorInterface { - /** - * @var \Nette\DI\Container - */ - private $container; - /** * @var array */ @@ -17,10 +12,9 @@ class ServiceLocator implements ServiceLocatorInterface public function __construct( - \Nette\DI\Container $container, + private readonly \Nette\DI\Container $container, ) { - $this->container = $container; $this->services = $container->findByType(\Spameri\Elastic\Model\ServiceInterface::class); } @@ -71,4 +65,5 @@ public function locateByIndex(string $index): \Spameri\Elastic\Model\ServiceInte return null; } + } diff --git a/src/Model/TypeToNewIndex/DocumentMigrateStatus.php b/src/Model/TypeToNewIndex/DocumentMigrateStatus.php index 07163592..cbf12cde 100644 --- a/src/Model/TypeToNewIndex/DocumentMigrateStatus.php +++ b/src/Model/TypeToNewIndex/DocumentMigrateStatus.php @@ -8,7 +8,7 @@ class DocumentMigrateStatus /** * @var array */ - private $storage = []; + private array $storage = []; public function add( diff --git a/src/Model/TypeToNewIndex/Migrate.php b/src/Model/TypeToNewIndex/Migrate.php index 33fdd0b8..b06318bd 100644 --- a/src/Model/TypeToNewIndex/Migrate.php +++ b/src/Model/TypeToNewIndex/Migrate.php @@ -5,100 +5,24 @@ class Migrate { - /** - * @var \Symfony\Component\Console\Output\OutputInterface $output - */ - private $output; - - /** - * @var \Spameri\Elastic\Model\TypeToNewIndex\DocumentMigrateStatus - */ - private $documentMigrateStatus; - - /** - * @var \Spameri\Elastic\ClientProvider - */ - private $clientProvider; - - /** - * @var \Spameri\Elastic\Provider\DateTimeProvider - */ - private $dateTimeProvider; - - /** - * @var \Spameri\Elastic\Model\Delete - */ - private $delete; - - /** - * @var \Spameri\Elastic\Model\Get - */ - private $get; - - /** - * @var \Spameri\Elastic\Model\Indices\Close - */ - private $close; - - /** - * @var \Spameri\Elastic\Model\Indices\GetMapping - */ - private $getMapping; - - /** - * @var \Spameri\Elastic\Model\Indices\PutMapping - */ - private $putMapping; - - /** - * @var \Spameri\Elastic\Model\Search - */ - private $search; - - /** - * @var \Spameri\Elastic\Model\Indices\Create - */ - private $create; - - /** - * @var \Spameri\Elastic\Model\Indices\Get - */ - private $indicesGet; - - private \Spameri\Elastic\Model\Indices\AddAlias $addAlias; - - private \Spameri\Elastic\Model\VersionProvider $versionProvider; - + private \Symfony\Component\Console\Output\OutputInterface $output; public function __construct( - DocumentMigrateStatus $documentMigrateStatus, - \Spameri\Elastic\ClientProvider $clientProvider, - \Spameri\Elastic\Provider\DateTimeProvider $dateTimeProvider, - \Spameri\Elastic\Model\Delete $delete, - \Spameri\Elastic\Model\Get $get, - \Spameri\Elastic\Model\Indices\Close $close, - \Spameri\Elastic\Model\Indices\GetMapping $getMapping, - \Spameri\Elastic\Model\Indices\PutMapping $putMapping, - \Spameri\Elastic\Model\Search $search, - \Spameri\Elastic\Model\Indices\Create $create, - \Spameri\Elastic\Model\Indices\Get $indicesGet, - \Spameri\Elastic\Model\Indices\AddAlias $addAlias, - \Spameri\Elastic\Model\VersionProvider $versionProvider, + private readonly DocumentMigrateStatus $documentMigrateStatus, + private readonly \Spameri\Elastic\ClientProvider $clientProvider, + private readonly \Spameri\Elastic\Provider\DateTimeProvider $dateTimeProvider, + private readonly \Spameri\Elastic\Model\Delete $delete, + private readonly \Spameri\Elastic\Model\Get $get, + private readonly \Spameri\Elastic\Model\Indices\Close $close, + private readonly \Spameri\Elastic\Model\Indices\GetMapping $getMapping, + private readonly \Spameri\Elastic\Model\Indices\PutMapping $putMapping, + private readonly \Spameri\Elastic\Model\Search $search, + private readonly \Spameri\Elastic\Model\Indices\Create $create, + private readonly \Spameri\Elastic\Model\Indices\Get $indicesGet, + private readonly \Spameri\Elastic\Model\Indices\AddAlias $addAlias, + private readonly \Spameri\Elastic\Model\VersionProvider $versionProvider, ) { - $this->documentMigrateStatus = $documentMigrateStatus; - $this->clientProvider = $clientProvider; - $this->dateTimeProvider = $dateTimeProvider; - $this->delete = $delete; - $this->get = $get; - $this->close = $close; - $this->getMapping = $getMapping; - $this->putMapping = $putMapping; - $this->search = $search; - $this->create = $create; - $this->indicesGet = $indicesGet; - $this->addAlias = $addAlias; - $this->versionProvider = $versionProvider; } diff --git a/src/Model/VersionProvider.php b/src/Model/VersionProvider.php index c2de2b96..93ebc951 100644 --- a/src/Model/VersionProvider.php +++ b/src/Model/VersionProvider.php @@ -2,17 +2,13 @@ namespace Spameri\Elastic\Model; -class VersionProvider +readonly class VersionProvider { - private int $versionNumber; - - public function __construct( - int $versionNumber = \Spameri\ElasticQuery\Response\Result\Version::ELASTIC_VERSION_ID_7, + private int $versionNumber = \Spameri\ElasticQuery\Response\Result\Version::ELASTIC_VERSION_ID_7, ) { - $this->versionNumber = $versionNumber; } diff --git a/src/Provider/DateTimeProvider.php b/src/Provider/DateTimeProvider.php index e125fff5..6f1e46ab 100644 --- a/src/Provider/DateTimeProvider.php +++ b/src/Provider/DateTimeProvider.php @@ -2,20 +2,13 @@ namespace Spameri\Elastic\Provider; -class DateTimeProvider +readonly class DateTimeProvider { - /** - * @var \DateTimeImmutable - */ - private $constant; - - public function __construct( - \DateTimeImmutable $constant, + private \DateTimeImmutable $constant, ) { - $this->constant = $constant; } diff --git a/src/Settings.php b/src/Settings.php index 04dbc8a3..9df25984 100644 --- a/src/Settings.php +++ b/src/Settings.php @@ -2,37 +2,18 @@ namespace Spameri\Elastic; -class Settings +readonly class Settings { - /** - * @var string - */ - private $host; - - /** - * @var int - */ - private $port; - - /** - * @var array - */ - private $headers; - - /** * @param array $headers */ public function __construct( - string $host, - int $port, - array $headers, + private string $host, + private int $port, + private array $headers, ) { - $this->host = $host; - $this->port = $port; - $this->headers = $headers; } diff --git a/src/Settings/NeonSettingsProvider.php b/src/Settings/NeonSettingsProvider.php index dd8d104f..8e69a5e7 100644 --- a/src/Settings/NeonSettingsProvider.php +++ b/src/Settings/NeonSettingsProvider.php @@ -2,37 +2,18 @@ namespace Spameri\Elastic\Settings; -class NeonSettingsProvider implements \Spameri\Elastic\SettingsProviderInterface +readonly class NeonSettingsProvider implements \Spameri\Elastic\SettingsProviderInterface { - /** - * @var string - */ - private $host; - - /** - * @var int - */ - private $port; - - /** - * @var array - */ - private $headers; - - /** * @param array $headers */ public function __construct( - string $host, - int $port, - array $headers = [], + private string $host, + private int $port, + private array $headers = [], ) { - $this->host = $host; - $this->port = $port; - $this->headers = $headers; } From ca620d26096f7c7d555a7140c501d796429b1408 Mon Sep 17 00:00:00 2001 From: Spamer Date: Thu, 4 Apr 2024 16:26:52 +0200 Subject: [PATCH 22/37] Used new namespace for elastic exceptions --- src/Commands/TypeToNewIndex.php | 2 +- src/Model/Aggregate.php | 2 +- src/Model/Delete.php | 4 ++-- src/Model/DeleteMultiple.php | 4 ++-- src/Model/Get.php | 2 +- src/Model/GetBy.php | 2 +- src/Model/Index.php | 4 ++-- src/Model/Indices/AddAlias.php | 8 ++++++-- src/Model/Indices/Close.php | 2 +- src/Model/Indices/Create.php | 2 +- src/Model/Indices/Delete.php | 2 +- src/Model/Indices/Exists.php | 2 +- src/Model/Indices/Get.php | 2 +- src/Model/Indices/GetFieldMapping.php | 2 +- src/Model/Indices/GetMapping.php | 2 +- src/Model/Indices/MoveAlias.php | 2 +- src/Model/Indices/Open.php | 2 +- src/Model/Indices/PutMapping.php | 2 +- src/Model/Indices/PutSettings.php | 2 +- src/Model/Indices/RemoveAlias.php | 2 +- src/Model/Insert.php | 4 ++-- src/Model/InsertMultiple.php | 4 ++-- src/Model/Scroll.php | 4 ++-- src/Model/Search.php | 2 +- src/Model/TypeToNewIndex/Migrate.php | 4 ++-- 25 files changed, 37 insertions(+), 33 deletions(-) diff --git a/src/Commands/TypeToNewIndex.php b/src/Commands/TypeToNewIndex.php index 219a7ffe..f57fe651 100644 --- a/src/Commands/TypeToNewIndex.php +++ b/src/Commands/TypeToNewIndex.php @@ -39,7 +39,7 @@ protected function configure(): void /** - * @throws \Elasticsearch\Common\Exceptions\ElasticsearchException + * @throws \Elastic\Elasticsearch\Exception\ElasticsearchException */ protected function execute( \Symfony\Component\Console\Input\InputInterface $input, diff --git a/src/Model/Aggregate.php b/src/Model/Aggregate.php index db8a66ce..8e84d3d0 100644 --- a/src/Model/Aggregate.php +++ b/src/Model/Aggregate.php @@ -42,7 +42,7 @@ public function execute( ) ; - } catch (\Elasticsearch\Common\Exceptions\ElasticsearchException $exception) { + } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { throw new \Spameri\Elastic\Exception\ElasticSearch($exception->getMessage()); } diff --git a/src/Model/Delete.php b/src/Model/Delete.php index 71fe91f0..8e55c9e9 100644 --- a/src/Model/Delete.php +++ b/src/Model/Delete.php @@ -44,7 +44,7 @@ public function execute( ) ; - } catch (\Elasticsearch\Common\Exceptions\ElasticsearchException $exception) { + } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { throw new \Spameri\Elastic\Exception\ElasticSearch($exception->getMessage()); } @@ -57,7 +57,7 @@ public function execute( ) ; - } catch (\Elasticsearch\Common\Exceptions\ElasticsearchException $exception) { + } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { throw new \Spameri\Elastic\Exception\ElasticSearch($exception->getMessage()); } diff --git a/src/Model/DeleteMultiple.php b/src/Model/DeleteMultiple.php index 48fefd1c..5fb0399a 100644 --- a/src/Model/DeleteMultiple.php +++ b/src/Model/DeleteMultiple.php @@ -50,7 +50,7 @@ public function execute( try { $response = $this->clientProvider->client()->bulk($document->toArray()); - } catch (\Elasticsearch\Common\Exceptions\ElasticsearchException $exception) { + } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { throw new \Spameri\Elastic\Exception\ElasticSearch($exception->getMessage()); } @@ -63,7 +63,7 @@ public function execute( ) ; - } catch (\Elasticsearch\Common\Exceptions\ElasticsearchException $exception) { + } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { throw new \Spameri\Elastic\Exception\ElasticSearch($exception->getMessage()); } diff --git a/src/Model/Get.php b/src/Model/Get.php index b3135825..b7dfe54a 100644 --- a/src/Model/Get.php +++ b/src/Model/Get.php @@ -47,7 +47,7 @@ public function execute( ) ; - } catch (\Elasticsearch\Common\Exceptions\ElasticsearchException $exception) { + } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { throw new \Spameri\Elastic\Exception\ElasticSearch($exception->getMessage()); } diff --git a/src/Model/GetBy.php b/src/Model/GetBy.php index 9bfe447a..fced2c98 100644 --- a/src/Model/GetBy.php +++ b/src/Model/GetBy.php @@ -44,7 +44,7 @@ public function execute( ) ; - } catch (\Elasticsearch\Common\Exceptions\ElasticsearchException $exception) { + } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { throw new \Spameri\Elastic\Exception\ElasticSearch($exception->getMessage()); } diff --git a/src/Model/Index.php b/src/Model/Index.php index c29aaad0..42fa90cd 100644 --- a/src/Model/Index.php +++ b/src/Model/Index.php @@ -43,7 +43,7 @@ public function execute( ) ; - } catch (\Elasticsearch\Common\Exceptions\ElasticsearchException $exception) { + } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { throw new \Spameri\Elastic\Exception\ElasticSearch($exception->getMessage()); } @@ -56,7 +56,7 @@ public function execute( ) ; - } catch (\Elasticsearch\Common\Exceptions\ElasticsearchException $exception) { + } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { throw new \Spameri\Elastic\Exception\ElasticSearch($exception->getMessage()); } diff --git a/src/Model/Indices/AddAlias.php b/src/Model/Indices/AddAlias.php index b0a8a4b2..5a036936 100644 --- a/src/Model/Indices/AddAlias.php +++ b/src/Model/Indices/AddAlias.php @@ -27,7 +27,11 @@ public function execute(string $alias, string $index): array throw new \Spameri\Elastic\Exception\AliasAlreadyExists($alias); - } catch (\Elasticsearch\Common\Exceptions\Missing404Exception $exception) { + } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { + if ($exception->getCode() !== 404) { + throw new \Spameri\Elastic\Exception\ElasticSearch($exception->getMessage()); + } + return $this->clientProvider->client()->indices()->putAlias( ( new \Spameri\ElasticQuery\Document( @@ -53,7 +57,7 @@ public function execute(string $alias, string $index): array ; } - } catch (\Elasticsearch\Common\Exceptions\ElasticsearchException $exception) { + } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { throw new \Spameri\Elastic\Exception\ElasticSearch($exception->getMessage()); } } diff --git a/src/Model/Indices/Close.php b/src/Model/Indices/Close.php index 2dfc88f0..90084f6b 100644 --- a/src/Model/Indices/Close.php +++ b/src/Model/Indices/Close.php @@ -29,7 +29,7 @@ public function execute( return TRUE; } - } catch (\Elasticsearch\Common\Exceptions\ElasticsearchException $exception) { + } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { throw new \Spameri\Elastic\Exception\ElasticSearch($exception->getMessage()); } diff --git a/src/Model/Indices/Create.php b/src/Model/Indices/Create.php index 650151dd..3ead7807 100644 --- a/src/Model/Indices/Create.php +++ b/src/Model/Indices/Create.php @@ -55,7 +55,7 @@ public function execute( ) ; - } catch (\Elasticsearch\Common\Exceptions\ElasticsearchException $exception) { + } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { throw new \Spameri\Elastic\Exception\ElasticSearch($exception->getMessage()); } } diff --git a/src/Model/Indices/Delete.php b/src/Model/Indices/Delete.php index 7327f525..dbf17eed 100644 --- a/src/Model/Indices/Delete.php +++ b/src/Model/Indices/Delete.php @@ -29,7 +29,7 @@ public function execute( ) ; - } catch (\Elasticsearch\Common\Exceptions\ElasticsearchException $exception) { + } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { throw new \Spameri\Elastic\Exception\ElasticSearch($exception->getMessage()); } } diff --git a/src/Model/Indices/Exists.php b/src/Model/Indices/Exists.php index d29a88ee..dd7df18a 100644 --- a/src/Model/Indices/Exists.php +++ b/src/Model/Indices/Exists.php @@ -26,7 +26,7 @@ public function execute( ) ; - } catch (\Elasticsearch\Common\Exceptions\ElasticsearchException $exception) { + } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { throw new \Spameri\Elastic\Exception\ElasticSearch($exception->getMessage()); } } diff --git a/src/Model/Indices/Get.php b/src/Model/Indices/Get.php index 5fb58198..5ce15049 100644 --- a/src/Model/Indices/Get.php +++ b/src/Model/Indices/Get.php @@ -32,7 +32,7 @@ public function execute( return $result; - } catch (\Elasticsearch\Common\Exceptions\ElasticsearchException $exception) { + } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { throw new \Spameri\Elastic\Exception\ElasticSearch($exception->getMessage()); } } diff --git a/src/Model/Indices/GetFieldMapping.php b/src/Model/Indices/GetFieldMapping.php index 90ecd4c7..f9ec1866 100644 --- a/src/Model/Indices/GetFieldMapping.php +++ b/src/Model/Indices/GetFieldMapping.php @@ -34,7 +34,7 @@ public function execute( ) ; - } catch (\Elasticsearch\Common\Exceptions\ElasticsearchException $exception) { + } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { throw new \Spameri\Elastic\Exception\ElasticSearch($exception->getMessage()); } } diff --git a/src/Model/Indices/GetMapping.php b/src/Model/Indices/GetMapping.php index ba4d17d8..a8b868c3 100644 --- a/src/Model/Indices/GetMapping.php +++ b/src/Model/Indices/GetMapping.php @@ -40,7 +40,7 @@ public function execute( return $this->clientProvider->client()->indices()->getMapping($documentArray); - } catch (\Elasticsearch\Common\Exceptions\ElasticsearchException $exception) { + } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { throw new \Spameri\Elastic\Exception\ElasticSearch($exception->getMessage()); } } diff --git a/src/Model/Indices/MoveAlias.php b/src/Model/Indices/MoveAlias.php index 8f875f93..d9b65530 100644 --- a/src/Model/Indices/MoveAlias.php +++ b/src/Model/Indices/MoveAlias.php @@ -43,7 +43,7 @@ public function execute(string $alias, string $indexFrom, string $indexTo): arra ) ; - } catch (\Elasticsearch\Common\Exceptions\ElasticsearchException $exception) { + } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { throw new \Spameri\Elastic\Exception\ElasticSearch($exception->getMessage()); } } diff --git a/src/Model/Indices/Open.php b/src/Model/Indices/Open.php index 9d9bab0e..b9c9d2f1 100644 --- a/src/Model/Indices/Open.php +++ b/src/Model/Indices/Open.php @@ -28,7 +28,7 @@ public function execute( return TRUE; } - } catch (\Elasticsearch\Common\Exceptions\ElasticsearchException $exception) { + } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { throw new \Spameri\Elastic\Exception\ElasticSearch($exception->getMessage()); } diff --git a/src/Model/Indices/PutMapping.php b/src/Model/Indices/PutMapping.php index 43a8023a..6a5f18ed 100644 --- a/src/Model/Indices/PutMapping.php +++ b/src/Model/Indices/PutMapping.php @@ -52,7 +52,7 @@ public function execute( ) ; - } catch (\Elasticsearch\Common\Exceptions\ElasticsearchException $exception) { + } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { throw new \Spameri\Elastic\Exception\ElasticSearch($exception->getMessage()); } } diff --git a/src/Model/Indices/PutSettings.php b/src/Model/Indices/PutSettings.php index 0100a7d4..dbe6ca11 100644 --- a/src/Model/Indices/PutSettings.php +++ b/src/Model/Indices/PutSettings.php @@ -32,7 +32,7 @@ public function execute( ) ; - } catch (\Elasticsearch\Common\Exceptions\ElasticsearchException $exception) { + } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { throw new \Spameri\Elastic\Exception\ElasticSearch($exception->getMessage()); } } diff --git a/src/Model/Indices/RemoveAlias.php b/src/Model/Indices/RemoveAlias.php index da276336..5f424ff7 100644 --- a/src/Model/Indices/RemoveAlias.php +++ b/src/Model/Indices/RemoveAlias.php @@ -39,7 +39,7 @@ public function execute(string $alias, string $index): array ) ; - } catch (\Elasticsearch\Common\Exceptions\ElasticsearchException $exception) { + } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { throw new \Spameri\Elastic\Exception\ElasticSearch($exception->getMessage()); } } diff --git a/src/Model/Insert.php b/src/Model/Insert.php index 6c148473..06c161bc 100644 --- a/src/Model/Insert.php +++ b/src/Model/Insert.php @@ -48,7 +48,7 @@ public function execute( ) ; - } catch (\Elasticsearch\Common\Exceptions\ElasticsearchException $exception) { + } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { throw new \Spameri\Elastic\Exception\ElasticSearch($exception->getMessage()); } @@ -61,7 +61,7 @@ public function execute( ) ; - } catch (\Elasticsearch\Common\Exceptions\ElasticsearchException $exception) { + } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { throw new \Spameri\Elastic\Exception\ElasticSearch($exception->getMessage()); } diff --git a/src/Model/InsertMultiple.php b/src/Model/InsertMultiple.php index a1d4062f..035422ec 100644 --- a/src/Model/InsertMultiple.php +++ b/src/Model/InsertMultiple.php @@ -52,7 +52,7 @@ public function execute( try { $response = $this->clientProvider->client()->bulk($document->toArray()); - } catch (\Elasticsearch\Common\Exceptions\ElasticsearchException $exception) { + } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { throw new \Spameri\Elastic\Exception\ElasticSearch($exception->getMessage()); } @@ -64,7 +64,7 @@ public function execute( ->toArray(), ) ; - } catch (\Elasticsearch\Common\Exceptions\ElasticsearchException $exception) { + } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { throw new \Spameri\Elastic\Exception\ElasticSearch($exception->getMessage()); } diff --git a/src/Model/Scroll.php b/src/Model/Scroll.php index c90ae2a1..2b46d952 100644 --- a/src/Model/Scroll.php +++ b/src/Model/Scroll.php @@ -77,7 +77,7 @@ public function execute( ; } - } catch (\Elasticsearch\Common\Exceptions\ElasticsearchException $exception) { + } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { throw new \Spameri\Elastic\Exception\ElasticSearch($exception->getMessage()); } @@ -106,7 +106,7 @@ public function closeScroll( ) ; - } catch (\Elasticsearch\Common\Exceptions\ElasticsearchException $exception) { + } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { throw new \Spameri\Elastic\Exception\ElasticSearch($exception->getMessage()); } } diff --git a/src/Model/Search.php b/src/Model/Search.php index ffb6ea68..5e9840a8 100644 --- a/src/Model/Search.php +++ b/src/Model/Search.php @@ -44,7 +44,7 @@ public function execute( ) ; - } catch (\Elasticsearch\Common\Exceptions\ElasticsearchException $exception) { + } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { throw new \Spameri\Elastic\Exception\ElasticSearch($exception->getMessage()); } diff --git a/src/Model/TypeToNewIndex/Migrate.php b/src/Model/TypeToNewIndex/Migrate.php index b06318bd..38e2cc6b 100644 --- a/src/Model/TypeToNewIndex/Migrate.php +++ b/src/Model/TypeToNewIndex/Migrate.php @@ -35,7 +35,7 @@ public function setOutput( /** - * @throws \Elasticsearch\Common\Exceptions\ElasticsearchException + * @throws \Elastic\Elasticsearch\Exception\ElasticsearchException */ public function execute( string $indexFrom, @@ -164,7 +164,7 @@ public function execute( /** - * @throws \Elasticsearch\Common\Exceptions\ElasticsearchException + * @throws \Elastic\Elasticsearch\Exception\ElasticsearchException */ public function processHit( string $indexTo, From 8e5675f62d824c598fddd1a6972a7d9355fa6e2a Mon Sep 17 00:00:00 2001 From: Spamer Date: Thu, 4 Apr 2024 16:30:53 +0200 Subject: [PATCH 23/37] converted to strict types --- src/Entity/AbstractImport.php | 5 +---- src/Entity/AbstractValueCollection.php | 10 ++-------- .../Collection/AbstractCachedEntityCollection.php | 4 ++-- src/Entity/Collection/AbstractEntityCollection.php | 2 +- src/Entity/DateTimeInterface.php | 2 +- src/Entity/ElasticEntityCollectionInterface.php | 2 +- src/Entity/EntityCollectionInterface.php | 2 +- src/Entity/Import/ValidationObjectInterface.php | 5 +---- src/Entity/Import/ValidationPropertyInterface.php | 11 ++--------- src/Entity/Property/Date.php | 8 ++------ src/Entity/Property/DateTime.php | 8 ++------ src/Entity/ValueInterface.php | 5 +---- src/Import/LoggerHandlerInterface.php | 5 +---- src/Import/PrepareImportDataInterface.php | 5 +---- src/Import/Response/SimpleResponse.php | 7 ++----- src/Import/ResponseInterface.php | 5 +---- src/Import/Run/LoggerHandler.php | 5 +---- src/Import/Run/NullLoggerHandler.php | 5 +---- src/Model/Indices/Close.php | 1 - 19 files changed, 24 insertions(+), 73 deletions(-) diff --git a/src/Entity/AbstractImport.php b/src/Entity/AbstractImport.php index adda3a22..2c5fec0e 100644 --- a/src/Entity/AbstractImport.php +++ b/src/Entity/AbstractImport.php @@ -12,10 +12,7 @@ public function __construct( } - /** - * @return int|string - */ - public function key() + public function key(): int|string { return $this->key; } diff --git a/src/Entity/AbstractValueCollection.php b/src/Entity/AbstractValueCollection.php index af2f72ef..e1eb910a 100644 --- a/src/Entity/AbstractValueCollection.php +++ b/src/Entity/AbstractValueCollection.php @@ -30,19 +30,13 @@ public function add( } - /** - * @param mixed $key - */ - public function remove($key): void + public function remove(mixed $key): void { unset($this->collection[$key]); } - /** - * @param mixed $key - */ - public function get($key): \Spameri\Elastic\Entity\ValueInterface|null + public function get(mixed $key): \Spameri\Elastic\Entity\ValueInterface|null { if ( ! isset($this->collection[$key])) { return NULL; diff --git a/src/Entity/Collection/AbstractCachedEntityCollection.php b/src/Entity/Collection/AbstractCachedEntityCollection.php index cc9e377b..ba730cbc 100644 --- a/src/Entity/Collection/AbstractCachedEntityCollection.php +++ b/src/Entity/Collection/AbstractCachedEntityCollection.php @@ -11,7 +11,7 @@ abstract class AbstractCachedEntityCollection extends AbstractEntityCollection abstract public function initialize(): void; public function entity( - string $key, + string|int $key, ): \Spameri\Elastic\Entity\EntityInterface|null { $this->initialize(); @@ -21,7 +21,7 @@ public function entity( public function remove( - string $key, + string|int $key, ): void { $this->initialize(); diff --git a/src/Entity/Collection/AbstractEntityCollection.php b/src/Entity/Collection/AbstractEntityCollection.php index 941f0a24..4b206a97 100644 --- a/src/Entity/Collection/AbstractEntityCollection.php +++ b/src/Entity/Collection/AbstractEntityCollection.php @@ -55,7 +55,7 @@ public function entity( public function remove( - string $key, + string|int $key, ): void { unset($this->collection[$key]); diff --git a/src/Entity/DateTimeInterface.php b/src/Entity/DateTimeInterface.php index 9aea848c..0359fb62 100644 --- a/src/Entity/DateTimeInterface.php +++ b/src/Entity/DateTimeInterface.php @@ -6,6 +6,6 @@ interface DateTimeInterface extends \DateTimeInterface { #[\ReturnTypeWillChange] - public function format($format = NULL); + public function format(string $format = ''); } diff --git a/src/Entity/ElasticEntityCollectionInterface.php b/src/Entity/ElasticEntityCollectionInterface.php index aeb2f9bf..b0a81afa 100644 --- a/src/Entity/ElasticEntityCollectionInterface.php +++ b/src/Entity/ElasticEntityCollectionInterface.php @@ -6,7 +6,7 @@ interface ElasticEntityCollectionInterface extends \IteratorAggregate { public function add( - \Spameri\Elastic\Entity\ElasticEntityInterface $entity, + \Spameri\Elastic\Entity\ElasticEntityInterface $elasticEntity, ): void; diff --git a/src/Entity/EntityCollectionInterface.php b/src/Entity/EntityCollectionInterface.php index 4623b4db..60564d60 100644 --- a/src/Entity/EntityCollectionInterface.php +++ b/src/Entity/EntityCollectionInterface.php @@ -16,7 +16,7 @@ public function entity( public function remove( - string $key, + string|int $key, ): void; diff --git a/src/Entity/Import/ValidationObjectInterface.php b/src/Entity/Import/ValidationObjectInterface.php index 0cf95eb4..4909d577 100644 --- a/src/Entity/Import/ValidationObjectInterface.php +++ b/src/Entity/Import/ValidationObjectInterface.php @@ -5,10 +5,7 @@ interface ValidationObjectInterface extends \Spameri\ElasticQuery\Entity\ArrayInterface { - /** - * @return mixed - */ - public function key(); + public function key(): mixed; /** diff --git a/src/Entity/Import/ValidationPropertyInterface.php b/src/Entity/Import/ValidationPropertyInterface.php index 4e932e88..53d63ed2 100644 --- a/src/Entity/Import/ValidationPropertyInterface.php +++ b/src/Entity/Import/ValidationPropertyInterface.php @@ -5,15 +5,8 @@ interface ValidationPropertyInterface { - /** - * @return mixed - */ - public function key(); + public function key(): mixed; - - /** - * @return mixed - */ - public function getValue(); + public function getValue(): mixed; } diff --git a/src/Entity/Property/Date.php b/src/Entity/Property/Date.php index b0924cd6..0c49c765 100644 --- a/src/Entity/Property/Date.php +++ b/src/Entity/Property/Date.php @@ -8,13 +8,9 @@ class Date extends \Nette\Utils\DateTime implements \Spameri\Elastic\Entity\Date public const FORMAT = 'Y-m-d'; - /** - * @param string|null $format - * @return string - */ - public function format($format = NULL): string + public function format(string $format = ''): string { - if ( ! $format) { + if ($format === '') { $format = self::FORMAT; } diff --git a/src/Entity/Property/DateTime.php b/src/Entity/Property/DateTime.php index 9e2c9b61..5df6690e 100644 --- a/src/Entity/Property/DateTime.php +++ b/src/Entity/Property/DateTime.php @@ -9,14 +9,10 @@ class DateTime extends \Nette\Utils\DateTime implements \Spameri\Elastic\Entity\ public const INDEX_FORMAT = 'Y-m-d_H-i-s'; - /** - * @param string|null $format - * @return string - */ #[\ReturnTypeWillChange] - public function format($format = NULL) + public function format(string $format = ''): string { - if (\is_null($format)) { + if ($format === '') { $format = self::FORMAT; } diff --git a/src/Entity/ValueInterface.php b/src/Entity/ValueInterface.php index 4bfc69f1..c7cd0ed0 100644 --- a/src/Entity/ValueInterface.php +++ b/src/Entity/ValueInterface.php @@ -5,9 +5,6 @@ interface ValueInterface { - /** - * @return mixed - */ - public function value(); + public function value(): mixed; } diff --git a/src/Import/LoggerHandlerInterface.php b/src/Import/LoggerHandlerInterface.php index 5b587ba8..26d8f7a5 100644 --- a/src/Import/LoggerHandlerInterface.php +++ b/src/Import/LoggerHandlerInterface.php @@ -5,11 +5,8 @@ interface LoggerHandlerInterface { - /** - * @param mixed $item - */ public function logItemStart( - $item, + mixed $item, ): void; diff --git a/src/Import/PrepareImportDataInterface.php b/src/Import/PrepareImportDataInterface.php index c3cfc509..48bc3b58 100644 --- a/src/Import/PrepareImportDataInterface.php +++ b/src/Import/PrepareImportDataInterface.php @@ -5,11 +5,8 @@ interface PrepareImportDataInterface { - /** - * @param mixed $entityData - */ public function prepare( - $entityData, + mixed $entityData, ): \Spameri\Elastic\Entity\AbstractImport; } diff --git a/src/Import/Response/SimpleResponse.php b/src/Import/Response/SimpleResponse.php index faea2cac..94e657cf 100644 --- a/src/Import/Response/SimpleResponse.php +++ b/src/Import/Response/SimpleResponse.php @@ -15,14 +15,11 @@ public function __construct( public function isSuccessful(): bool { - return $this->response ? TRUE : FALSE; + return (bool) $this->response; } - /** - * @return mixed - */ - public function getResponse() + public function getResponse(): mixed { return $this->response; } diff --git a/src/Import/ResponseInterface.php b/src/Import/ResponseInterface.php index 9c080735..09f64dba 100644 --- a/src/Import/ResponseInterface.php +++ b/src/Import/ResponseInterface.php @@ -14,10 +14,7 @@ public function __construct( public function isSuccessful(): bool; - /** - * @return mixed - */ - public function getResponse(); + public function getResponse(): mixed; public function getEntity(): \Spameri\Elastic\Entity\AbstractImport; diff --git a/src/Import/Run/LoggerHandler.php b/src/Import/Run/LoggerHandler.php index b82df332..33f0df62 100644 --- a/src/Import/Run/LoggerHandler.php +++ b/src/Import/Run/LoggerHandler.php @@ -12,10 +12,7 @@ public function __construct( } - /** - * @param mixed $item - */ - public function logItemStart($item): void + public function logItemStart(mixed $item): void { $this->logger->debug('Processing item ' . \Tracy\Dumper::toText($item)); } diff --git a/src/Import/Run/NullLoggerHandler.php b/src/Import/Run/NullLoggerHandler.php index 9401bab8..0f252dfc 100644 --- a/src/Import/Run/NullLoggerHandler.php +++ b/src/Import/Run/NullLoggerHandler.php @@ -6,10 +6,7 @@ class NullLoggerHandler implements \Spameri\Elastic\Import\LoggerHandlerInterfac { // phpcs:disable - /** - * @param mixed $item - */ - public function logItemStart($item): void + public function logItemStart(mixed $item): void { // do nothing; } diff --git a/src/Model/Indices/Close.php b/src/Model/Indices/Close.php index 90084f6b..eef07b97 100644 --- a/src/Model/Indices/Close.php +++ b/src/Model/Indices/Close.php @@ -9,7 +9,6 @@ public function __construct( private \Spameri\Elastic\ClientProvider $clientProvider, ) { - $this->clientProvider = $clientProvider; } From c4ab369881f34ec003613f6cd6d3736fdab2f851 Mon Sep 17 00:00:00 2001 From: Spamer Date: Thu, 4 Apr 2024 16:34:04 +0200 Subject: [PATCH 24/37] elastic now returns object, we must convert it to array so existing code can stay --- src/Model/Aggregate.php | 2 +- src/Model/Delete.php | 2 +- src/Model/DeleteMultiple.php | 2 +- src/Model/Get.php | 2 +- src/Model/GetBy.php | 2 +- src/Model/Index.php | 2 +- src/Model/Indices/AddAlias.php | 34 +++++++++++++-------------- src/Model/Indices/Create.php | 2 +- src/Model/Indices/Delete.php | 2 +- src/Model/Indices/Exists.php | 2 +- src/Model/Indices/Get.php | 17 ++++++-------- src/Model/Indices/GetFieldMapping.php | 2 +- src/Model/Indices/GetMapping.php | 2 +- src/Model/Indices/MoveAlias.php | 2 +- src/Model/Indices/PutMapping.php | 2 +- src/Model/Indices/PutSettings.php | 2 +- src/Model/Indices/RemoveAlias.php | 2 +- src/Model/Insert.php | 2 +- src/Model/InsertMultiple.php | 2 +- src/Model/Scroll.php | 4 ++-- src/Model/Search.php | 2 +- 21 files changed, 44 insertions(+), 47 deletions(-) diff --git a/src/Model/Aggregate.php b/src/Model/Aggregate.php index 8e84d3d0..76628bde 100644 --- a/src/Model/Aggregate.php +++ b/src/Model/Aggregate.php @@ -46,7 +46,7 @@ public function execute( throw new \Spameri\Elastic\Exception\ElasticSearch($exception->getMessage()); } - return $this->resultMapper->mapSearchResults($result); + return $this->resultMapper->mapSearchResults($result->asArray()); } } diff --git a/src/Model/Delete.php b/src/Model/Delete.php index 8e55c9e9..edcd4f0a 100644 --- a/src/Model/Delete.php +++ b/src/Model/Delete.php @@ -41,7 +41,7 @@ public function execute( ) ) ->toArray(), - ) + )->asArray() ; } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { diff --git a/src/Model/DeleteMultiple.php b/src/Model/DeleteMultiple.php index 5fb0399a..6807214d 100644 --- a/src/Model/DeleteMultiple.php +++ b/src/Model/DeleteMultiple.php @@ -48,7 +48,7 @@ public function execute( $document = new \Spameri\ElasticQuery\Document\Bulk($documentsArray); try { - $response = $this->clientProvider->client()->bulk($document->toArray()); + $response = $this->clientProvider->client()->bulk($document->toArray())->asArray(); } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { throw new \Spameri\Elastic\Exception\ElasticSearch($exception->getMessage()); diff --git a/src/Model/Get.php b/src/Model/Get.php index b7dfe54a..158418e5 100644 --- a/src/Model/Get.php +++ b/src/Model/Get.php @@ -51,7 +51,7 @@ public function execute( throw new \Spameri\Elastic\Exception\ElasticSearch($exception->getMessage()); } - return $this->resultMapper->mapSingleResult($response); + return $this->resultMapper->mapSingleResult($response->asArray()); } } diff --git a/src/Model/GetBy.php b/src/Model/GetBy.php index fced2c98..c7590015 100644 --- a/src/Model/GetBy.php +++ b/src/Model/GetBy.php @@ -48,7 +48,7 @@ public function execute( throw new \Spameri\Elastic\Exception\ElasticSearch($exception->getMessage()); } - return $this->resultMapper->mapSearchResults($response); + return $this->resultMapper->mapSearchResults($response->asArray()); } } diff --git a/src/Model/Index.php b/src/Model/Index.php index 42fa90cd..1e9b1b30 100644 --- a/src/Model/Index.php +++ b/src/Model/Index.php @@ -40,7 +40,7 @@ public function execute( $type, ) )->toArray(), - ) + )->asArray() ; } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { diff --git a/src/Model/Indices/AddAlias.php b/src/Model/Indices/AddAlias.php index 5a036936..cc143733 100644 --- a/src/Model/Indices/AddAlias.php +++ b/src/Model/Indices/AddAlias.php @@ -34,27 +34,27 @@ public function execute(string $alias, string $index): array return $this->clientProvider->client()->indices()->putAlias( ( - new \Spameri\ElasticQuery\Document( - $index, - new \Spameri\ElasticQuery\Document\Body\Plain( - [ - 'actions' => [ - 'add' => [ - 'index' => $index, - 'alias' => $alias, + new \Spameri\ElasticQuery\Document( + $index, + new \Spameri\ElasticQuery\Document\Body\Plain( + [ + 'actions' => [ + 'add' => [ + 'index' => $index, + 'alias' => $alias, + ], ], ], + ), + NULL, + NULL, + [ + 'name' => $index, ], - ), - NULL, - NULL, - [ - 'name' => $index, - ], - ) + ) )->toArray(), - ) - ; + )->asArray() + ; } } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { diff --git a/src/Model/Indices/Create.php b/src/Model/Indices/Create.php index 3ead7807..9e895261 100644 --- a/src/Model/Indices/Create.php +++ b/src/Model/Indices/Create.php @@ -52,7 +52,7 @@ public function execute( new \Spameri\ElasticQuery\Document\Body\Plain($parameters), ) )->toArray(), - ) + )->asArray() ; } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { diff --git a/src/Model/Indices/Delete.php b/src/Model/Indices/Delete.php index dbf17eed..9ea7709a 100644 --- a/src/Model/Indices/Delete.php +++ b/src/Model/Indices/Delete.php @@ -26,7 +26,7 @@ public function execute( $index, ) )->toArray(), - ) + )->asArray() ; } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { diff --git a/src/Model/Indices/Exists.php b/src/Model/Indices/Exists.php index dd7df18a..72ece064 100644 --- a/src/Model/Indices/Exists.php +++ b/src/Model/Indices/Exists.php @@ -23,7 +23,7 @@ public function execute( $index, ) )->toArray(), - ) + )->asBool() ; } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { diff --git a/src/Model/Indices/Get.php b/src/Model/Indices/Get.php index 5ce15049..850fc0fe 100644 --- a/src/Model/Indices/Get.php +++ b/src/Model/Indices/Get.php @@ -20,18 +20,15 @@ public function execute( ): array { try { - /** @var array $result */ - $result = $this->clientProvider->client()->indices()->get( - ( - new \Spameri\ElasticQuery\Document( - $index, - ) - )->toArray(), - ) + return $this->clientProvider->client()->indices()->get( + ( + new \Spameri\ElasticQuery\Document( + $index, + ) + )->toArray(), + )->asArray() ; - return $result; - } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { throw new \Spameri\Elastic\Exception\ElasticSearch($exception->getMessage()); } diff --git a/src/Model/Indices/GetFieldMapping.php b/src/Model/Indices/GetFieldMapping.php index f9ec1866..947d8c04 100644 --- a/src/Model/Indices/GetFieldMapping.php +++ b/src/Model/Indices/GetFieldMapping.php @@ -31,7 +31,7 @@ public function execute( ], ) )->toArray(), - ) + )->asArray() ; } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { diff --git a/src/Model/Indices/GetMapping.php b/src/Model/Indices/GetMapping.php index a8b868c3..1a2443fc 100644 --- a/src/Model/Indices/GetMapping.php +++ b/src/Model/Indices/GetMapping.php @@ -38,7 +38,7 @@ public function execute( ) )->toArray(); - return $this->clientProvider->client()->indices()->getMapping($documentArray); + return $this->clientProvider->client()->indices()->getMapping($documentArray)->asArray(); } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { throw new \Spameri\Elastic\Exception\ElasticSearch($exception->getMessage()); diff --git a/src/Model/Indices/MoveAlias.php b/src/Model/Indices/MoveAlias.php index d9b65530..145f4cbc 100644 --- a/src/Model/Indices/MoveAlias.php +++ b/src/Model/Indices/MoveAlias.php @@ -40,7 +40,7 @@ public function execute(string $alias, string $indexFrom, string $indexTo): arra ], ) )->toArray(), - ) + )->asArray() ; } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { diff --git a/src/Model/Indices/PutMapping.php b/src/Model/Indices/PutMapping.php index 6a5f18ed..93831652 100644 --- a/src/Model/Indices/PutMapping.php +++ b/src/Model/Indices/PutMapping.php @@ -49,7 +49,7 @@ public function execute( $type, ) )->toArray(), - ) + )->asArray() ; } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { diff --git a/src/Model/Indices/PutSettings.php b/src/Model/Indices/PutSettings.php index dbe6ca11..58662646 100644 --- a/src/Model/Indices/PutSettings.php +++ b/src/Model/Indices/PutSettings.php @@ -29,7 +29,7 @@ public function execute( new \Spameri\ElasticQuery\Document\Body\Plain($settings), ) )->toArray(), - ) + )->asArray() ; } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { diff --git a/src/Model/Indices/RemoveAlias.php b/src/Model/Indices/RemoveAlias.php index 5f424ff7..69a92d39 100644 --- a/src/Model/Indices/RemoveAlias.php +++ b/src/Model/Indices/RemoveAlias.php @@ -36,7 +36,7 @@ public function execute(string $alias, string $index): array ], ) )->toArray(), - ) + )->asArray() ; } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { diff --git a/src/Model/Insert.php b/src/Model/Insert.php index 06c161bc..c17591d8 100644 --- a/src/Model/Insert.php +++ b/src/Model/Insert.php @@ -45,7 +45,7 @@ public function execute( $entity->id()->value(), ) )->toArray(), - ) + )->asArray() ; } catch (\Elastic\Elasticsearch\Exception\ElasticsearchException $exception) { diff --git a/src/Model/InsertMultiple.php b/src/Model/InsertMultiple.php index 035422ec..2b8e7a32 100644 --- a/src/Model/InsertMultiple.php +++ b/src/Model/InsertMultiple.php @@ -68,7 +68,7 @@ public function execute( throw new \Spameri\Elastic\Exception\ElasticSearch($exception->getMessage()); } - return $this->resultMapper->mapBulkResult($response); + return $this->resultMapper->mapBulkResult($response->asArray()); } } diff --git a/src/Model/Scroll.php b/src/Model/Scroll.php index 2b46d952..47a62dc4 100644 --- a/src/Model/Scroll.php +++ b/src/Model/Scroll.php @@ -46,7 +46,7 @@ public function execute( ) ) ->toArray(), - ) + )->asArray() ; if (isset($result['_scroll_id'])) { @@ -73,7 +73,7 @@ public function execute( ) ) ->toArray(), - ) + )->asArray() ; } diff --git a/src/Model/Search.php b/src/Model/Search.php index 5e9840a8..fd38d12d 100644 --- a/src/Model/Search.php +++ b/src/Model/Search.php @@ -48,7 +48,7 @@ public function execute( throw new \Spameri\Elastic\Exception\ElasticSearch($exception->getMessage()); } - return $this->resultMapper->mapSearchResults($result); + return $this->resultMapper->mapSearchResults($result->asArray()); } } From 48b9faab97cc6287283be043161eaa12ac45c146 Mon Sep 17 00:00:00 2001 From: Spamer Date: Thu, 4 Apr 2024 16:35:47 +0200 Subject: [PATCH 25/37] cs --- src/Diagnostics/Panel.php | 4 +++- src/Diagnostics/PanelLogger.php | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Diagnostics/Panel.php b/src/Diagnostics/Panel.php index c8d9c5ea..9482d221 100644 --- a/src/Diagnostics/Panel.php +++ b/src/Diagnostics/Panel.php @@ -1,4 +1,6 @@ - Date: Thu, 4 Apr 2024 16:36:19 +0200 Subject: [PATCH 26/37] collection stores class in elastic --- src/Mapping/Collection.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Mapping/Collection.php b/src/Mapping/Collection.php index 20076c52..ececd0f5 100644 --- a/src/Mapping/Collection.php +++ b/src/Mapping/Collection.php @@ -10,7 +10,6 @@ class Collection public function __construct( - public string $class, ) { } From 598e0297917cd926ce93f00cc6facd427271bdfd Mon Sep 17 00:00:00 2001 From: Spamer Date: Thu, 4 Apr 2024 16:38:09 +0200 Subject: [PATCH 27/37] Added STI flag to settings --- src/EntityRepository.php | 6 +++++- src/Model/Insert.php | 3 ++- src/Model/Insert/PrepareEntityArray.php | 8 +++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/EntityRepository.php b/src/EntityRepository.php index dc2a5c34..626c2b30 100644 --- a/src/EntityRepository.php +++ b/src/EntityRepository.php @@ -97,7 +97,11 @@ public function persist( { $indexConfig = $this->entitySettingsLocator->locateByEntityClass($entity::class); - return $this->insert->execute($entity, $indexConfig->indexName()); + return $this->insert->execute( + entity: $entity, + index: $indexConfig->indexName(), + hasSti: $indexConfig->hasSti(), + ); } diff --git a/src/Model/Insert.php b/src/Model/Insert.php index c17591d8..61007246 100644 --- a/src/Model/Insert.php +++ b/src/Model/Insert.php @@ -22,6 +22,7 @@ public function execute( \Spameri\Elastic\Entity\ElasticEntityInterface $entity, string $index, string|null $type = NULL, + bool $hasSti = FALSE, ): string { if ($type === NULL) { @@ -32,7 +33,7 @@ public function execute( $type = NULL; } - $entityArray = $this->prepareEntityArray->prepare($entity); + $entityArray = $this->prepareEntityArray->prepare($entity, $hasSti); unset($entityArray['id']); try { diff --git a/src/Model/Insert/PrepareEntityArray.php b/src/Model/Insert/PrepareEntityArray.php index 058177b7..63cd2e14 100644 --- a/src/Model/Insert/PrepareEntityArray.php +++ b/src/Model/Insert/PrepareEntityArray.php @@ -22,12 +22,18 @@ public function __construct( */ public function prepare( \Spameri\Elastic\Entity\ElasticEntityInterface $entity, + bool $hasSti = FALSE, ): array { $this->insertedEntities = []; $this->insertedEntities[$entity->id()->value()] = true; - return $this->iterateVariables($entity->entityVariables()); + $entityVariables = $entity->entityVariables(); + if ($hasSti === true) { + $entityVariables[self::ENTITY_CLASS] = \get_class($entity); + } + + return $this->iterateVariables($entityVariables); } From 65c76122146a712896cd9f0c0fbf0d1ff2f76259 Mon Sep 17 00:00:00 2001 From: Spamer Date: Thu, 4 Apr 2024 16:39:51 +0200 Subject: [PATCH 28/37] Added AbstracElasticEntity class - used for ensuring entity used in default service and in insert method has ID --- src/Entity/AbstractElasticEntity.php | 26 +++++++++++++++++++++++++ src/EntityRepository.php | 2 +- src/Model/AbstractBaseService.php | 2 +- src/Model/Insert.php | 2 +- src/Model/Insert/PrepareEntityArray.php | 11 ++++++++--- src/Model/ServiceInterface.php | 2 +- 6 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 src/Entity/AbstractElasticEntity.php diff --git a/src/Entity/AbstractElasticEntity.php b/src/Entity/AbstractElasticEntity.php new file mode 100644 index 00000000..19d4eabf --- /dev/null +++ b/src/Entity/AbstractElasticEntity.php @@ -0,0 +1,26 @@ +id; + } + + + public function entityVariables(): array + { + return \get_object_vars($this); + } + +} \ No newline at end of file diff --git a/src/EntityRepository.php b/src/EntityRepository.php index 626c2b30..029eac35 100644 --- a/src/EntityRepository.php +++ b/src/EntityRepository.php @@ -92,7 +92,7 @@ public function findAll(string $class): array public function persist( - \Spameri\Elastic\Entity\ElasticEntityInterface $entity + \Spameri\Elastic\Entity\AbstractElasticEntity $entity ): string { $indexConfig = $this->entitySettingsLocator->locateByEntityClass($entity::class); diff --git a/src/Model/AbstractBaseService.php b/src/Model/AbstractBaseService.php index 1fb22363..2333eef7 100644 --- a/src/Model/AbstractBaseService.php +++ b/src/Model/AbstractBaseService.php @@ -24,7 +24,7 @@ public function __construct( * @throws \Spameri\Elastic\Exception\DocumentInsertFailed */ public function insert( - \Spameri\Elastic\Entity\ElasticEntityInterface $entity, + \Spameri\Elastic\Entity\AbstractElasticEntity $entity, ): string { return $this->insert->execute($entity, $this->index); diff --git a/src/Model/Insert.php b/src/Model/Insert.php index 61007246..dc88ad54 100644 --- a/src/Model/Insert.php +++ b/src/Model/Insert.php @@ -19,7 +19,7 @@ public function __construct( * @throws \Spameri\Elastic\Exception\DocumentInsertFailed */ public function execute( - \Spameri\Elastic\Entity\ElasticEntityInterface $entity, + \Spameri\Elastic\Entity\AbstractElasticEntity $entity, string $index, string|null $type = NULL, bool $hasSti = FALSE, diff --git a/src/Model/Insert/PrepareEntityArray.php b/src/Model/Insert/PrepareEntityArray.php index 63cd2e14..f0525f23 100644 --- a/src/Model/Insert/PrepareEntityArray.php +++ b/src/Model/Insert/PrepareEntityArray.php @@ -48,8 +48,8 @@ public function iterateVariables( $preparedArray = []; foreach ($variables as $key => $property) { - if ($property instanceof \Spameri\Elastic\Entity\ElasticEntityInterface) { - if (\in_array($property->id()->value(), $this->insertedEntities)) { + if ($property instanceof \Spameri\Elastic\Entity\AbstractElasticEntity) { + if (\in_array($property->id->value(), $this->insertedEntities, true)) { $preparedArray[$key] = $property->id()->value(); } else { @@ -57,6 +57,11 @@ public function iterateVariables( $this->insertedEntities[$property->id()->value()] = true; } + } elseif ($property instanceof \Spameri\Elastic\Entity\ElasticEntityInterface) { + throw new \Spameri\Elastic\Exception\DocumentInsertFailed( + 'Entity ' . \get_class($property) . ' must be extend AbstractElasticEntity.' + ); + } elseif ($property instanceof \Spameri\Elastic\Entity\EntityInterface) { $preparedArray[$key] = $this->iterateVariables($property->entityVariables()); @@ -77,7 +82,7 @@ public function iterateVariables( $preparedArray[$key] = $property->elasticIds(); } else { - /** @var \Spameri\Elastic\Entity\ElasticEntityInterface $item */ + /** @var \Spameri\Elastic\Entity\AbstractElasticEntity $item */ foreach ($property as $item) { if (\in_array($item->id()->value(), $this->insertedEntities)) { $preparedArray[$key][] = $item->id()->value(); diff --git a/src/Model/ServiceInterface.php b/src/Model/ServiceInterface.php index 05fef17f..7b19c1c6 100644 --- a/src/Model/ServiceInterface.php +++ b/src/Model/ServiceInterface.php @@ -6,7 +6,7 @@ interface ServiceInterface { public function insert( - \Spameri\Elastic\Entity\ElasticEntityInterface $entity, + \Spameri\Elastic\Entity\AbstractElasticEntity $entity, ): string; From a638bc8276a7c32e60e010dba2d6e6a5eaf2de1e Mon Sep 17 00:00:00 2001 From: Spamer Date: Thu, 4 Apr 2024 16:42:13 +0200 Subject: [PATCH 29/37] entity class is array of possible entities entity settings locator iterates these entities to find out correct config --- src/Model/EntitySettingsLocator.php | 6 ++++-- src/Settings/AbstractIndexConfig.php | 4 ++-- src/Settings/IndexConfigInterface.php | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Model/EntitySettingsLocator.php b/src/Model/EntitySettingsLocator.php index 4d1c0866..85f6de72 100644 --- a/src/Model/EntitySettingsLocator.php +++ b/src/Model/EntitySettingsLocator.php @@ -35,8 +35,10 @@ public function locateByEntityClass(string $entityClass): \Spameri\ElasticQuery\ /** @var \Spameri\Elastic\Settings\AbstractIndexConfig $indexConfig */ foreach ($indexConfigs as $indexConfig) { -if ($indexConfig->entityClass() === $entityClass) { -return $indexConfig->provide(); + foreach ($indexConfig->entityClass() as $class) { + if ($class === $entityClass) { + return $indexConfig->provide(); + } } } diff --git a/src/Settings/AbstractIndexConfig.php b/src/Settings/AbstractIndexConfig.php index de3f79c3..a956bb12 100644 --- a/src/Settings/AbstractIndexConfig.php +++ b/src/Settings/AbstractIndexConfig.php @@ -10,13 +10,13 @@ abstract class AbstractIndexConfig implements IndexConfigInterface public function __construct( protected string $index, - protected string $entityClass, + protected array $entityClass, ) { } - public function entityClass(): string + public function entityClass(): array { return $this->entityClass; } diff --git a/src/Settings/IndexConfigInterface.php b/src/Settings/IndexConfigInterface.php index c7d8a27e..bcfc5d0f 100644 --- a/src/Settings/IndexConfigInterface.php +++ b/src/Settings/IndexConfigInterface.php @@ -7,7 +7,7 @@ interface IndexConfigInterface public function provide(): \Spameri\ElasticQuery\Mapping\Settings; - public function entityClass(): string; + public function entityClass(): array; public function indexName(): string; } From 95029f7a1cc171771121944d621e351c6d34323b Mon Sep 17 00:00:00 2001 From: Spamer Date: Thu, 4 Apr 2024 16:42:28 +0200 Subject: [PATCH 30/37] cs --- src/Model/InitializeIndex.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Model/InitializeIndex.php b/src/Model/InitializeIndex.php index 210f6d8e..3da88eaf 100644 --- a/src/Model/InitializeIndex.php +++ b/src/Model/InitializeIndex.php @@ -26,7 +26,8 @@ public function execute(\Spameri\Elastic\Settings\IndexConfigInterface $indexCon } catch (\Spameri\Elastic\Exception\ElasticSearch $exception) { $indexName = - $indexAlias . '-' + $indexAlias + . '-' . $this->dateTimeProvider->provide()->format(\Spameri\Elastic\Entity\Property\DateTime::INDEX_FORMAT); $this->create->execute($indexName, $indexConfig->provide()->toArray(), $indexAlias); From 1fb22474a3f18ab05845b73b788aee1383cc7dda Mon Sep 17 00:00:00 2001 From: Spamer Date: Thu, 4 Apr 2024 16:42:54 +0200 Subject: [PATCH 31/37] Added ability to persist STI entity collection --- src/Model/Insert/PrepareEntityArray.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Model/Insert/PrepareEntityArray.php b/src/Model/Insert/PrepareEntityArray.php index f0525f23..98e5912a 100644 --- a/src/Model/Insert/PrepareEntityArray.php +++ b/src/Model/Insert/PrepareEntityArray.php @@ -68,6 +68,14 @@ public function iterateVariables( } elseif ($property instanceof \Spameri\Elastic\Entity\ValueInterface) { $preparedArray[$key] = $property->value(); + } elseif ($property instanceof \Spameri\Elastic\Entity\Collection\STIEntityCollection) { + $preparedArray[$key] = []; + foreach ($property as $item) { + $iterateVariables = $this->iterateVariables($item->entityVariables()); + $iterateVariables[self::ENTITY_CLASS] = \get_class($item); + $preparedArray[$key][] = $iterateVariables; + } + } elseif ($property instanceof \Spameri\Elastic\Entity\EntityCollectionInterface) { $preparedArray[$key] = []; /** @var \Spameri\Elastic\Entity\EntityInterface $item */ From de505218a8b5f973d02e00b4acf645f8f6d6579e Mon Sep 17 00:00:00 2001 From: Spamer Date: Thu, 4 Apr 2024 16:45:24 +0200 Subject: [PATCH 32/37] EntityFactory: - Added Helper class for reflections - Uses metadata for entity class from elasticsearch, because of this entity factory can determine class of entity to create - Fixed null/empty value handling - Fixed ability to create collection --- src/Factory/EntityFactory.php | 82 ++++++++++++++++++++--------------- src/Reflection/Reflection.php | 37 ++++++++++++++++ 2 files changed, 84 insertions(+), 35 deletions(-) create mode 100644 src/Reflection/Reflection.php diff --git a/src/Factory/EntityFactory.php b/src/Factory/EntityFactory.php index 5bb3e0b7..a204d827 100644 --- a/src/Factory/EntityFactory.php +++ b/src/Factory/EntityFactory.php @@ -4,9 +4,15 @@ namespace Spameri\Elastic\Factory; -class EntityFactory implements \Spameri\Elastic\Factory\EntityFactoryInterface +readonly class EntityFactory implements \Spameri\Elastic\Factory\EntityFactoryInterface { + public function __construct( + private \Spameri\Elastic\Reflection\Reflection $reflection, + ) + { + } + /** * @return \Generator<\SpameriTests\Elastic\Data\Entity\Person> */ @@ -21,6 +27,10 @@ public function create( $properties = $this->resolveProperties($hit, $class); + if ($hit->getValue(\Spameri\Elastic\Model\Insert\PrepareEntityArray::ENTITY_CLASS) !== null) { + $class = $hit->getValue(\Spameri\Elastic\Model\Insert\PrepareEntityArray::ENTITY_CLASS); + } + yield new $class( ... $properties, ); @@ -32,23 +42,30 @@ protected function resolveProperties( string|null $parentFieldName = null, ): array { - $reflection = new \ReflectionClass($class); + $reflection = $this->reflection->createReflection($class); $resolvedProperties = []; - foreach ($reflection->getProperties() as $property) { + foreach ($this->reflection->getProperties($reflection) as $property) { $hitKey = $property->getName(); if ($parentFieldName !== null) { $hitKey = $parentFieldName . '.' . $hitKey; } - if ($property->getType() === null) { + $reflectionPropertyType = $this->reflection->getPropertyType($property); + if ($reflectionPropertyType === null) { $resolvedProperties[$property->getName()] = $hit->getValue($parentFieldName); continue; } - $propertyTypeName = $property->getType()->getName(); - if ($propertyTypeName === \Spameri\Elastic\Entity\Property\Date::class) { - $value = $hit->getValue($hitKey); + $value = $hit->getValue($hitKey); + $propertyTypeName = $reflectionPropertyType->getName(); + if ($reflectionPropertyType->allowsNull() && $value === null) { + $propertyValue = null; + + } elseif ($property->hasDefaultValue() === true && $value === null) { + $propertyValue = $property->getDefaultValue(); + + } elseif ($propertyTypeName === \Spameri\Elastic\Entity\Property\Date::class) { if ($value !== null) { $propertyValue = new \Spameri\Elastic\Entity\Property\Date( datetime: $value, @@ -61,13 +78,7 @@ protected function resolveProperties( } elseif (\count($property->getAttributes()) > 0) { foreach ($property->getAttributes() as $attribute) { if ( - \in_array( - $attribute->getName(), - [ - \Spameri\Elastic\Mapping\Collection::class, - \Spameri\Elastic\Mapping\Entity::class, - ] - ) === true + $attribute->getName() === \Spameri\Elastic\Mapping\Entity::class ) { $arguments = $attribute->getArguments(); @@ -76,36 +87,35 @@ protected function resolveProperties( $hit->id(), ); - } elseif ($attribute->getName() === \Spameri\Elastic\Mapping\Collection::class) { - $propertyValue = new \Spameri\Elastic\Entity\Collection\EntityCollection(); - foreach ($hit->getValue($hitKey) as $collectionItemKey => $collectionItem) { - $propertyValue->add(new $arguments['class']( - ... $this->resolveProperties($hit, $arguments['class'], $hitKey . '.' . $collectionItemKey), - )); - } - - } elseif ($attribute->getName() === \Spameri\Elastic\Mapping\ElasticCollection::class) { - $propertyValue = new \Spameri\Elastic\Entity\Collection\ElasticEntityCollection( - // TODO musíme předat service nebo udělat novou kolekci co implementuje ElasticEntityCollectionInterface - ); - foreach ($hit->getValue($hitKey) as $collectionItemKey => $collectionItem) { - $propertyValue->add(new $arguments['class']( - ... $this->resolveProperties($hit, $arguments['class'], $hitKey . '.' . $collectionItemKey), - )); - } - } else { $propertyValue = new $arguments['class']( ... $this->resolveProperties($hit, $propertyTypeName, $hitKey), ); } + } elseif ( + $attribute->getName() === \Spameri\Elastic\Mapping\Collection::class + ) { + $propertyValue = new $propertyTypeName(); + if ($value !== null) { + foreach ($value as $entityKey => $entity) { + $propertyValue->add( + new $entity[\Spameri\Elastic\Model\Insert\PrepareEntityArray::ENTITY_CLASS]( + ... $this->resolveProperties($hit, $entity[\Spameri\Elastic\Model\Insert\PrepareEntityArray::ENTITY_CLASS], $hitKey . '.' . $entityKey), + ), + ); + } + } + } elseif ( + $attribute->getName() === \Spameri\Elastic\Mapping\Ignored::class + ) { + continue 2; } } } elseif (\class_exists($propertyTypeName)) { if (isset(\class_implements($propertyTypeName)[\Spameri\Elastic\Entity\ValueInterface::class]) === true) { $propertyValue = new $propertyTypeName( - $hit->getValue($hitKey), + $value, ); } else { @@ -115,10 +125,12 @@ protected function resolveProperties( } } else { - $propertyValue = $hit->getValue($hitKey); + $propertyValue = $value; } - $resolvedProperties[$property->getName()] = $propertyValue; + if (isset($propertyValue)) { + $resolvedProperties[$property->getName()] = $propertyValue; + } unset($propertyValue); } diff --git a/src/Reflection/Reflection.php b/src/Reflection/Reflection.php new file mode 100644 index 00000000..f5b93d63 --- /dev/null +++ b/src/Reflection/Reflection.php @@ -0,0 +1,37 @@ + + */ + public function getProperties(\ReflectionClass $class): array + { + return $class->getProperties(); + } + + + public function getPropertyType(\ReflectionProperty $property): \ReflectionNamedType|null + { + $reflectionType = $property->getType(); + + if ($reflectionType instanceof \ReflectionNamedType) { + return $reflectionType; + } + + return null; + } +} From 7840985a007142237b791cac4e189e0ed002a3c9 Mon Sep 17 00:00:00 2001 From: Spamer Date: Thu, 4 Apr 2024 16:45:39 +0200 Subject: [PATCH 33/37] updated tests --- doc/03_entity_class.md | 2 +- .../Elastic/Data/Entity/Person.php | 117 ++--------- .../Person/CharacterCollectionElastic.php | 7 +- .../Elastic/Data/Entity/Video.php | 189 ++---------------- .../Data/Entity/Video/Identification.php | 8 +- .../Elastic/Data/Entity/Video/People.php | 2 +- .../Elastic/Data/Model/PersonFactory.php | 4 +- .../Elastic/Factory/EntityFactory.phpt | 12 +- 8 files changed, 44 insertions(+), 297 deletions(-) diff --git a/doc/03_entity_class.md b/doc/03_entity_class.md index 0c2416cc..80e3a245 100644 --- a/doc/03_entity_class.md +++ b/doc/03_entity_class.md @@ -231,7 +231,7 @@ class People extends \Spameri\Elastic\Entity\Collection\AbstractElasticEntityCol { /** @var \SpameriTests\Elastic\Data\Entity\Person $entity */ foreach ($this->collection() as $entity) { - if ($imdb->value() === $entity->identification()->imdb()->value()) { + if ($imdb->value() === $entity->identification->imdb->value()) { return $entity; } } diff --git a/tests/SpameriTests/Elastic/Data/Entity/Person.php b/tests/SpameriTests/Elastic/Data/Entity/Person.php index 6a0b1738..52ee23d4 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Person.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Person.php @@ -2,117 +2,28 @@ namespace SpameriTests\Elastic\Data\Entity; -class Person implements \Spameri\Elastic\Entity\ElasticEntityInterface +class Person extends \Spameri\Elastic\Entity\AbstractElasticEntity { public function __construct( #[\Spameri\Elastic\Mapping\Entity(class: \Spameri\Elastic\Entity\Property\ElasticId::class)] public \Spameri\Elastic\Entity\Property\ElasticIdInterface $id, - private \SpameriTests\Elastic\Data\Entity\Video\Identification $identification, - private \SpameriTests\Elastic\Data\Entity\Property\Name $name, - private \SpameriTests\Elastic\Data\Entity\Property\Description $description, - private \Spameri\Elastic\Entity\Property\Date|null $birth, - private \Spameri\Elastic\Entity\Property\Date|null $death, - private \SpameriTests\Elastic\Data\Entity\Property\Name $alias, - - #[\Spameri\Elastic\Mapping\Collection(class: \SpameriTests\Elastic\Data\Entity\Person\Character::class)] - private \Spameri\Elastic\Entity\Collection\AbstractEntityCollection $characters, - - #[\Spameri\Elastic\Mapping\Collection(class: \SpameriTests\Elastic\Data\Entity\Person\Job::class)] - private \Spameri\Elastic\Entity\Collection\EntityCollection $jobs, + public \SpameriTests\Elastic\Data\Entity\Video\Identification $identification, + public \SpameriTests\Elastic\Data\Entity\Property\Name $name, + public \SpameriTests\Elastic\Data\Entity\Property\Description $description, + public \Spameri\Elastic\Entity\Property\Date|null $birth, + public \Spameri\Elastic\Entity\Property\Date|null $death, + public \SpameriTests\Elastic\Data\Entity\Property\Name $alias, + + #[\Spameri\Elastic\Mapping\Collection] + public \Spameri\Elastic\Entity\Collection\AbstractEntityCollection $characters, + + #[\Spameri\Elastic\Mapping\Collection] + public \Spameri\Elastic\Entity\Collection\AbstractEntityCollection $jobs, ) { - } - - - public function entityVariables(): array - { - return \get_object_vars($this); - } - - - public function id(): \Spameri\Elastic\Entity\Property\ElasticIdInterface - { - return $this->id; - } - - - public function identification(): \SpameriTests\Elastic\Data\Entity\Video\Identification - { - return $this->identification; - } - - - public function name(): \SpameriTests\Elastic\Data\Entity\Property\Name - { - return $this->name; - } - - - public function rename(\SpameriTests\Elastic\Data\Entity\Property\Name $name): void - { - $this->name = $name; - } - - - public function description(): \SpameriTests\Elastic\Data\Entity\Property\Description - { - return $this->description; - } - - - public function changeDescription(\SpameriTests\Elastic\Data\Entity\Property\Description $description): void - { - $this->description = $description; - } - - - public function birth(): \Spameri\Elastic\Entity\Property\Date|null - { - return $this->birth; - } - - - public function setBirth(\Spameri\Elastic\Entity\Property\Date|null $birth): void - { - $this->birth = $birth; - } - - - public function death(): \Spameri\Elastic\Entity\Property\Date|null - { - return $this->death; - } - - - public function setDeath(\Spameri\Elastic\Entity\Property\Date|null $death): void - { - $this->death = $death; - } - - - public function alias(): \SpameriTests\Elastic\Data\Entity\Property\Name - { - return $this->alias; - } - - - public function setAlias(\SpameriTests\Elastic\Data\Entity\Property\Name $alias): void - { - $this->alias = $alias; - } - - - public function characters(): \SpameriTests\Elastic\Data\Entity\Person\CharacterCollectionElastic - { - return $this->characters; - } - - - public function jobs(): \SpameriTests\Elastic\Data\Entity\Person\JobCollectionElastic - { - return $this->jobs; + parent::__construct($id); } } diff --git a/tests/SpameriTests/Elastic/Data/Entity/Person/CharacterCollectionElastic.php b/tests/SpameriTests/Elastic/Data/Entity/Person/CharacterCollectionElastic.php index 0f7f8e1c..2601ff54 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Person/CharacterCollectionElastic.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Person/CharacterCollectionElastic.php @@ -14,15 +14,14 @@ public function character( foreach ($this->collection() as $character) { if ($episode) { if ( - $character->id()->value() === $id->value() - && $character->episode() - && $character->episode()->value() === $episode->value() + $character->id === $id->value() + && $character->episode->value() === $episode->value() ) { return $character; } } else { - if ($character->id()->value() === $id->value()) { + if ($character->id === $id->value()) { return $character; } } diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video.php b/tests/SpameriTests/Elastic/Data/Entity/Video.php index da8a4f01..e271c7a1 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video.php @@ -2,184 +2,27 @@ namespace SpameriTests\Elastic\Data\Entity; -class Video implements \Spameri\Elastic\Entity\ElasticEntityInterface +class Video extends \Spameri\Elastic\Entity\AbstractElasticEntity { - /** - * @var \Spameri\Elastic\Entity\Property\ElasticIdInterface - */ - public $id; - - /** - * @var \SpameriTests\Elastic\Data\Entity\Video\Identification - */ - private $identification; - - /** - * @var \SpameriTests\Elastic\Data\Entity\Property\Name - */ - private $name; - - /** - * @var \SpameriTests\Elastic\Data\Entity\Property\Year - */ - private $year; - - /** - * @var \SpameriTests\Elastic\Data\Entity\Video\Technical - */ - private $technical; - - /** - * @var \SpameriTests\Elastic\Data\Entity\Video\Story - */ - private $story; - - /** - * @var \SpameriTests\Elastic\Data\Entity\Video\Details - */ - private $details; - - /** - * @var \SpameriTests\Elastic\Data\Entity\Video\HighLights - */ - private $highLights; - - /** - * @var \SpameriTests\Elastic\Data\Entity\Video\Connections - */ - private $connections; - - /** - * @var \SpameriTests\Elastic\Data\Entity\Video\SeasonCollection - */ - private $season; - - /** - * @var \SpameriTests\Elastic\Data\Entity\Video\People - */ - private $people; - - public function __construct( - \Spameri\Elastic\Entity\Property\ElasticIdInterface $id, - \SpameriTests\Elastic\Data\Entity\Video\Identification $identification, - \SpameriTests\Elastic\Data\Entity\Property\Name $name, - \SpameriTests\Elastic\Data\Entity\Property\Year $year, - \SpameriTests\Elastic\Data\Entity\Video\Technical $technical, - \SpameriTests\Elastic\Data\Entity\Video\Story $story, - \SpameriTests\Elastic\Data\Entity\Video\Details $details, - \SpameriTests\Elastic\Data\Entity\Video\HighLights $highLights, - \SpameriTests\Elastic\Data\Entity\Video\Connections $connections, - \SpameriTests\Elastic\Data\Entity\Video\People $people, - \SpameriTests\Elastic\Data\Entity\Video\SeasonCollection $season = NULL, + #[\Spameri\Elastic\Mapping\Entity(class: \Spameri\Elastic\Entity\Property\ElasticId::class)] + public \Spameri\Elastic\Entity\Property\ElasticIdInterface $id, + public \SpameriTests\Elastic\Data\Entity\Video\Identification $identification, + public \SpameriTests\Elastic\Data\Entity\Property\Name $name, + public \SpameriTests\Elastic\Data\Entity\Property\Year $year, + public \SpameriTests\Elastic\Data\Entity\Video\Technical $technical, + public \SpameriTests\Elastic\Data\Entity\Video\Story $story, + public \SpameriTests\Elastic\Data\Entity\Video\Details $details, + public \SpameriTests\Elastic\Data\Entity\Video\HighLights $highLights, + public \SpameriTests\Elastic\Data\Entity\Video\Connections $connections, + public \SpameriTests\Elastic\Data\Entity\Video\People $people, + + #[\Spameri\Elastic\Mapping\Collection] + public \Spameri\Elastic\Entity\Collection\AbstractEntityCollection $season, ) { - $this->id = $id; - $this->identification = $identification; - $this->name = $name; - $this->year = $year; - $this->technical = $technical; - $this->story = $story; - $this->details = $details; - $this->highLights = $highLights; - $this->connections = $connections; - - if ($season === NULL) { - $season = new \SpameriTests\Elastic\Data\Entity\Video\SeasonCollection(); - } - $this->season = $season; - $this->people = $people; - } - - - public function entityVariables(): array - { - return \get_object_vars($this); - } - - - public function id(): \Spameri\Elastic\Entity\Property\ElasticIdInterface - { - return $this->id; - } - - - public function identification(): \SpameriTests\Elastic\Data\Entity\Video\Identification - { - return $this->identification; - } - - - public function name(): \SpameriTests\Elastic\Data\Entity\Property\Name - { - return $this->name; - } - - - public function rename(\SpameriTests\Elastic\Data\Entity\Property\Name $name): void - { - $this->name = $name; - } - - - public function year(): \SpameriTests\Elastic\Data\Entity\Property\Year - { - return $this->year; - } - - - public function setYear(\SpameriTests\Elastic\Data\Entity\Property\Year $year): void - { - $this->year = $year; - } - - - public function technical(): \SpameriTests\Elastic\Data\Entity\Video\Technical - { - return $this->technical; - } - - - public function setTechnicalFromImdb(\SpameriTests\Elastic\Data\Entity\Video\Technical $technical): void - { - $this->technical = $technical; - } - - - public function story(): \SpameriTests\Elastic\Data\Entity\Video\Story - { - return $this->story; - } - - - public function details(): \SpameriTests\Elastic\Data\Entity\Video\Details - { - return $this->details; - } - - - public function highLights(): \SpameriTests\Elastic\Data\Entity\Video\HighLights - { - return $this->highLights; - } - - - public function connections(): \SpameriTests\Elastic\Data\Entity\Video\Connections - { - return $this->connections; - } - - - public function season(): \SpameriTests\Elastic\Data\Entity\Video\SeasonCollection - { - return $this->season; - } - - - public function people(): \SpameriTests\Elastic\Data\Entity\Video\People - { - return $this->people; + parent::__construct($id); } } diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/Identification.php b/tests/SpameriTests/Elastic/Data/Entity/Video/Identification.php index e80d61d7..d044a283 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/Identification.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/Identification.php @@ -6,7 +6,7 @@ class Identification implements \Spameri\Elastic\Entity\EntityInterface { public function __construct( - private \SpameriTests\Elastic\Data\Entity\Property\ImdbId $imdb, + public \SpameriTests\Elastic\Data\Entity\Property\ImdbId $imdb, ) { } @@ -23,10 +23,4 @@ public function entityVariables(): array return \get_object_vars($this); } - - public function imdb(): \SpameriTests\Elastic\Data\Entity\Property\ImdbId - { - return $this->imdb; - } - } diff --git a/tests/SpameriTests/Elastic/Data/Entity/Video/People.php b/tests/SpameriTests/Elastic/Data/Entity/Video/People.php index 377c7350..9e8bcd2a 100644 --- a/tests/SpameriTests/Elastic/Data/Entity/Video/People.php +++ b/tests/SpameriTests/Elastic/Data/Entity/Video/People.php @@ -11,7 +11,7 @@ public function personByImdb( { /** @var \SpameriTests\Elastic\Data\Entity\Person $entity */ foreach ($this->collection() as $entity) { - if ($imdb->value() === $entity->identification()->imdb()->value()) { + if ($imdb->value() === $entity->identification->imdb->value()) { return $entity; } } diff --git a/tests/SpameriTests/Elastic/Data/Model/PersonFactory.php b/tests/SpameriTests/Elastic/Data/Model/PersonFactory.php index 8918895a..af2b09f8 100644 --- a/tests/SpameriTests/Elastic/Data/Model/PersonFactory.php +++ b/tests/SpameriTests/Elastic/Data/Model/PersonFactory.php @@ -23,8 +23,8 @@ public function create( birth: new \Spameri\Elastic\Entity\Property\Date($hit->getValue('birth')), death: new \Spameri\Elastic\Entity\Property\Date($hit->getValue('death')), alias: new \SpameriTests\Elastic\Data\Entity\Property\Name($hit->getValue('alias')), -// characters: new \SpameriTests\Elastic\Data\Entity\Person\CharacterCollectionElastic(), -// jobs: new \SpameriTests\Elastic\Data\Entity\Person\JobCollectionElastic(), + characters: new \SpameriTests\Elastic\Data\Entity\Person\CharacterCollectionElastic(), + jobs: new \SpameriTests\Elastic\Data\Entity\Person\JobCollectionElastic(), ); } diff --git a/tests/SpameriTests/Elastic/Factory/EntityFactory.phpt b/tests/SpameriTests/Elastic/Factory/EntityFactory.phpt index 340404c8..5916c8bf 100644 --- a/tests/SpameriTests/Elastic/Factory/EntityFactory.phpt +++ b/tests/SpameriTests/Elastic/Factory/EntityFactory.phpt @@ -55,12 +55,12 @@ class EntityFactory extends \SpameriTests\Elastic\AbstractTestCase $entity = $entityFactory->create($hit, \SpameriTests\Elastic\Data\Entity\Person::class)->current(); \Tester\Assert::same($person->id->value(), $entity->id->value()); - \Tester\Assert::same($person->identification()->imdb()->value(), $entity->identification()->imdb()->value()); - \Tester\Assert::same($person->name()->value(), $entity->name()->value()); - \Tester\Assert::same($person->description()->value(), $entity->description()->value()); - \Tester\Assert::same($person->birth()->format('Y-m-d'), $entity->birth()->format('Y-m-d')); - \Tester\Assert::null($entity->death()); - \Tester\Assert::same($person->alias()->value(), $entity->alias()->value()); + \Tester\Assert::same($person->identification->imdb->value(), $entity->identification->imdb->value()); + \Tester\Assert::same($person->name->value(), $entity->name->value()); + \Tester\Assert::same($person->description->value(), $entity->description->value()); + \Tester\Assert::same($person->birth->format('Y-m-d'), $entity->birth->format('Y-m-d')); + \Tester\Assert::null($entity->death); + \Tester\Assert::same($person->alias->value(), $entity->alias->value()); } } From 57400d86a1ad449f35223e9d1d58def505400e0f Mon Sep 17 00:00:00 2001 From: Spamer Date: Thu, 4 Apr 2024 16:45:55 +0200 Subject: [PATCH 34/37] elastic bump --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5d505cdf..682c0d4f 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "ext-json": "*", "ext-curl": "*", "spameri/elastic-query": "dev-master", - "elasticsearch/elasticsearch": "^7.12|^8", + "elasticsearch/elasticsearch": "^8.12.0", "nette/di": "^3.0.5", "nette/utils": "^3.2.5", "symfony/console": "^4.4.26", From 903d26977ef087fe0c3690611fff601db3daeea4 Mon Sep 17 00:00:00 2001 From: Spamer Date: Thu, 4 Apr 2024 16:46:18 +0200 Subject: [PATCH 35/37] PHP stan bump --- composer.json | 4 ++-- makefile | 9 +++------ phpstan-low.neon | 2 +- phpstan.neon | 28 +--------------------------- 4 files changed, 7 insertions(+), 36 deletions(-) diff --git a/composer.json b/composer.json index 682c0d4f..ea56d144 100644 --- a/composer.json +++ b/composer.json @@ -38,9 +38,9 @@ }, "require-dev": { "slevomat/coding-standard": "^8.0", - "spameri/dependency-mocker": "^1.3", + "spameri/dependency-mocker": "^1.3", "nette/tester": "^2.4", - "phpstan/phpstan": "0.12.84", + "phpstan/phpstan": "^1.10.66", "php-coveralls/php-coveralls": "^2.1", "nette/bootstrap": "^3.0", "nette/http": "^3.0.7", diff --git a/makefile b/makefile index 94e35709..72a86990 100644 --- a/makefile +++ b/makefile @@ -28,13 +28,10 @@ phpstan-lowest: vendor/bin/phpstan analyse -l 6 -c phpstan-low.neon src tests cs: - vendor/bin/phpcs --standard=ruleset.xml --cache=.phpcs-cache src tests/SpameriTests + vendor/bin/phpcs --standard=ruleset.xml --cache=.phpcs-cache src tests -cs-local: - vendor/bin/phpcs --standard=ruleset.xml src tests/SpameriTests - -cbf: - vendor/bin/phpcbf --standard=ruleset.xml src tests/SpameriTests +csf: + vendor/bin/phpcbf --standard=ruleset.xml src tests coverage: vendor/bin/tester $COVERAGE -s -c ./tests/php.ini-unix ./tests diff --git a/phpstan-low.neon b/phpstan-low.neon index 7969873e..97de0bc1 100644 --- a/phpstan-low.neon +++ b/phpstan-low.neon @@ -1,5 +1,5 @@ parameters: - excludes_analyse: + excludePaths: - %rootDir%/../../../tests/tmp/* checkGenericClassInNonGenericObjectType: false diff --git a/phpstan.neon b/phpstan.neon index ecfe68c0..60bc1978 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,39 +1,13 @@ parameters: - excludes_analyse: + excludePaths: - %rootDir%/../../../tests/tmp/* ignoreErrors: - - - message: "#^PHPDoc tag @throws with type Elasticsearch\\\\Common\\\\Exceptions\\\\ElasticsearchException is not subtype of Throwable$#" - count: 1 - path: src/ClientProvider.php - - - - message: "#^PHPDoc tag @throws with type Elasticsearch\\\\Common\\\\Exceptions\\\\ElasticsearchException is not subtype of Throwable$#" - count: 1 - path: src/Commands/TypeToNewIndex.php - - - - message: "#^Call to function array_key_exists\\(\\) with string and array\\ will always evaluate to false\\.$#" - count: 1 - path: src/Entity/Collection/AbstractElasticEntityCollection.php - - - - message: "#^Call to function array_key_exists\\(\\) with string and array\\ will always evaluate to false\\.$#" - count: 1 - path: src/Entity/Collection/AbstractEntityCollection.php - - - - message: "#^PHPDoc tag @throws with type Elasticsearch\\\\Common\\\\Exceptions\\\\ElasticsearchException is not subtype of Throwable$#" - count: 2 - path: src/Model/TypeToNewIndex/Migrate.php - - message: "#^Unable to resolve the template type T in call to method Nette\\\\DI\\\\Container\\:\\:getByType\\(\\)$#" count: 2 path: src/Model/ServiceLocator.php - checkGenericClassInNonGenericObjectType: false checkMissingIterableValueType: false From 2aa9922925cf9d0ac8871eda5034309b39198cb9 Mon Sep 17 00:00:00 2001 From: Spamer Date: Thu, 4 Apr 2024 16:53:19 +0200 Subject: [PATCH 36/37] cs --- ruleset.xml | 8 ++++++-- src/Commands/AddAlias.php | 5 ++++- src/Commands/CreateIndex.php | 8 +++++--- src/Commands/DeleteIndex.php | 5 ++++- src/Commands/DumpIndex.php | 5 ++++- src/Commands/InitializeIndexes.php | 9 ++++++--- src/Commands/LoadDump.php | 5 ++++- src/Commands/RemoveAlias.php | 5 ++++- src/Commands/TypeToNewIndex.php | 9 ++++++--- src/Model/Insert/PrepareEntityArray.php | 15 +++++++++------ .../Elastic/Data/Model/VideoFactory.php | 6 +----- 11 files changed, 53 insertions(+), 27 deletions(-) diff --git a/ruleset.xml b/ruleset.xml index d86f1c00..dbf45e07 100644 --- a/ruleset.xml +++ b/ruleset.xml @@ -1,5 +1,5 @@ - + @@ -83,6 +83,10 @@ + + + + @@ -103,7 +107,7 @@ - + diff --git a/src/Commands/AddAlias.php b/src/Commands/AddAlias.php index edbd2886..7526e450 100644 --- a/src/Commands/AddAlias.php +++ b/src/Commands/AddAlias.php @@ -5,6 +5,9 @@ class AddAlias extends \Symfony\Component\Console\Command\Command { + /** + * @var string + */ protected static $defaultName = 'spameri:elastic:add-alias'; @@ -12,7 +15,7 @@ public function __construct( private readonly \Spameri\Elastic\Model\Indices\AddAlias $addAlias, ) { - parent::__construct(NULL); + parent::__construct(null); } diff --git a/src/Commands/CreateIndex.php b/src/Commands/CreateIndex.php index 587957d5..6f31d877 100644 --- a/src/Commands/CreateIndex.php +++ b/src/Commands/CreateIndex.php @@ -4,7 +4,9 @@ class CreateIndex extends \Symfony\Component\Console\Command\Command { - + /** + * @var string + */ protected static $defaultName = 'spameri:elastic:create-index'; @@ -13,7 +15,7 @@ public function __construct( private readonly \Spameri\Elastic\Model\DeleteIndex $deleteIndex, ) { - parent::__construct(NULL); + parent::__construct(null); } @@ -26,7 +28,7 @@ protected function configure(): void ) ->addArgument('indexName', \Symfony\Component\Console\Input\InputArgument::REQUIRED) ->addOption( - 'force', 'f', NULL, + 'force', 'f', null, 'Warning this deletes your data! Forces now used index to be deleted before new index is created.', ) ; diff --git a/src/Commands/DeleteIndex.php b/src/Commands/DeleteIndex.php index f4c24700..2609a431 100644 --- a/src/Commands/DeleteIndex.php +++ b/src/Commands/DeleteIndex.php @@ -5,6 +5,9 @@ class DeleteIndex extends \Symfony\Component\Console\Command\Command { + /** + * @var string + */ protected static $defaultName = 'spameri:elastic:delete-index'; @@ -12,7 +15,7 @@ public function __construct( private readonly \Spameri\Elastic\Model\Indices\Delete $delete, ) { - parent::__construct(NULL); + parent::__construct(null); } diff --git a/src/Commands/DumpIndex.php b/src/Commands/DumpIndex.php index ca60f404..d339829c 100644 --- a/src/Commands/DumpIndex.php +++ b/src/Commands/DumpIndex.php @@ -5,6 +5,9 @@ class DumpIndex extends \Symfony\Component\Console\Command\Command { + /** + * @var string + */ protected static $defaultName = 'spameri:elastic:dump-index'; @@ -12,7 +15,7 @@ public function __construct( private readonly \Spameri\Elastic\Model\DumpIndex $migrate, ) { - parent::__construct(NULL); + parent::__construct(null); } diff --git a/src/Commands/InitializeIndexes.php b/src/Commands/InitializeIndexes.php index 9a13346c..39a165a5 100644 --- a/src/Commands/InitializeIndexes.php +++ b/src/Commands/InitializeIndexes.php @@ -5,6 +5,9 @@ class InitializeIndexes extends \Symfony\Component\Console\Command\Command { + /** + * @var string + */ protected static $defaultName = 'spameri:elastic:initialize-index'; @@ -14,7 +17,7 @@ public function __construct( private readonly \Spameri\Elastic\Model\InitializeIndex $initializeIndex, ) { - parent::__construct(NULL); + parent::__construct(null); } @@ -27,7 +30,7 @@ protected function configure(): void ) ->addArgument('entityName', \Symfony\Component\Console\Input\InputArgument::IS_ARRAY) ->addOption( - 'force', 'f', NULL, + 'force', 'f', null, 'Warning this deletes your data! Forces now used index to be deleted before new index is created.', ) ; @@ -52,7 +55,7 @@ protected function execute( $settings = $indexConfig->provide(); foreach ($entityNames as $entityName) { - if (\strpos($settings->indexName(), $entityName) === FALSE) { + if (\strpos($settings->indexName(), $entityName) === false) { continue 2; } } diff --git a/src/Commands/LoadDump.php b/src/Commands/LoadDump.php index 199f9e2e..d3360186 100644 --- a/src/Commands/LoadDump.php +++ b/src/Commands/LoadDump.php @@ -5,6 +5,9 @@ class LoadDump extends \Symfony\Component\Console\Command\Command { + /** + * @var string + */ protected static $defaultName = 'spameri:elastic:load-dump'; @@ -12,7 +15,7 @@ public function __construct( private readonly \Spameri\Elastic\Model\RestoreIndex $migrate, ) { - parent::__construct(NULL); + parent::__construct(null); } diff --git a/src/Commands/RemoveAlias.php b/src/Commands/RemoveAlias.php index fdbab6fe..5804395c 100644 --- a/src/Commands/RemoveAlias.php +++ b/src/Commands/RemoveAlias.php @@ -5,6 +5,9 @@ class RemoveAlias extends \Symfony\Component\Console\Command\Command { + /** + * @var string + */ protected static $defaultName = 'spameri:elastic:remove-alias'; @@ -12,7 +15,7 @@ public function __construct( private readonly \Spameri\Elastic\Model\Indices\RemoveAlias $removeAlias, ) { - parent::__construct(NULL); + parent::__construct(null); } diff --git a/src/Commands/TypeToNewIndex.php b/src/Commands/TypeToNewIndex.php index f57fe651..159c0c8f 100644 --- a/src/Commands/TypeToNewIndex.php +++ b/src/Commands/TypeToNewIndex.php @@ -5,6 +5,9 @@ class TypeToNewIndex extends \Symfony\Component\Console\Command\Command { + /** + * @var string + */ protected static $defaultName = 'spameri:elastic:move-type'; @@ -12,7 +15,7 @@ public function __construct( private readonly \Spameri\Elastic\Model\TypeToNewIndex\Migrate $migrate, ) { - parent::__construct(NULL); + parent::__construct(null); } @@ -28,11 +31,11 @@ protected function configure(): void ->addArgument('typeFrom', \Symfony\Component\Console\Input\InputArgument::REQUIRED) ->addArgument('indexTo', \Symfony\Component\Console\Input\InputArgument::REQUIRED) ->addArgument('aliasTo', \Symfony\Component\Console\Input\InputArgument::REQUIRED) - ->addArgument('typeTo', \Symfony\Component\Console\Input\InputArgument::OPTIONAL, 'Use only on old ElasticSearch', NULL) + ->addArgument('typeTo', \Symfony\Component\Console\Input\InputArgument::OPTIONAL, 'Use only on old ElasticSearch', null) ->addOption( 'allowClose', 'c', \Symfony\Component\Console\Input\InputOption::VALUE_OPTIONAL, 'Allows command to close index for data transfer. After data is transferred index is opened and resumes normal operations. When open it needs to check changed files after move and sync remaining.', - TRUE, + true, ) ; } diff --git a/src/Model/Insert/PrepareEntityArray.php b/src/Model/Insert/PrepareEntityArray.php index 98e5912a..00ee6a2c 100644 --- a/src/Model/Insert/PrepareEntityArray.php +++ b/src/Model/Insert/PrepareEntityArray.php @@ -7,6 +7,9 @@ class PrepareEntityArray public const ENTITY_CLASS = 'entityClass'; + /** + * @var array + */ private array $insertedEntities; @@ -22,7 +25,7 @@ public function __construct( */ public function prepare( \Spameri\Elastic\Entity\ElasticEntityInterface $entity, - bool $hasSti = FALSE, + bool $hasSti = false, ): array { $this->insertedEntities = []; @@ -30,7 +33,7 @@ public function prepare( $entityVariables = $entity->entityVariables(); if ($hasSti === true) { - $entityVariables[self::ENTITY_CLASS] = \get_class($entity); + $entityVariables[self::ENTITY_CLASS] = $entity::class; } return $this->iterateVariables($entityVariables); @@ -59,7 +62,7 @@ public function iterateVariables( } elseif ($property instanceof \Spameri\Elastic\Entity\ElasticEntityInterface) { throw new \Spameri\Elastic\Exception\DocumentInsertFailed( - 'Entity ' . \get_class($property) . ' must be extend AbstractElasticEntity.' + 'Entity ' . $property::class . ' must be extend AbstractElasticEntity.', ); } elseif ($property instanceof \Spameri\Elastic\Entity\EntityInterface) { @@ -72,7 +75,7 @@ public function iterateVariables( $preparedArray[$key] = []; foreach ($property as $item) { $iterateVariables = $this->iterateVariables($item->entityVariables()); - $iterateVariables[self::ENTITY_CLASS] = \get_class($item); + $iterateVariables[self::ENTITY_CLASS] = $item::class; $preparedArray[$key][] = $iterateVariables; } @@ -119,7 +122,7 @@ public function iterateVariables( || \is_int($property) || \is_bool($property) || \is_float($property) - || $property === NULL + || $property === null ) { $preparedArray[$key] = $property; @@ -140,7 +143,7 @@ public function iterateVariables( } else { if (\is_object($property)) { throw new \Spameri\Elastic\Exception\EntityIsNotValid( - 'Property ' . $key . ' in ' . \get_class($property) . ' is not supported.', + 'Property ' . $key . ' in ' . $property::class . ' is not supported.', ); } diff --git a/tests/SpameriTests/Elastic/Data/Model/VideoFactory.php b/tests/SpameriTests/Elastic/Data/Model/VideoFactory.php index d3a8205d..092ee716 100644 --- a/tests/SpameriTests/Elastic/Data/Model/VideoFactory.php +++ b/tests/SpameriTests/Elastic/Data/Model/VideoFactory.php @@ -5,14 +5,10 @@ class VideoFactory implements \Spameri\Elastic\Factory\EntityFactoryInterface { - private \SpameriTests\Elastic\Data\Model\PersonService $personService; - - public function __construct( - \SpameriTests\Elastic\Data\Model\PersonService $personService, + private \SpameriTests\Elastic\Data\Model\PersonService $personService, ) { - $this->personService = $personService; } From cd2d7c21d253b56e8e9bbc9d41d2e0b554a19289 Mon Sep 17 00:00:00 2001 From: Spamer Date: Thu, 4 Apr 2024 16:58:03 +0200 Subject: [PATCH 37/37] ci versions bump --- .github/ci.yml | 2 +- .github/workflows/ci.yml | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/ci.yml b/.github/ci.yml index ae161fac..bca704a5 100644 --- a/.github/ci.yml +++ b/.github/ci.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php: [ 7.4 ] + php: [ 8.2 ] version: [ lowest, standard ] steps: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c403febb..e1f8c8d5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,9 +9,9 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php: [ 7.4, 8.0, 8.1 ] + php: [ 8.2, 8.3 ] version: [ lowest, standard ] - elastic: [ 7.12.1 ] + elastic: [ 8.12.0 ] steps: - uses: actions/checkout@v2 @@ -39,15 +39,15 @@ jobs: name: Composer standard run: make composer - - if: matrix.php == '7.4' + - if: matrix.php == '8.2' name: Coding standard run: make cs - - if: matrix.php == '7.4' && matrix.version == 'lowest' + - if: matrix.php == '8.2' && matrix.version == 'lowest' name: PHPStan lowest run: make phpstan-lowest - - if: matrix.php == '7.4' && matrix.version == 'standard' + - if: matrix.php == '8.2' && matrix.version == 'standard' name: PHPStan standard run: make phpstan