Skip to content

Commit

Permalink
cs
Browse files Browse the repository at this point in the history
  • Loading branch information
Spamercz committed Apr 4, 2024
1 parent 903d269 commit 2aa9922
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 27 deletions.
8 changes: 6 additions & 2 deletions ruleset.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" ?>
<ruleset name="Spameri\ElasticQuery">
<ruleset name="Spameri\Elastic">

<config name="installed_paths" value="../../slevomat/coding-standard,../../escapestudios/symfony2-coding-standard"/>

Expand Down Expand Up @@ -83,6 +83,10 @@
<!-- TypeHints -->
<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
<exclude name="SlevomatCodingStandard.TypeHints.DeclareStrictTypes.IncorrectWhitespaceBetweenOpenTagAndDeclare"/>
<properties>
<property name="declareOnFirstLine" type="bool" value="true"/>
<property name="spacesCountAroundEqualsSign" type="int" value="1"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.DisallowArrayTypeHintSyntax"/>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing" />
Expand All @@ -103,7 +107,7 @@
<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName">
<properties>
<property name="rootNamespaces" type="array">
<element key="src" value="Spameri\ElasticQuery"/>
<element key="src" value="Spameri\Elastic"/>
<element key="tests/SpameriTests" value="SpameriTests"/>
</property>
</properties>
Expand Down
5 changes: 4 additions & 1 deletion src/Commands/AddAlias.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
class AddAlias extends \Symfony\Component\Console\Command\Command
{

/**
* @var string
*/
protected static $defaultName = 'spameri:elastic:add-alias';


public function __construct(
private readonly \Spameri\Elastic\Model\Indices\AddAlias $addAlias,
)
{
parent::__construct(NULL);
parent::__construct(null);
}


Expand Down
8 changes: 5 additions & 3 deletions src/Commands/CreateIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

class CreateIndex extends \Symfony\Component\Console\Command\Command
{

/**
* @var string
*/
protected static $defaultName = 'spameri:elastic:create-index';


Expand All @@ -13,7 +15,7 @@ public function __construct(
private readonly \Spameri\Elastic\Model\DeleteIndex $deleteIndex,
)
{
parent::__construct(NULL);
parent::__construct(null);
}


Expand All @@ -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.',
)
;
Expand Down
5 changes: 4 additions & 1 deletion src/Commands/DeleteIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
class DeleteIndex extends \Symfony\Component\Console\Command\Command
{

/**
* @var string
*/
protected static $defaultName = 'spameri:elastic:delete-index';


public function __construct(
private readonly \Spameri\Elastic\Model\Indices\Delete $delete,
)
{
parent::__construct(NULL);
parent::__construct(null);
}


Expand Down
5 changes: 4 additions & 1 deletion src/Commands/DumpIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
class DumpIndex extends \Symfony\Component\Console\Command\Command
{

/**
* @var string
*/
protected static $defaultName = 'spameri:elastic:dump-index';


public function __construct(
private readonly \Spameri\Elastic\Model\DumpIndex $migrate,
)
{
parent::__construct(NULL);
parent::__construct(null);
}


Expand Down
9 changes: 6 additions & 3 deletions src/Commands/InitializeIndexes.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
class InitializeIndexes extends \Symfony\Component\Console\Command\Command
{

/**
* @var string
*/
protected static $defaultName = 'spameri:elastic:initialize-index';


Expand All @@ -14,7 +17,7 @@ public function __construct(
private readonly \Spameri\Elastic\Model\InitializeIndex $initializeIndex,
)
{
parent::__construct(NULL);
parent::__construct(null);
}


Expand All @@ -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.',
)
;
Expand All @@ -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;
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/Commands/LoadDump.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
class LoadDump extends \Symfony\Component\Console\Command\Command
{

/**
* @var string
*/
protected static $defaultName = 'spameri:elastic:load-dump';


public function __construct(
private readonly \Spameri\Elastic\Model\RestoreIndex $migrate,
)
{
parent::__construct(NULL);
parent::__construct(null);
}


Expand Down
5 changes: 4 additions & 1 deletion src/Commands/RemoveAlias.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
class RemoveAlias extends \Symfony\Component\Console\Command\Command
{

/**
* @var string
*/
protected static $defaultName = 'spameri:elastic:remove-alias';


public function __construct(
private readonly \Spameri\Elastic\Model\Indices\RemoveAlias $removeAlias,
)
{
parent::__construct(NULL);
parent::__construct(null);
}


Expand Down
9 changes: 6 additions & 3 deletions src/Commands/TypeToNewIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
class TypeToNewIndex extends \Symfony\Component\Console\Command\Command
{

/**
* @var string
*/
protected static $defaultName = 'spameri:elastic:move-type';


public function __construct(
private readonly \Spameri\Elastic\Model\TypeToNewIndex\Migrate $migrate,
)
{
parent::__construct(NULL);
parent::__construct(null);
}


Expand All @@ -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,
)
;
}
Expand Down
15 changes: 9 additions & 6 deletions src/Model/Insert/PrepareEntityArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ class PrepareEntityArray

public const ENTITY_CLASS = 'entityClass';

/**
* @var array<string, bool>
*/
private array $insertedEntities;


Expand All @@ -22,15 +25,15 @@ public function __construct(
*/
public function prepare(
\Spameri\Elastic\Entity\ElasticEntityInterface $entity,
bool $hasSti = FALSE,
bool $hasSti = false,
): array
{
$this->insertedEntities = [];
$this->insertedEntities[$entity->id()->value()] = true;

$entityVariables = $entity->entityVariables();
if ($hasSti === true) {
$entityVariables[self::ENTITY_CLASS] = \get_class($entity);
$entityVariables[self::ENTITY_CLASS] = $entity::class;
}

return $this->iterateVariables($entityVariables);
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
}

Expand Down Expand Up @@ -119,7 +122,7 @@ public function iterateVariables(
|| \is_int($property)
|| \is_bool($property)
|| \is_float($property)
|| $property === NULL
|| $property === null
) {
$preparedArray[$key] = $property;

Expand All @@ -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.',
);
}

Expand Down
6 changes: 1 addition & 5 deletions tests/SpameriTests/Elastic/Data/Model/VideoFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


Expand Down

0 comments on commit 2aa9922

Please sign in to comment.