Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PHP 8.0] Add promoted properties in Stage, Sms, Report and Point bundles - step 3 #13005

Merged
merged 3 commits into from Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -31,24 +31,20 @@ class TriggerApiController extends CommonApiController
*/
protected $model;

private ?RequestStack $requestStack = null;

public function __construct(
CorePermissions $security,
Translator $translator,
EntityResultHelper $entityResultHelper,
RouterInterface $router,
FormFactoryInterface $formFactory,
AppVersion $appVersion,
RequestStack $requestStack,
private ?RequestStack $requestStack,
ManagerRegistry $doctrine,
ModelFactory $modelFactory,
EventDispatcherInterface $dispatcher,
CoreParametersHelper $coreParametersHelper,
MauticFactory $factory
) {
$this->requestStack = $requestStack;

$triggerModel = $modelFactory->getModel('point.trigger');
\assert($triggerModel instanceof TriggerModel);

Expand Down
5 changes: 1 addition & 4 deletions app/bundles/PointBundle/Event/GroupEvent.php
Expand Up @@ -8,11 +8,8 @@

final class GroupEvent
{
private Group $entity;

public function __construct(Group $group)
public function __construct(private Group $entity)

Check warning on line 11 in app/bundles/PointBundle/Event/GroupEvent.php

View check run for this annotation

Codecov / codecov/patch

app/bundles/PointBundle/Event/GroupEvent.php#L11

Added line #L11 was not covered by tests
{
$this->entity = $group;
}

public function getGroup(): Group
Expand Down
8 changes: 1 addition & 7 deletions app/bundles/PointBundle/Event/PointActionEvent.php
Expand Up @@ -8,14 +8,8 @@

class PointActionEvent extends CommonEvent
{
protected \Mautic\PointBundle\Entity\Point $point;

protected \Mautic\LeadBundle\Entity\Lead $lead;

public function __construct(Point $point, Lead $lead)
public function __construct(protected Point $point, protected Lead $lead)
{
$this->point = $point;
$this->lead = $lead;
}

/**
Expand Down
5 changes: 1 addition & 4 deletions app/bundles/PointBundle/Event/PointBuilderEvent.php
Expand Up @@ -13,11 +13,8 @@ class PointBuilderEvent extends Event
*/
private $actions = [];

private \Symfony\Contracts\Translation\TranslatorInterface $translator;

public function __construct(TranslatorInterface $translator)
public function __construct(private TranslatorInterface $translator)
{
$this->translator = $translator;
}

/**
Expand Down
5 changes: 1 addition & 4 deletions app/bundles/PointBundle/Event/TriggerBuilderEvent.php
Expand Up @@ -13,11 +13,8 @@ class TriggerBuilderEvent extends Event
*/
private $events = [];

private \Symfony\Contracts\Translation\TranslatorInterface $translator;

public function __construct(TranslatorInterface $translator)
public function __construct(private TranslatorInterface $translator)
{
$this->translator = $translator;
}

/**
Expand Down
8 changes: 1 addition & 7 deletions app/bundles/PointBundle/Event/TriggerEvent.php
Expand Up @@ -12,18 +12,12 @@ class TriggerEvent extends CommonEvent
*/
protected $entity;

/**
* @var bool
*/
protected $isNew;

/**
* @param bool $isNew
*/
public function __construct(Trigger &$trigger, $isNew = false)
public function __construct(Trigger &$trigger, protected $isNew = false)
{
$this->entity = &$trigger;
$this->isNew = $isNew;
}

/**
Expand Down
8 changes: 1 addition & 7 deletions app/bundles/PointBundle/Event/TriggerExecutedEvent.php
Expand Up @@ -8,17 +8,11 @@

class TriggerExecutedEvent extends Event
{
private TriggerEventEntity $triggerEvent;

private \Mautic\LeadBundle\Entity\Lead $lead;

/** @var bool */
private $result;

public function __construct(TriggerEventEntity $triggerEvent, Lead $lead)
public function __construct(private TriggerEventEntity $triggerEvent, private Lead $lead)
{
$this->triggerEvent = $triggerEvent;
$this->lead = $lead;
}

/**
Expand Down
Expand Up @@ -34,11 +34,8 @@ class DashboardSubscriber extends MainDashboardSubscriber
'point:points:viewother',
];

protected \Mautic\PointBundle\Model\PointModel $pointModel;

public function __construct(PointModel $pointModel)
public function __construct(protected PointModel $pointModel)
{
$this->pointModel = $pointModel;
}

/**
Expand Down
Expand Up @@ -11,11 +11,8 @@

class GroupScoreSubscriber implements EventSubscriberInterface
{
private TriggerModel $triggerModel;

public function __construct(TriggerModel $triggerModel)
public function __construct(private TriggerModel $triggerModel)
{
$this->triggerModel = $triggerModel;
}

/**
Expand Down
24 changes: 2 additions & 22 deletions app/bundles/PointBundle/EventListener/LeadSubscriber.php
Expand Up @@ -16,28 +16,8 @@

class LeadSubscriber implements EventSubscriberInterface
{
private \Mautic\PointBundle\Model\TriggerModel $triggerModel;

private \Symfony\Contracts\Translation\TranslatorInterface $translator;

private \Mautic\LeadBundle\Entity\PointsChangeLogRepository $pointsChangeLogRepository;

private \Mautic\PointBundle\Entity\LeadPointLogRepository $leadPointLogRepository;

private \Mautic\PointBundle\Entity\LeadTriggerLogRepository $leadTriggerLogRepository;

public function __construct(
TriggerModel $triggerModel,
TranslatorInterface $translator,
PointsChangeLogRepository $pointsChangeLogRepository,
LeadPointLogRepository $leadPointLogRepository,
LeadTriggerLogRepository $leadTriggerLogRepository
) {
$this->triggerModel = $triggerModel;
$this->translator = $translator;
$this->pointsChangeLogRepository = $pointsChangeLogRepository;
$this->leadPointLogRepository = $leadPointLogRepository;
$this->leadTriggerLogRepository = $leadTriggerLogRepository;
public function __construct(private TriggerModel $triggerModel, private TranslatorInterface $translator, private PointsChangeLogRepository $pointsChangeLogRepository, private LeadPointLogRepository $leadPointLogRepository, private LeadTriggerLogRepository $leadTriggerLogRepository)
{
}

/**
Expand Down
8 changes: 1 addition & 7 deletions app/bundles/PointBundle/EventListener/PointSubscriber.php
Expand Up @@ -10,14 +10,8 @@

class PointSubscriber implements EventSubscriberInterface
{
private \Mautic\CoreBundle\Helper\IpLookupHelper $ipLookupHelper;

private \Mautic\CoreBundle\Model\AuditLogModel $auditLogModel;

public function __construct(IpLookupHelper $ipLookupHelper, AuditLogModel $auditLogModel)
public function __construct(private IpLookupHelper $ipLookupHelper, private AuditLogModel $auditLogModel)
{
$this->ipLookupHelper = $ipLookupHelper;
$this->auditLogModel = $auditLogModel;
}

/**
Expand Down
5 changes: 1 addition & 4 deletions app/bundles/PointBundle/EventListener/ReportSubscriber.php
Expand Up @@ -41,11 +41,8 @@ class ReportSubscriber implements EventSubscriberInterface
self::CONTEXT_GROUP_SCORE,
];

private \Mautic\LeadBundle\Report\FieldsBuilder $fieldsBuilder;

public function __construct(FieldsBuilder $fieldsBuilder)
public function __construct(private FieldsBuilder $fieldsBuilder)
{
$this->fieldsBuilder = $fieldsBuilder;
}

/**
Expand Down
20 changes: 2 additions & 18 deletions app/bundles/PointBundle/EventListener/SearchSubscriber.php
Expand Up @@ -12,24 +12,8 @@

class SearchSubscriber implements EventSubscriberInterface
{
private \Mautic\PointBundle\Model\PointModel $pointModel;

private \Mautic\PointBundle\Model\TriggerModel $pointTriggerModel;

private \Mautic\CoreBundle\Security\Permissions\CorePermissions $security;

private \Twig\Environment $twig;

public function __construct(
PointModel $pointModel,
TriggerModel $pointTriggerModel,
CorePermissions $security,
Environment $twig
) {
$this->pointModel = $pointModel;
$this->pointTriggerModel = $pointTriggerModel;
$this->security = $security;
$this->twig = $twig;
public function __construct(private PointModel $pointModel, private TriggerModel $pointTriggerModel, private CorePermissions $security, private Environment $twig)
{
}

/**
Expand Down
Expand Up @@ -14,20 +14,8 @@

class SegmentFilterSubscriber implements EventSubscriberInterface
{
private GroupRepository $groupRepository;

private TypeOperatorProviderInterface $typeOperatorProvider;

private TranslatorInterface $translator;

public function __construct(
GroupRepository $groupRepository,
TypeOperatorProviderInterface $typeOperatorProvider,
TranslatorInterface $translator)
public function __construct(private GroupRepository $groupRepository, private TypeOperatorProviderInterface $typeOperatorProvider, private TranslatorInterface $translator)
{
$this->groupRepository = $groupRepository;
$this->typeOperatorProvider = $typeOperatorProvider;
$this->translator = $translator;
}

/**
Expand Down
5 changes: 1 addition & 4 deletions app/bundles/PointBundle/Form/Type/PointType.php
Expand Up @@ -21,11 +21,8 @@

class PointType extends AbstractType
{
private \Mautic\CoreBundle\Security\Permissions\CorePermissions $security;

public function __construct(CorePermissions $security)
public function __construct(private CorePermissions $security)
{
$this->security = $security;
}

/**
Expand Down
5 changes: 1 addition & 4 deletions app/bundles/PointBundle/Form/Type/TriggerType.php
Expand Up @@ -21,11 +21,8 @@

class TriggerType extends AbstractType
{
private \Mautic\CoreBundle\Security\Permissions\CorePermissions $security;

public function __construct(CorePermissions $security)
public function __construct(private CorePermissions $security)
{
$this->security = $security;
}

/**
Expand Down
37 changes: 9 additions & 28 deletions app/bundles/PointBundle/Model/PointModel.php
Expand Up @@ -36,27 +36,15 @@
*/
class PointModel extends CommonFormModel
{
protected RequestStack $requestStack;

protected \Mautic\CoreBundle\Helper\IpLookupHelper $ipLookupHelper;

protected \Mautic\LeadBundle\Model\LeadModel $leadModel;

/**
* @deprecated https://github.com/mautic/mautic/issues/8229
*/
protected \Mautic\CoreBundle\Factory\MauticFactory $mauticFactory;

private \Mautic\LeadBundle\Tracker\ContactTracker $contactTracker;

private PointGroupModel $pointGroupModel;

public function __construct(
RequestStack $requestStack,
IpLookupHelper $ipLookupHelper,
LeadModel $leadModel,
MauticFactory $mauticFactory,
ContactTracker $contactTracker,
protected RequestStack $requestStack,
protected IpLookupHelper $ipLookupHelper,
protected LeadModel $leadModel,
/**
* @deprecated https://github.com/mautic/mautic/issues/8229
*/
protected MauticFactory $mauticFactory,
private ContactTracker $contactTracker,
EntityManager $em,
CorePermissions $security,
EventDispatcherInterface $dispatcher,
Expand All @@ -65,15 +53,8 @@ public function __construct(
UserHelper $userHelper,
LoggerInterface $mauticLogger,
CoreParametersHelper $coreParametersHelper,
PointGroupModel $pointGroupModel
private PointGroupModel $pointGroupModel
) {
$this->requestStack = $requestStack;
$this->ipLookupHelper = $ipLookupHelper;
$this->leadModel = $leadModel;
$this->mauticFactory = $mauticFactory;
$this->contactTracker = $contactTracker;
$this->pointGroupModel = $pointGroupModel;

parent::__construct($em, $security, $dispatcher, $router, $translator, $userHelper, $mauticLogger, $coreParametersHelper);
}

Expand Down
32 changes: 8 additions & 24 deletions app/bundles/PointBundle/Model/TriggerModel.php
Expand Up @@ -36,30 +36,20 @@ class TriggerModel extends CommonFormModel
{
protected $triggers = [];

protected \Mautic\CoreBundle\Helper\IpLookupHelper $ipLookupHelper;

protected \Mautic\LeadBundle\Model\LeadModel $leadModel;

protected \Mautic\PointBundle\Model\TriggerEventModel $pointTriggerEventModel;

/**
* @deprecated https://github.com/mautic/mautic/issues/8229
*/
protected \Mautic\CoreBundle\Factory\MauticFactory $mauticFactory;

private \Mautic\LeadBundle\Tracker\ContactTracker $contactTracker;

/**
* @var array<string,array<string,mixed>>
*/
private static array $events;

public function __construct(
IpLookupHelper $ipLookupHelper,
LeadModel $leadModel,
TriggerEventModel $pointTriggerEventModel,
MauticFactory $mauticFactory,
ContactTracker $contactTracker,
protected IpLookupHelper $ipLookupHelper,
protected LeadModel $leadModel,
protected TriggerEventModel $pointTriggerEventModel,
/**
* @deprecated https://github.com/mautic/mautic/issues/8229
*/
protected MauticFactory $mauticFactory,
private ContactTracker $contactTracker,
EntityManagerInterface $em,
CorePermissions $security,
EventDispatcherInterface $dispatcher,
Expand All @@ -69,12 +59,6 @@ public function __construct(
LoggerInterface $mauticLogger,
CoreParametersHelper $coreParametersHelper
) {
$this->ipLookupHelper = $ipLookupHelper;
$this->leadModel = $leadModel;
$this->pointTriggerEventModel = $pointTriggerEventModel;
$this->mauticFactory = $mauticFactory;
$this->contactTracker = $contactTracker;

parent::__construct($em, $security, $dispatcher, $router, $translator, $userHelper, $mauticLogger, $coreParametersHelper);
}

Expand Down
5 changes: 1 addition & 4 deletions app/bundles/ReportBundle/Adapter/ReportDataAdapter.php
Expand Up @@ -9,11 +9,8 @@

class ReportDataAdapter
{
private \Mautic\ReportBundle\Model\ReportModel $reportModel;

public function __construct(ReportModel $reportModel)
public function __construct(private ReportModel $reportModel)
{
$this->reportModel = $reportModel;
}

public function getReportData(Report $report, ReportExportOptions $reportExportOptions): ReportDataResult
Expand Down