Skip to content

Commit

Permalink
[Task][PD-109] Check usage of private vs protected methods and decide…
Browse files Browse the repository at this point in the history
… which classes should be final (#7)

* check usage of private vs protected methods and decide which classes should be final

* Apply php-cs-fixer changes

* fix: remove unused injections

* fix: qodana

---------

Co-authored-by: lukmzig <lukmzig@users.noreply.github.com>
  • Loading branch information
lukmzig and lukmzig authored Jan 30, 2024
1 parent 6673dad commit 82b8793
Show file tree
Hide file tree
Showing 62 changed files with 380 additions and 188 deletions.
9 changes: 6 additions & 3 deletions src/Command/Update/IndexUpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Contracts\Service\Attribute\Required;

class IndexUpdateCommand extends AbstractCommand
/**
* @internal
*/
final class IndexUpdateCommand extends AbstractCommand
{
use LockableTrait;

Expand All @@ -36,9 +39,9 @@ class IndexUpdateCommand extends AbstractCommand

private const OPTION_RECREATE_INDEX = 'recreate_index';

protected IndexUpdateService $indexUpdateService;
private IndexUpdateService $indexUpdateService;

protected EnqueueService $enqueueService;
private EnqueueService $enqueueService;

#[Required]
public function setIndexUpdateService(IndexUpdateService $indexUpdateService): void
Expand Down
3 changes: 3 additions & 0 deletions src/Controller/DefaultController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

use Symfony\Component\HttpFoundation\Response;

/**
* @internal
*/
final class DefaultController
{
public function defaultAction(): Response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;

class SearchIndexFieldDefinitionPass implements CompilerPassInterface
/**
* @internal
*/
final class SearchIndexFieldDefinitionPass implements CompilerPassInterface
{
/**
* @param ContainerBuilder $container
Expand Down
4 changes: 4 additions & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
*
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/configuration.html}
*/

/**
* @internal
*/
class Configuration implements ConfigurationInterface
{
/**
Expand Down
8 changes: 5 additions & 3 deletions src/DependencyInjection/PimcoreGenericDataIndexExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
*
* @link http://symfony.com/doc/current/cookbook/bundles/extension.html
*/

/**
* @internal
*/
class PimcoreGenericDataIndexExtension extends Extension implements PrependExtensionInterface
{
/**
Expand Down Expand Up @@ -60,7 +64,7 @@ public function prepend(ContainerBuilder $container): void
$container->prependExtensionConfig('doctrine', $config['doctrine']);
}

protected function registerIndexServiceParams(ContainerBuilder $container, array $indexSettings): static
private function registerIndexServiceParams(ContainerBuilder $container, array $indexSettings): void
{
$definition = $container->getDefinition(SearchIndexConfigService::class);
$definition->setArgument('$indexPrefix', $indexSettings['client_params']['index_prefix']);
Expand All @@ -73,7 +77,5 @@ protected function registerIndexServiceParams(ContainerBuilder $container, array
$definition->setArgument('$username', $indexSettings['client_params']['username']);
$definition->setArgument('$password', $indexSettings['client_params']['password']);
$definition->setArgument('$sslVerification', $indexSettings['client_params']['ssl_verification']);

return $this;
}
}
3 changes: 3 additions & 0 deletions src/Entity/IndexQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
#[ORM\Table(name: self::TABLE)]
#[ORM\Index(columns: ['dispatched'], name: self::TABLE . '_dispatched')]

/**
* @internal
*/
class IndexQueue
{
public const TABLE = 'generic_data_index_queue';
Expand Down
3 changes: 3 additions & 0 deletions src/Enum/DependencyInjection/CompilerPassTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

namespace Pimcore\Bundle\GenericDataIndexBundle\Enum\DependencyInjection;

/**
* @internal
*/
enum CompilerPassTag: string
{
case DATA_OBJECT_SEARCH_INDEX_FIELD_DEFINITION =
Expand Down
3 changes: 3 additions & 0 deletions src/Enum/Messenger/TransportName.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

namespace Pimcore\Bundle\GenericDataIndexBundle\Enum\Messenger;

/**
* @internal
*/
enum TransportName: string
{
case INDEX_QUEUE = 'pimcore_generic_data_index_queue';
Expand Down
3 changes: 3 additions & 0 deletions src/Enum/SearchIndex/ElementType.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

namespace Pimcore\Bundle\GenericDataIndexBundle\Enum\SearchIndex;

/**
* @internal
*/
enum ElementType: string
{
case ASSET = 'asset';
Expand Down
3 changes: 3 additions & 0 deletions src/Enum/SearchIndex/FieldCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

namespace Pimcore\Bundle\GenericDataIndexBundle\Enum\SearchIndex;

/**
* @internal
*/
enum FieldCategory: string
{
case SYSTEM_FIELDS = 'system_fields';
Expand Down
3 changes: 3 additions & 0 deletions src/Enum/SearchIndex/FieldCategory/SystemField.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

namespace Pimcore\Bundle\GenericDataIndexBundle\Enum\SearchIndex\FieldCategory;

/**
* @internal
*/
enum SystemField: string
{
case ID = 'id';
Expand Down
3 changes: 3 additions & 0 deletions src/Enum/SearchIndex/IndexName.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

namespace Pimcore\Bundle\GenericDataIndexBundle\Enum\SearchIndex;

/**
* @internal
*/
enum IndexName: string
{
case ASSET = 'asset';
Expand Down
3 changes: 3 additions & 0 deletions src/Enum/SearchIndex/IndexQueueOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

namespace Pimcore\Bundle\GenericDataIndexBundle\Enum\SearchIndex;

/**
* @internal
*/
enum IndexQueueOperation: string
{
case UPDATE = 'update';
Expand Down
3 changes: 3 additions & 0 deletions src/Enum/SearchIndex/OpenSearch/AttributeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

namespace Pimcore\Bundle\GenericDataIndexBundle\Enum\SearchIndex\OpenSearch;

/**
* @internal
*/
enum AttributeType: string
{
case TEXT = 'text';
Expand Down
17 changes: 8 additions & 9 deletions src/EventSubscriber/IndexUpdateSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
use Pimcore\Bundle\GenericDataIndexBundle\Installer;
use Pimcore\Bundle\GenericDataIndexBundle\Service\SearchIndex\IndexQueue\EnqueueService;
use Pimcore\Bundle\GenericDataIndexBundle\Service\SearchIndex\IndexQueueService;
use Pimcore\Bundle\GenericDataIndexBundle\Service\SearchIndex\IndexService\IndexHandler\AssetIndexHandler;
use Pimcore\Bundle\GenericDataIndexBundle\Service\SearchIndex\IndexService\IndexHandler\DataObjectIndexHandler;
use Pimcore\Bundle\GenericDataIndexBundle\Service\SearchIndex\OpenSearch\OpenSearchService;
use Pimcore\Bundle\GenericDataIndexBundle\Traits\LoggerAwareTrait;
use Pimcore\Event\AssetEvents;
use Pimcore\Event\DataObjectClassDefinitionEvents;
Expand All @@ -35,17 +33,18 @@
use Pimcore\Model\Element\Service;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class IndexUpdateSubscriber implements EventSubscriberInterface
/**
* @internal
*/
final class IndexUpdateSubscriber implements EventSubscriberInterface

Check notice on line 39 in src/EventSubscriber/IndexUpdateSubscriber.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Efferent coupling between objects

\[EA\] High efferent coupling (21).
{
use LoggerAwareTrait;

public function __construct(
protected readonly IndexQueueService $indexQueueService,
protected readonly EnqueueService $enqueueService,
protected readonly DataObjectIndexHandler $dataObjectMappingHandler,
protected readonly AssetIndexHandler $assetMappingHandler,
protected readonly OpenSearchService $openSearchService,
protected readonly Installer $installer,
private readonly IndexQueueService $indexQueueService,
private readonly EnqueueService $enqueueService,
private readonly DataObjectIndexHandler $dataObjectMappingHandler,
private readonly Installer $installer,
) {
}

Expand Down
23 changes: 23 additions & 0 deletions src/Exception/DataObjectNormalizerException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
declare(strict_types=1);

/**
* Pimcore
*
* This source file is available under following license:
* - Pimcore Commercial License (PCL)
*
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
* @license http://www.pimcore.org/license PCL
*/

namespace Pimcore\Bundle\GenericDataIndexBundle\Exception;

use RuntimeException;

/**
* @internal
*/
final class DataObjectNormalizerException extends RuntimeException implements GenericDataIndexBundleExceptionInterface
{
}
5 changes: 4 additions & 1 deletion src/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

use Pimcore;

class Installer extends Pimcore\Extension\Bundle\Installer\SettingsStoreAwareInstaller
/**
* @internal
*/
final class Installer extends Pimcore\Extension\Bundle\Installer\SettingsStoreAwareInstaller
{
}
5 changes: 4 additions & 1 deletion src/Message/DispatchQueueMessagesMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

namespace Pimcore\Bundle\GenericDataIndexBundle\Message;

class DispatchQueueMessagesMessage
/**
* @internal
*/
final class DispatchQueueMessagesMessage
{
}
7 changes: 5 additions & 2 deletions src/Message/IndexUpdateQueueMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@

namespace Pimcore\Bundle\GenericDataIndexBundle\Message;

class IndexUpdateQueueMessage
/**
* @internal
*/
final class IndexUpdateQueueMessage
{
public function __construct(protected array $entries)
public function __construct(private readonly array $entries)
{
}

Expand Down
11 changes: 7 additions & 4 deletions src/MessageHandler/DispatchQueueMessagesHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
use Symfony\Component\Messenger\MessageBusInterface;

/**
* @internal
*/
#[AsMessageHandler]
class DispatchQueueMessagesHandler
final class DispatchQueueMessagesHandler
{
public function __construct(
protected readonly IndexQueueRepository $indexQueueRepository,
protected readonly QueueMessagesDispatcher $queueMessagesDispatcher,
protected readonly MessageBusInterface $messageBus
private readonly IndexQueueRepository $indexQueueRepository,
private readonly QueueMessagesDispatcher $queueMessagesDispatcher,
private readonly MessageBusInterface $messageBus
) {
}

Expand Down
9 changes: 6 additions & 3 deletions src/MessageHandler/IndexUpdateQueueHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
use Symfony\Component\Serializer\Exception\ExceptionInterface;

/**
* @internal
*/
#[AsMessageHandler]
class IndexUpdateQueueHandler
final class IndexUpdateQueueHandler
{
public function __construct(
protected readonly IndexQueueService $indexQueueService,
protected readonly IndexQueueRepository $indexQueueRepository,
private readonly IndexQueueService $indexQueueService,
private readonly IndexQueueRepository $indexQueueRepository,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/Repository/IndexQueueRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
use Symfony\Component\Serializer\Exception\ExceptionInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;

class IndexQueueRepository extends ServiceEntityRepository
final class IndexQueueRepository extends ServiceEntityRepository

Check notice on line 27 in src/Repository/IndexQueueRepository.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Long inheritance chain

\[EA\] Class has 3 parent classes, consider using appropriate design patterns.
{
use LoggerAwareTrait;

Expand Down
5 changes: 4 additions & 1 deletion src/Scheduler/GenericDataIndexScheduleProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@
use Symfony\Component\Scheduler\Schedule;
use Symfony\Component\Scheduler\ScheduleProviderInterface;

/**
* @internal
*/
#[AsSchedule('generic_data_index')]
class GenericDataIndexScheduleProvider implements ScheduleProviderInterface
final class GenericDataIndexScheduleProvider implements ScheduleProviderInterface
{
public function __construct(
private readonly QueueMessagesDispatcher $queueMessagesDispatcher,
Expand Down
9 changes: 8 additions & 1 deletion src/Service/Normalizer/AssetNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,19 @@
use Pimcore\Bundle\GenericDataIndexBundle\Enum\SearchIndex\FieldCategory;
use Pimcore\Bundle\GenericDataIndexBundle\Enum\SearchIndex\FieldCategory\SystemField;
use Pimcore\Bundle\GenericDataIndexBundle\Service\Workflow\WorkflowService;
use Pimcore\Bundle\GenericDataIndexBundle\Traits\ElementNormalizerTrait;
use Pimcore\Model\Asset;
use Pimcore\Model\Element\ElementInterface;
use Pimcore\Model\Element\Service;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;

class AssetNormalizer extends AbstractElementNormalizer
/**
* @internal
*/
final class AssetNormalizer implements NormalizerInterface
{
use ElementNormalizerTrait;

public const NOT_LOCALIZED_KEY = 'default';

public function __construct(private readonly WorkflowService $workflowService)
Expand Down
Loading

0 comments on commit 82b8793

Please sign in to comment.