Skip to content

Commit

Permalink
use property promotions (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
cirolosapio authored Mar 28, 2024
1 parent 9256c6c commit a181023
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 194 deletions.
8 changes: 1 addition & 7 deletions Block/Adminhtml/System/Config/DeploymentConfigInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@

class DeploymentConfigInfo extends Field
{
/**
* @var Version
*/
private $version;

/**
* @var string
*/
Expand All @@ -28,10 +23,9 @@ class DeploymentConfigInfo extends Field
*/
public function __construct(
Context $context,
Version $version,
private Version $version,
array $data = []
) {
$this->version = $version;
parent::__construct($context, $data);
}

Expand Down
25 changes: 3 additions & 22 deletions Block/SentryScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,6 @@ class SentryScript extends Template
{
const CURRENT_VERSION = '7.39.0';

/**
* @var DataHelper
*/
private $dataHelper;

/**
* @var Version
*/
private $version;

/**
* @var Json
*/
private $json;

/**
* SentryScript constructor.
*
Expand All @@ -34,16 +19,12 @@ class SentryScript extends Template
* @param array $data
*/
public function __construct(
DataHelper $dataHelper,
Version $version,
private DataHelper $dataHelper,
private Version $version,
Template\Context $context,
Json $json,
private Json $json,
array $data = []
) {
$this->dataHelper = $dataHelper;
$this->version = $version;
$this->json = $json;

parent::__construct($context, $data);
}

Expand Down
40 changes: 5 additions & 35 deletions Controller/Adminhtml/Test/Sentry.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace JustBetter\Sentry\Controller\Adminhtml\Test;

use JustBetter\Sentry\Helper\Data;
use JustBetter\Sentry\Model\SentryLog;
use JustBetter\Sentry\Plugin\MonologPlugin;
use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
Expand All @@ -20,29 +19,6 @@ class Sentry extends Action
*/
const ADMIN_RESOURCE = 'JustBetter_Sentry::sentry';

/**
* @var PageFactory
*/
protected $resultPageFactory;

/**
* @var LoggerInterface
*/
protected $logger;

/**
* @var Json
*/
private $jsonSerializer;
/**
* @var Data
*/
private $helperSentry;
/**
* @var \JustBetter\Sentry\Model\SentryLog|SentryLog
*/
private $monologPlugin;

/**
* Sentry constructor.
*
Expand All @@ -55,18 +31,12 @@ class Sentry extends Action
*/
public function __construct(
Context $context,
PageFactory $resultPageFactory,
Json $jsonSerializer,
LoggerInterface $logger,
Data $helperSentry,
MonologPlugin $monologPlugin
protected PageFactory $resultPageFactory,
private Json $jsonSerializer,
protected LoggerInterface $logger,
private Data $helperSentry,
private MonologPlugin $monologPlugin
) {
$this->resultPageFactory = $resultPageFactory;
$this->jsonSerializer = $jsonSerializer;
$this->logger = $logger;
$this->helperSentry = $helperSentry;
$this->monologPlugin = $monologPlugin;

parent::__construct($context);
}

Expand Down
39 changes: 5 additions & 34 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,11 @@ class Data extends AbstractHelper
const XML_PATH_SRS = 'sentry/general/';
const XML_PATH_SRS_ISSUE_GROUPING = 'sentry/issue_grouping/';

/**
* @var StoreManagerInterface
*/
protected $storeManager;

/**
* @var State
*/
protected $appState;

/**
* @var ScopeConfigInterface
*/
protected $scopeConfig;

/**
* @var ProductMetaDataInterface
*/
protected $productMetadataInterface;

/**
* @var DeploymentConfig
*/
protected $deploymentConfig;

/**
* @var array
*/
Expand All @@ -70,10 +50,6 @@ class Data extends AbstractHelper
'tracing_sample_rate',
'ignore_js_errors',
];
/**
* @var Json
*/
private $serializer;

/**
* Data constructor.
Expand All @@ -87,18 +63,13 @@ class Data extends AbstractHelper
*/
public function __construct(
Context $context,
StoreManagerInterface $storeManager,
State $appState,
Json $serializer,
ProductMetadataInterface $productMetadataInterface,
DeploymentConfig $deploymentConfig
protected StoreManagerInterface $storeManager,
protected State $appState,
private Json $serializer,
protected ProductMetadataInterface $productMetadataInterface,
protected DeploymentConfig $deploymentConfig
) {
$this->storeManager = $storeManager;
$this->appState = $appState;
$this->scopeConfig = $context->getScopeConfig();
$this->productMetadataInterface = $productMetadataInterface;
$this->deploymentConfig = $deploymentConfig;
$this->serializer = $serializer;
$this->collectModuleConfig();

parent::__construct($context);
Expand Down
16 changes: 2 additions & 14 deletions Helper/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,6 @@
*/
class Version extends AbstractHelper
{
/**
* @var \Magento\Framework\App\State
*/
private $appState;

/**
* @var \Magento\Framework\App\View\Deployment\Version\StorageInterface
*/
private $versionStorage;

/**
* @var string
*/
Expand All @@ -44,12 +34,10 @@ class Version extends AbstractHelper
* @param DeploymentConfig|null $deploymentConfig
*/
public function __construct(
\Magento\Framework\App\State $appState,
\Magento\Framework\App\View\Deployment\Version\StorageInterface $versionStorage,
private \Magento\Framework\App\State $appState,
private \Magento\Framework\App\View\Deployment\Version\StorageInterface $versionStorage,
DeploymentConfig $deploymentConfig = null
) {
$this->appState = $appState;
$this->versionStorage = $versionStorage;
$this->deploymentConfig = $deploymentConfig ?: ObjectManager::getInstance()->get(DeploymentConfig::class);
}

Expand Down
8 changes: 1 addition & 7 deletions Model/ReleaseIdentifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,14 @@

class ReleaseIdentifier
{
/**
* @var Version
*/
private $version;

/**
* ReleaseIdentifier constructor.
*
* @param Version $version
*/
public function __construct(
Version $version
private Version $version
) {
$this->version = $version;
}

/**
Expand Down
23 changes: 3 additions & 20 deletions Model/SentryLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,11 @@

class SentryLog extends Monolog
{
/**
* @var Data
*/
protected $data;

/**
* @var Session
*/
protected $customerSession;

/**
* @var array
*/
protected $config = [];

/** @var State */
private $appState;

/**
* SentryLog constructor.
*
Expand All @@ -42,16 +29,12 @@ class SentryLog extends Monolog
*/
public function __construct(
$name,
Data $data,
Session $customerSession,
State $appState,
protected Data $data,
protected Session $customerSession,
private State $appState,
array $handlers = [],
array $processors = []
) {
$this->data = $data;
$this->customerSession = $customerSession;
$this->appState = $appState;

parent::__construct($name, $handlers, $processors);
}

Expand Down
30 changes: 5 additions & 25 deletions Plugin/GlobalExceptionCatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,6 @@

class GlobalExceptionCatcher
{
/** @var SenteryHelper */
protected $sentryHelper;

/** @var ReleaseIdentifier */
private $releaseIdentifier;

/** @var SentryInteraction */
private $sentryInteraction;

/** @var EventManagerInterface */
private $eventManager;

/** @var DataObjectFactory */
private $dataObjectFactory;

/**
* ExceptionCatcher constructor.
*
Expand All @@ -38,17 +23,12 @@ class GlobalExceptionCatcher
* @param DataObjectFactory $dataObjectFactory
*/
public function __construct(
SenteryHelper $sentryHelper,
ReleaseIdentifier $releaseIdentifier,
SentryInteraction $sentryInteraction,
EventManagerInterface $eventManager,
DataObjectFactory $dataObjectFactory
protected SenteryHelper $sentryHelper,
private ReleaseIdentifier $releaseIdentifier,
private SentryInteraction $sentryInteraction,
private EventManagerInterface $eventManager,
private DataObjectFactory $dataObjectFactory
) {
$this->sentryHelper = $sentryHelper;
$this->releaseIdentifier = $releaseIdentifier;
$this->sentryInteraction = $sentryInteraction;
$this->eventManager = $eventManager;
$this->dataObjectFactory = $dataObjectFactory;
}

public function aroundLaunch(AppInterface $subject, callable $proceed)
Expand Down
9 changes: 2 additions & 7 deletions Plugin/LogrocketCustomerInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,10 @@

class LogrocketCustomerInfo
{
protected $currentCustomer;
protected $customerSession;

public function __construct(
CurrentCustomer $currentCustomer,
Session $session
protected CurrentCustomer $currentCustomer,
protected Session $customerSession
) {
$this->currentCustomer = $currentCustomer;
$this->customerSession = $session;
}

public function afterGetSectionData(Customer $subject, $result)
Expand Down
25 changes: 3 additions & 22 deletions Plugin/MonologPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,17 @@

class MonologPlugin extends Monolog
{
/**
* @var Data
*/
protected $sentryHelper;

/**
* @var SentryLog
*/
protected $sentryLog;

/**
* @var DeploymentConfig
*/
protected $deploymentConfig;

/**
* {@inheritdoc}
*/
public function __construct(
$name,
Data $data,
SentryLog $sentryLog,
DeploymentConfig $deploymentConfig,
protected Data $sentryHelper,
protected SentryLog $sentryLog,
protected DeploymentConfig $deploymentConfig,
array $handlers = [],
array $processors = []
) {
$this->sentryHelper = $data;
$this->sentryLog = $sentryLog;
$this->deploymentConfig = $deploymentConfig;

parent::__construct($name, $handlers, $processors);
}

Expand Down
Loading

0 comments on commit a181023

Please sign in to comment.