apply static code analysis fixes

This commit is contained in:
Daniel Seifert 2022-08-07 22:52:00 +02:00
parent 817f9e68a2
commit 8590fac16d
Signed by: DanielS
GPG Key ID: 6A513E13AEE66170
4 changed files with 46 additions and 31 deletions

View File

@ -38,7 +38,8 @@
}, },
"require-dev": { "require-dev": {
"php": "^7.4", "php": "^7.4",
"friendsofphp/php-cs-fixer": "^3.9" "friendsofphp/php-cs-fixer": "^3.9",
"phpstan/phpstan": "^1.8"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {

14
phpstan.neon Normal file
View File

@ -0,0 +1,14 @@
parameters:
scanFiles:
- src/IntelliSenseHelper.php
- ../../oxid-esales/oxideshop-ce/source/oxfunctions.php
- ../../oxid-esales/oxideshop-ce/source/overridablefunctions.php
- ../../d3/ordermanager/src/IntelliSenseHelper.php
paths:
- src
level: 6
phpVersion: 70300
checkMissingIterableValueType: false
ignoreErrors:
- '#d3linkmobility_ordermanager_action::startAction\(\) has no return type specified#'
- '#d3linkmobility_ordermanager_action::\$sTplName has no type specified#'

View File

@ -39,7 +39,7 @@ class d3linkmobility_ordermanager_action extends d3ordermanager_action_abstract
{ {
public $sTplName = 'd3linkmobility_ordermanager_action.tpl'; public $sTplName = 'd3linkmobility_ordermanager_action.tpl';
public const ACTIVE_SWITCH = 'blActionLinkmobility_status'; public const ACTIVE_SWITCH = 'blActionLinkmobility_status';
public $sTitleIdent = 'D3_LINKMOBILITY_ORDERMANAGER_ACTION'; public string $sTitleIdent = 'D3_LINKMOBILITY_ORDERMANAGER_ACTION';
public const SOURCE_TEMPLATE = 'template'; public const SOURCE_TEMPLATE = 'template';
public const SOURCE_CMS = 'cms'; public const SOURCE_CMS = 'cms';
@ -98,12 +98,9 @@ class d3linkmobility_ordermanager_action extends d3ordermanager_action_abstract
/** @var Language $oLang */ /** @var Language $oLang */
$oLang = oxNew(Language::class); $oLang = oxNew(Language::class);
$this->getManager()->getRemarkHandler()->addNote( /** @var string $format */
sprintf( $format = $oLang->translateString('D3_ORDERMANAGER_JOBDESC_SENDLMMESSAGE', null, true);
$oLang->translateString('D3_ORDERMANAGER_JOBDESC_SENDLMMESSAGE', null, true), $this->getManager()->getRemarkHandler()->addNote(sprintf($format, $this->getRecipientDescription()));
$this->getRecipientDescription()
)
);
$this->startExecution(); $this->startExecution();
@ -238,8 +235,9 @@ class d3linkmobility_ordermanager_action extends d3ordermanager_action_abstract
* @throws StandardException * @throws StandardException
* @throws d3ShopCompatibilityAdapterException * @throws d3ShopCompatibilityAdapterException
* @throws d3_cfg_mod_exception * @throws d3_cfg_mod_exception
* @return void
*/ */
public function startExecution() public function startExecution(): void
{ {
try { try {
if ($this->canExecuteMethod() && $this->hasRequiredValues()) { if ($this->canExecuteMethod() && $this->hasRequiredValues()) {
@ -247,18 +245,18 @@ class d3linkmobility_ordermanager_action extends d3ordermanager_action_abstract
} }
} catch (emptyMesageException $e) { } catch (emptyMesageException $e) {
Registry::getLogger()->error($e->getMessage()); Registry::getLogger()->error($e->getMessage());
$this->getManager()->getRemarkHandler()->addNote( /** @var string $note */
Registry::getLang()->translateString('D3_ORDERMANAGER_JOBDESC_SENDLMMESSAGE_EMPTYMESSAGE', null, true) $note = Registry::getLang()->translateString('D3_ORDERMANAGER_JOBDESC_SENDLMMESSAGE_EMPTYMESSAGE', null, true);
); $this->getManager()->getRemarkHandler()->addNote($note);
} catch (noRecipientFoundException $e) { } catch (noRecipientFoundException $e) {
Registry::getLogger()->info( Registry::getLogger()->info(
$this->getManager()->getFieldData('oxtitle')." => ". $this->getManager()->getFieldData('oxtitle')." => ".
$this->getItem()->getFieldData('oxordernr').": ". $this->getItem()->getFieldData('oxordernr').": ".
$e->getMessage() $e->getMessage()
); );
$this->getManager()->getRemarkHandler()->addNote( /** @var string $note */
Registry::getLang()->translateString('D3_ORDERMANAGER_JOBDESC_SENDLMMESSAGE_NORECIPIENT', null, true) $note = Registry::getLang()->translateString('D3_ORDERMANAGER_JOBDESC_SENDLMMESSAGE_NORECIPIENT', null, true);
); $this->getManager()->getRemarkHandler()->addNote($note);
} }
} }

View File

@ -93,7 +93,7 @@ class d3linkmobility_ordermanager_sender
->getTemplateRenderer(); ->getTemplateRenderer();
$templateEngine = $renderer->getTemplateEngine(); $templateEngine = $renderer->getTemplateEngine();
/** @var $oBasket Basket */ /** @var Basket $oBasket */
$oBasket = $oManager->getCurrentItem()->d3getOrderBasket4OrderManager($oManager); $oBasket = $oManager->getCurrentItem()->d3getOrderBasket4OrderManager($oManager);
$oPayment = oxNew(Payment::class); $oPayment = oxNew(Payment::class);
@ -146,13 +146,19 @@ class d3linkmobility_ordermanager_sender
{ {
$iOrderLangId = $this->getManager()->getCurrentItem()->getFieldData('oxlang'); $iOrderLangId = $this->getManager()->getCurrentItem()->getFieldData('oxlang');
$oLang = Registry::getLang(); $oLang = Registry::getLang();
/** @var int $iCurrentTplLang */
$iCurrentTplLang = $oLang->getTplLanguage(); $iCurrentTplLang = $oLang->getTplLanguage();
/** @var int $iCurrentBaseLang */
$iCurrentBaseLang = $oLang->getBaseLanguage(); $iCurrentBaseLang = $oLang->getBaseLanguage();
$oLang->setTplLanguage($iOrderLangId); $oLang->setTplLanguage($iOrderLangId);
$oLang->setBaseLanguage($iOrderLangId); $oLang->setBaseLanguage($iOrderLangId);
$content = '';
/** @var int $iCurrentCurrency */
$iCurrentCurrency = Registry::getConfig()->getShopCurrency(); $iCurrentCurrency = Registry::getConfig()->getShopCurrency();
$iOrderCurr = $this->getManager()->getCurrentItem()->getOrderCurrency()->id; /** @var \stdClass $oOrderCurr */
$oOrderCurr = $this->getManager()->getCurrentItem()->getOrderCurrency();
$iOrderCurr = $oOrderCurr->id;
Registry::getConfig()->setActShopCurrency($iOrderCurr); Registry::getConfig()->setActShopCurrency($iOrderCurr);
set_error_handler( set_error_handler(
@ -173,7 +179,7 @@ class d3linkmobility_ordermanager_sender
$content = $templateEngine->render($this->getManager()->getValue('sLinkMobilityMessageFromTemplatename')); $content = $templateEngine->render($this->getManager()->getValue('sLinkMobilityMessageFromTemplatename'));
} }
if (false === is_string($content) || false === (bool) strlen($content)) { if (false === (bool) strlen($content)) {
throw oxNew(emptyMesageException::class, 'message content is empty', $this->getManager()->getFieldData('oxtitle')); throw oxNew(emptyMesageException::class, 'message content is empty', $this->getManager()->getFieldData('oxtitle'));
} }
@ -220,9 +226,9 @@ class d3linkmobility_ordermanager_sender
try { try {
$recipients[] = (oxNew(OrderRecipients::class, $this->getItem()))->getSmsRecipient(); $recipients[] = (oxNew(OrderRecipients::class, $this->getItem()))->getSmsRecipient();
} catch (noRecipientFoundException $e) { } catch (noRecipientFoundException $e) {
$this->getManager()->getRemarkHandler()->addNote( /** @var string $note */
Registry::getLang()->translateString('D3_ORDERMANAGER_JOBDESC_SENDLMMESSAGE_NORECIPIENT', null, true) $note = Registry::getLang()->translateString('D3_ORDERMANAGER_JOBDESC_SENDLMMESSAGE_NORECIPIENT', null, true);
); $this->getManager()->getRemarkHandler()->addNote($note);
} }
} }
if ((bool) $this->getManager()->getValue('blLinkMobilityMessageToCustom') && if ((bool) $this->getManager()->getValue('blLinkMobilityMessageToCustom') &&
@ -233,17 +239,13 @@ class d3linkmobility_ordermanager_sender
$recipients[] = oxNew(Recipient::class, $phoneNumber, $countryId); $recipients[] = oxNew(Recipient::class, $phoneNumber, $countryId);
} catch (RecipientException $e) { } catch (RecipientException $e) {
Registry::getLogger()->info($e->getMessage(), [$phoneNumber, $countryId]); Registry::getLogger()->info($e->getMessage(), [$phoneNumber, $countryId]);
$this->getManager()->getRemarkHandler()->addNote( /** @var string $format */
sprintf( $format = Registry::getLang()->translateString(
Registry::getLang()->translateString( 'D3_ORDERMANAGER_JOBDESC_SENDLMMESSAGE_RECIPIENTERROR',
'D3_ORDERMANAGER_JOBDESC_SENDLMMESSAGE_RECIPIENTERROR', null,
null, true
true
),
$phoneNumber,
$countryId
)
); );
$this->getManager()->getRemarkHandler()->addNote(sprintf($format, $phoneNumber, $countryId));
} }
} }
} }