From 2aa9922925cf9d0ac8871eda5034309b39198cb9 Mon Sep 17 00:00:00 2001 From: Spamer Date: Thu, 4 Apr 2024 16:53:19 +0200 Subject: [PATCH] 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 d86f1c0..dbf45e0 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 edbd288..7526e45 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 587957d..6f31d87 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 f4c2470..2609a43 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 ca60f40..d339829 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 9a13346..39a165a 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 199f9e2..d336018 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 fdbab6f..5804395 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 f57fe65..159c0c8 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 98e5912..00ee6a2 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 d3a8205..092ee71 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; }