Skip to content

Commit

Permalink
fix: phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
fox-john committed Jan 15, 2025
1 parent 81e67e2 commit a31824b
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/Handler/ErrorHandler/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@

namespace PrestaShop\Module\PsEventbus\Handler\ErrorHandler;

use Module;
use PrestaShop\Module\PsEventbus\Service\CommonService;
use PrestaShop\Module\PsEventbus\Service\PsAccountsAdapterService;

if (!defined('_PS_VERSION_')) {
exit;
Expand All @@ -53,27 +51,32 @@ class ErrorHandler
public function __construct($sentryDsn, $sentryEnv)
{
try {
/** @var Module $module */
/** @var \ModuleCore $accountsModule */
$accountsModule = \Module::getInstanceByName('ps_accounts');
/** @var mixed $accountService */
$accountService = $accountsModule->get('PrestaShop\Module\PsAccounts\Service\PsAccountsService');

/** @var \ModuleCore $eventbusModule */
$eventbusModule = \Module::getInstanceByName('ps_eventbus');
} catch (\Exception $e) {
$accountsModule = null;
$accountService = null;
$eventbusModule = null;
}

try {
$this->client = new \Raven_Client(
$sentryDsn,
[
'level' => 'warning',
'tags' => [
'shop_id' => $accountService ? $accountService->getShopUuid() : false,
'ps_eventbus_version' => \Module::getInstanceByName('ps_eventbus')->version,
'ps_eventbus_version' => $eventbusModule ? $eventbusModule->version : false,
'ps_accounts_version' => $accountsModule ? $accountsModule->version : false,
'php_version' => phpversion(),
'prestashop_version' => _PS_VERSION_,
'ps_eventbus_is_enabled' => \Module::isEnabled((string) $module->name),
'ps_eventbus_is_installed' => \Module::isInstalled((string) $module->name),
'ps_eventbus_is_enabled' => $eventbusModule ? \Module::isEnabled((string) $eventbusModule->name) : false,
'ps_eventbus_is_installed' => $eventbusModule ? \Module::isInstalled((string) $eventbusModule->name) : false,
'env' => $sentryEnv,
],
]
Expand All @@ -94,7 +97,7 @@ public function __construct($sentryDsn, $sentryEnv)
* @@throws Exception
*/
public function handle($exception, $silent = null)
{
{
$logsEnabled = false;
$verboseEnabled = false;

Expand Down Expand Up @@ -130,7 +133,7 @@ public function handle($exception, $silent = null)
if ($silent) {
return;
}

CommonService::exitWithExceptionMessage($exception);
}
}
Expand Down

0 comments on commit a31824b

Please sign in to comment.