Skip to content

Commit

Permalink
php8 improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
solverat committed Oct 23, 2023
1 parent acad0c6 commit 3cecc51
Show file tree
Hide file tree
Showing 26 changed files with 72 additions and 221 deletions.
5 changes: 1 addition & 4 deletions src/Controller/Admin/LogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@

class LogController extends AdminAbstractController
{
protected LogManagerInterface $logManager;

public function __construct(LogManagerInterface $logManager)
public function __construct(protected LogManagerInterface $logManager)
{
$this->logManager = $logManager;
}

public function loadLogsForConnectorAction(Request $request, int $connectorEngineId): JsonResponse
Expand Down
26 changes: 6 additions & 20 deletions src/Controller/Admin/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,14 @@

class SettingsController extends AdminAbstractController
{
protected FormFactoryInterface $formFactory;
protected EnvironmentServiceInterface $environmentService;
protected ConnectorManagerInterface $connectorManager;
protected ConnectorDefinitionRegistryInterface $connectorRegistry;
protected ConnectorServiceInterface $connectorService;
protected ExtJsDataBuilder $extJsDataBuilder;

public function __construct(

FormFactoryInterface $formFactory,
EnvironmentServiceInterface $environmentService,
ConnectorManagerInterface $connectorManager,
ConnectorDefinitionRegistryInterface $connectorRegistry,
ConnectorServiceInterface $connectorService,
ExtJsDataBuilder $extJsDataBuilder
protected FormFactoryInterface $formFactory,
protected EnvironmentServiceInterface $environmentService,
protected ConnectorManagerInterface $connectorManager,
protected ConnectorDefinitionRegistryInterface $connectorRegistry,
protected ConnectorServiceInterface $connectorService,
protected ExtJsDataBuilder $extJsDataBuilder
) {
$this->formFactory = $formFactory;
$this->environmentService = $environmentService;
$this->connectorManager = $connectorManager;
$this->connectorRegistry = $connectorRegistry;
$this->connectorService = $connectorService;
$this->extJsDataBuilder = $extJsDataBuilder;
}

/**
Expand Down
21 changes: 5 additions & 16 deletions src/Controller/Admin/WallsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,13 @@

class WallsController extends AdminAbstractController
{
protected LockServiceInterface $lockService;
protected LoggerInterface $logger;
protected FormFactoryInterface $formFactory;
protected WallManagerInterface $wallManager;
protected ExtJsDataBuilder $extJsDataBuilder;

public function __construct(
LockServiceInterface $lockService,
LoggerInterface $logger,
FormFactoryInterface $formFactory,
WallManagerInterface $wallManager,
ExtJsDataBuilder $extJsDataBuilder
protected LockServiceInterface $lockService,
protected LoggerInterface $logger,
protected FormFactoryInterface $formFactory,
protected WallManagerInterface $wallManager,
protected ExtJsDataBuilder $extJsDataBuilder
) {
$this->lockService = $lockService;
$this->logger = $logger;
$this->formFactory = $formFactory;
$this->wallManager = $wallManager;
$this->extJsDataBuilder = $extJsDataBuilder;
}

public function fetchAllWallsAction(): JsonResponse
Expand Down
10 changes: 4 additions & 6 deletions src/Dto/AbstractData.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@

abstract class AbstractData
{
protected BuildConfig $buildConfig;
protected array $options;
protected mixed $transferredData = null;

public function __construct(BuildConfig $buildConfig, array $options)
{
$this->buildConfig = $buildConfig;
$this->options = $options;
public function __construct(
protected BuildConfig $buildConfig,
protected array $options
) {
}

/**
Expand Down
13 changes: 3 additions & 10 deletions src/Dto/BuildConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,11 @@

class BuildConfig
{
protected FeedInterface $feed;
protected ConnectorEngineConfigurationInterface $engineConfiguration;
protected array $definitionConfiguration;

public function __construct(
FeedInterface $feed,
ConnectorEngineConfigurationInterface $engineConfiguration,
array $definitionConfiguration
protected FeedInterface $feed,
protected ConnectorEngineConfigurationInterface $engineConfiguration,
protected array $definitionConfiguration
) {
$this->feed = $feed;
$this->engineConfiguration = $engineConfiguration;
$this->definitionConfiguration = $definitionConfiguration;
}

public function getEngineConfiguration(): ConnectorEngineConfigurationInterface
Expand Down
11 changes: 4 additions & 7 deletions src/Event/SocialPostBuildEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@

class SocialPostBuildEvent extends Event
{
protected string $connectorName;
protected AbstractData $data;

public function __construct(string $connectorName, AbstractData $data)
{
$this->connectorName = $connectorName;
$this->data = $data;
public function __construct(
protected string $connectorName,
protected AbstractData $data
) {
}

public function getConnectorName(): string
Expand Down
5 changes: 1 addition & 4 deletions src/EventListener/FeedPostListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@

class FeedPostListener implements EventSubscriberInterface
{
protected FeedPostManager $feedPostManager;

public function __construct(FeedPostManager $feedPostManager)
public function __construct(protected FeedPostManager $feedPostManager)
{
$this->feedPostManager = $feedPostManager;
}

public static function getSubscribedEvents(): array
Expand Down
13 changes: 3 additions & 10 deletions src/EventListener/Maintenance/CleanUpLogsTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,11 @@

class CleanUpLogsTask implements TaskInterface
{
protected bool $enabled;
protected int $expirationDays;
protected LogRepositoryInterface $logRepository;

public function __construct(
bool $enabled,
int $expirationDays,
LogRepositoryInterface $logRepository
protected bool $enabled,
protected int $expirationDays,
protected LogRepositoryInterface $logRepository
) {
$this->enabled = $enabled;
$this->expirationDays = $expirationDays;
$this->logRepository = $logRepository;
}

public function execute(): void
Expand Down
21 changes: 5 additions & 16 deletions src/EventListener/Maintenance/CleanUpOldSocialPostsTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,13 @@ class CleanUpOldSocialPostsTask implements TaskInterface
{
public const LOCK_ID = 'social_data_maintenance_task_cleanup_old_social_posts';

protected bool $enabled;
protected bool $deletePoster;
protected int $expirationDays;
protected LockServiceInterface $lockService;
protected SocialPostRepositoryInterface $socialPostRepository;

public function __construct(
bool $enabled,
bool $deletePoster,
int $expirationDays,
LockServiceInterface $lockService,
SocialPostRepositoryInterface $socialPostRepository
protected bool $enabled,
protected bool $deletePoster,
protected int $expirationDays,
protected LockServiceInterface $lockService,
protected SocialPostRepositoryInterface $socialPostRepository
) {
$this->enabled = $enabled;
$this->deletePoster = $deletePoster;
$this->expirationDays = $expirationDays;
$this->lockService = $lockService;
$this->socialPostRepository = $socialPostRepository;
}

public function execute(): void
Expand Down
17 changes: 4 additions & 13 deletions src/EventListener/Maintenance/FetchSocialPostsTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,12 @@ class FetchSocialPostsTask implements TaskInterface
{
public const LOCK_ID = 'social_data_maintenance_task_fetch_social_posts';

protected bool $enabled;
protected float $interval;
protected LockServiceInterface $lockService;
protected SocialPostBuilderProcessor $socialPostBuilderProcessor;

public function __construct(
bool $enabled,
float $interval,
LockServiceInterface $lockService,
SocialPostBuilderProcessor $socialPostBuilderProcessor
protected bool $enabled,
protected float $interval,
protected LockServiceInterface $lockService,
protected SocialPostBuilderProcessor $socialPostBuilderProcessor
) {
$this->enabled = $enabled;
$this->interval = $interval;
$this->lockService = $lockService;
$this->socialPostBuilderProcessor = $socialPostBuilderProcessor;
}

public function execute(): void
Expand Down
7 changes: 2 additions & 5 deletions src/Factory/SocialPostFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@

class SocialPostFactory implements SocialPostFactoryInterface
{
protected EnvironmentService $environmentService;

public function __construct(EnvironmentService $environmentService)
public function __construct(protected EnvironmentService $environmentService)
{
$this->environmentService = $environmentService;
}

public function create(): SocialPostInterface
Expand All @@ -20,4 +17,4 @@ public function create(): SocialPostInterface

return new $objectClass();
}
}
}
7 changes: 2 additions & 5 deletions src/Form/Admin/Type/TagType.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@

class TagType extends AbstractType
{
protected EntityManagerInterface $manager;

public function __construct(EntityManagerInterface $manager)
public function __construct(protected EntityManagerInterface $manager)
{
$this->manager = $manager;
}

public function buildForm(FormBuilderInterface $builder, array $options): void
Expand Down Expand Up @@ -62,4 +59,4 @@ public function configureOptions(OptionsResolver $resolver): void
'data_class' => Tag::class
]);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,10 @@

class ConnectorEngineChoiceType extends AbstractType
{
protected ConnectorDefinitionRegistry $connectorDefinitionRegistry;
protected ConnectorManagerInterface $connectorManager;

public function __construct(
ConnectorDefinitionRegistry $connectorDefinitionRegistry,
ConnectorManagerInterface $connectorManager
protected ConnectorDefinitionRegistry $connectorDefinitionRegistry,
protected ConnectorManagerInterface $connectorManager
) {
$this->connectorDefinitionRegistry = $connectorDefinitionRegistry;
$this->connectorManager = $connectorManager;
}

public function configureOptions(OptionsResolver $resolver): void
Expand Down
9 changes: 2 additions & 7 deletions src/Form/Admin/Type/Wall/FeedType.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,10 @@ class FeedType extends AbstractType
{
use ExtJsTagTransformTrait;

protected ConnectorManagerInterface $connectorManager;
protected EntityManagerInterface $entityManager;

public function __construct(
ConnectorManagerInterface $connectorManager,
EntityManagerInterface $entityManager
protected ConnectorManagerInterface $connectorManager,
protected EntityManagerInterface $entityManager
) {
$this->connectorManager = $connectorManager;
$this->entityManager = $entityManager;
}

public function buildForm(FormBuilderInterface $builder, array $options): void
Expand Down
5 changes: 1 addition & 4 deletions src/Form/Admin/Type/Wall/WallType.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@ class WallType extends AbstractType
{
use ExtJsTagTransformTrait;

protected EntityManagerInterface $entityManager;

public function __construct(EntityManagerInterface $entityManager)
public function __construct(protected EntityManagerInterface $entityManager)
{
$this->entityManager = $entityManager;
}

public function buildForm(FormBuilderInterface $builder, array $options): void
Expand Down
5 changes: 1 addition & 4 deletions src/Logger/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@

class Logger implements LoggerInterface
{
protected \Psr\Log\LoggerInterface $logger;

public function __construct(\Psr\Log\LoggerInterface $logger)
public function __construct(protected \Psr\Log\LoggerInterface $logger)
{
$this->logger = $logger;
}

public function log(string $level, $message, ?array $context = null): void
Expand Down
17 changes: 4 additions & 13 deletions src/Manager/ConnectorManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,12 @@

class ConnectorManager implements ConnectorManagerInterface
{
protected array $availableConnectors;
protected ConnectorDefinitionRegistryInterface $connectorDefinitionRegistry;
protected ConnectorEngineRepositoryInterface $connectorEngineRepository;
protected EntityManagerInterface $entityManager;

public function __construct(
array $availableConnectors,
ConnectorDefinitionRegistryInterface $connectorDefinitionRegistry,
ConnectorEngineRepositoryInterface $connectorEngineRepository,
EntityManagerInterface $entityManager
protected array $availableConnectors,
protected ConnectorDefinitionRegistryInterface $connectorDefinitionRegistry,
protected ConnectorEngineRepositoryInterface $connectorEngineRepository,
protected EntityManagerInterface $entityManager
) {
$this->availableConnectors = $availableConnectors;
$this->connectorDefinitionRegistry = $connectorDefinitionRegistry;
$this->connectorEngineRepository = $connectorEngineRepository;
$this->entityManager = $entityManager;
}

public function getAllActiveConnectorDefinitions(): array
Expand Down
9 changes: 2 additions & 7 deletions src/Manager/FeedPostManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,15 @@
namespace SocialDataBundle\Manager;

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver\Statement;
use Doctrine\DBAL\Query\QueryBuilder;
use Pimcore\Model\DataObject\Concrete;
use SocialDataBundle\Model\FeedInterface;
use Doctrine\ORM\EntityManagerInterface;

class FeedPostManager implements FeedPostManagerInterface
{
protected EntityManagerInterface $entityManager;

public function __construct(EntityManagerInterface $entityManager)
public function __construct(protected EntityManagerInterface $entityManager)
{
$this->entityManager = $entityManager;
}

public function connectFeedWithPost(FeedInterface $feed, Concrete $socialPost): void
Expand Down Expand Up @@ -48,8 +44,7 @@ protected function relationExists(FeedInterface $feed, Concrete $socialPost): bo
'postId' => $socialPost->getId()
]);

/** @var Statement $stmt */
$stmt = $qb->execute();
$stmt = $qb->executeQuery();

return $stmt->rowCount() > 0;
}
Expand Down
Loading

0 comments on commit 3cecc51

Please sign in to comment.