apply static code analysis changes
This commit is contained in:
parent
fb124c1f1a
commit
2312af010a
@ -4,7 +4,10 @@ parameters:
|
||||
- ../../oxid-esales/oxideshop-ce/source/oxfunctions.php
|
||||
paths:
|
||||
- src
|
||||
excludePaths:
|
||||
- src/tests
|
||||
level: 9
|
||||
phpVersion: 70100
|
||||
ignoreErrors:
|
||||
- '#Psr\\Container\\ContainerExceptionInterface is not subtype of Throwable#'
|
||||
- '#Psr\\Container\\ContainerExceptionInterface is not subtype of Throwable#'
|
||||
- '#Cannot cast mixed to string.#'
|
@ -44,11 +44,14 @@ class AdminOrder extends AdminController
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->item = d3GetOxidDIC()->get('d3ox.linkmobility.'.Order::class);
|
||||
d3GetOxidDIC()->set(OrderRecipients::class.'.args.order', $this->item);
|
||||
$this->itemRecipients = d3GetOxidDIC()->get(OrderRecipients::class);
|
||||
|
||||
$this->item->load($this->getEditObjectId());
|
||||
/** @var Order $item */
|
||||
$item = d3GetOxidDIC()->get('d3ox.linkmobility.'.Order::class);
|
||||
$this->item = $item;
|
||||
d3GetOxidDIC()->set(OrderRecipients::class.'.args.order', $item);
|
||||
/** @var OrderRecipients $itemRecipients */
|
||||
$itemRecipients = d3GetOxidDIC()->get(OrderRecipients::class);
|
||||
$this->itemRecipients = $itemRecipients;
|
||||
$item->load($this->getEditObjectId());
|
||||
|
||||
$this->addTplParam('recipient', $this->getRecipientFromCurrentItem());
|
||||
|
||||
@ -81,6 +84,7 @@ class AdminOrder extends AdminController
|
||||
} catch (noRecipientFoundException $e) {
|
||||
/** @var Language $lang */
|
||||
$lang = d3GetOxidDIC()->get('d3ox.linkmobility.'.Language::class);
|
||||
/** @var string $message */
|
||||
$message = $lang->translateString($e->getMessage());
|
||||
/** @var UtilsView $utilsView */
|
||||
$utilsView = d3GetOxidDIC()->get('d3ox.linkmobility.'.UtilsView::class);
|
||||
@ -101,7 +105,7 @@ class AdminOrder extends AdminController
|
||||
try {
|
||||
$utilsView->addErrorToDisplay($this->sendMessage());
|
||||
} catch (noRecipientFoundException|InvalidArgumentException $e) {
|
||||
$utilsView->addErrorToDisplay($e);
|
||||
$utilsView->addErrorToDisplay($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,10 +46,14 @@ class AdminUser extends AdminController
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->item = d3GetOxidDIC()->get('d3ox.linkmobility.'.User::class);
|
||||
d3GetOxidDIC()->set(UserRecipients::class.".args.user", $this->item);
|
||||
$this->itemRecipients = d3GetOxidDIC()->get(UserRecipients::class);
|
||||
$this->item->load($this->getEditObjectId());
|
||||
/** @var User $item */
|
||||
$item = d3GetOxidDIC()->get('d3ox.linkmobility.'.User::class);
|
||||
$this->item = $item;
|
||||
d3GetOxidDIC()->set(UserRecipients::class.".args.user", $item);
|
||||
/** @var UserRecipients $itemRecipients */
|
||||
$itemRecipients = d3GetOxidDIC()->get(UserRecipients::class);
|
||||
$this->itemRecipients = $itemRecipients;
|
||||
$item->load($this->getEditObjectId());
|
||||
|
||||
$this->addTplParam('recipient', $this->getRecipientFromCurrentItem());
|
||||
|
||||
@ -82,6 +86,7 @@ class AdminUser extends AdminController
|
||||
} catch (noRecipientFoundException $e) {
|
||||
/** @var Language $lang */
|
||||
$lang = d3GetOxidDIC()->get('d3ox.linkmobility.'.Language::class);
|
||||
/** @var string $message */
|
||||
$message = $lang->translateString($e->getMessage());
|
||||
/** @var UtilsView $utilsView */
|
||||
$utilsView = d3GetOxidDIC()->get('d3ox.linkmobility.'.UtilsView::class);
|
||||
@ -102,7 +107,7 @@ class AdminUser extends AdminController
|
||||
try {
|
||||
$utilsView->addErrorToDisplay($this->sendMessage());
|
||||
} catch (noRecipientFoundException|InvalidArgumentException $e) {
|
||||
$utilsView->addErrorToDisplay($e);
|
||||
$utilsView->addErrorToDisplay($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -133,8 +133,8 @@ class Configuration
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $customFields
|
||||
* @return array
|
||||
* @param string[] $customFields
|
||||
* @return string[]
|
||||
*/
|
||||
public function sanitizeKeys(array $customFields): array
|
||||
{
|
||||
|
@ -29,8 +29,10 @@ class successfullySentException extends StandardException
|
||||
*/
|
||||
public function __construct($messageCount = 1, $code = 0, Exception $previous = null)
|
||||
{
|
||||
/** @var Language $language */
|
||||
$language = d3GetOxidDIC()->get('d3ox.linkmobility.'.Language::class);
|
||||
/** @var string $format */
|
||||
$format = d3GetOxidDIC()->get('d3ox.linkmobility.'.Language::class)->translateString('D3LM_EXC_SMS_SUCC_SENT');
|
||||
$format = $language->translateString('D3LM_EXC_SMS_SUCC_SENT');
|
||||
$message = sprintf($format, $messageCount);
|
||||
|
||||
parent::__construct($message, $code, $previous);
|
||||
|
@ -16,6 +16,7 @@ declare(strict_types=1);
|
||||
namespace D3\Linkmobility4OXID\Application\Model\MessageTypes;
|
||||
|
||||
use D3\LinkmobilityClient\RecipientsList\RecipientsList;
|
||||
use D3\LinkmobilityClient\RecipientsList\RecipientsListInterface;
|
||||
use D3\LinkmobilityClient\Response\ResponseInterface;
|
||||
use D3\LinkmobilityClient\ValueObject\Recipient;
|
||||
use Exception;
|
||||
@ -37,7 +38,7 @@ abstract class AbstractMessage
|
||||
/** @var ResponseInterface */
|
||||
protected $response;
|
||||
|
||||
/** @var RecipientsList */
|
||||
/** @var RecipientsListInterface */
|
||||
protected $recipients;
|
||||
|
||||
/**
|
||||
@ -66,6 +67,7 @@ abstract class AbstractMessage
|
||||
*/
|
||||
protected function setRemark(string $userId, string $recipients, string $message): void
|
||||
{
|
||||
/** @var Remark $remark */
|
||||
$remark = d3GetOxidDIC()->get('d3ox.linkmobility.'.Remark::class);
|
||||
$remark->assign([
|
||||
'oxtype' => self::REMARK_IDENT,
|
||||
@ -84,10 +86,10 @@ abstract class AbstractMessage
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RecipientsList $recipients
|
||||
* @param RecipientsListInterface $recipients
|
||||
* @return void
|
||||
*/
|
||||
protected function setRecipients(RecipientsList $recipients)
|
||||
protected function setRecipients(RecipientsListInterface $recipients)
|
||||
{
|
||||
$this->recipients = $recipients;
|
||||
}
|
||||
|
@ -60,7 +60,9 @@ class Sms extends AbstractMessage
|
||||
return $return;
|
||||
} catch (noRecipientFoundException $e) {
|
||||
$this->getLogger()->warning($e->getMessage());
|
||||
d3GetOxidDIC()->get('d3ox.linkmobility.'.UtilsView::class)->addErrorToDisplay($e);
|
||||
/** @var UtilsView $utilsView */
|
||||
$utilsView = d3GetOxidDIC()->get('d3ox.linkmobility.'.UtilsView::class);
|
||||
$utilsView->addErrorToDisplay($e);
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -107,7 +109,9 @@ class Sms extends AbstractMessage
|
||||
return $return;
|
||||
} catch (noRecipientFoundException $e) {
|
||||
$this->getLogger()->warning($e->getMessage());
|
||||
d3GetOxidDIC()->get('d3ox.linkmobility.'.UtilsView::class)->addErrorToDisplay($e);
|
||||
/** @var UtilsView $utilsView */
|
||||
$utilsView = d3GetOxidDIC()->get('d3ox.linkmobility.'.UtilsView::class);
|
||||
$utilsView->addErrorToDisplay($e);
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -146,11 +150,11 @@ class Sms extends AbstractMessage
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RecipientsList $recipientsList
|
||||
* @param RecipientsListInterface $recipientsList
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function sendCustomRecipientMessage(RecipientsList $recipientsList): bool
|
||||
public function sendCustomRecipientMessage(RecipientsListInterface $recipientsList): bool
|
||||
{
|
||||
try {
|
||||
$this->response = $response = $this->submitMessage($recipientsList);
|
||||
@ -159,7 +163,9 @@ class Sms extends AbstractMessage
|
||||
} catch (abortSendingExceptionInterface|GuzzleException|ApiException|InvalidArgumentException $e) {
|
||||
$this->getLogger()->warning($e->getMessage());
|
||||
// Oxid does not accept throwable interface only exceptions according to definition
|
||||
d3GetOxidDIC()->get('d3ox.linkmobility.'.UtilsView::class)->addErrorToDisplay($e->getMessage());
|
||||
/** @var UtilsView $utilsView */
|
||||
$utilsView = d3GetOxidDIC()->get('d3ox.linkmobility.'.UtilsView::class);
|
||||
$utilsView->addErrorToDisplay($e->getMessage());
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -192,12 +198,12 @@ class Sms extends AbstractMessage
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RecipientsList $recipientsList
|
||||
* @param RecipientsListInterface $recipientsList
|
||||
* @return ResponseInterface
|
||||
* @throws ApiException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
protected function submitMessage(RecipientsList $recipientsList): ResponseInterface
|
||||
protected function submitMessage(RecipientsListInterface $recipientsList): ResponseInterface
|
||||
{
|
||||
$this->setRecipients($recipientsList);
|
||||
/** @var Configuration $configuration */
|
||||
|
@ -53,19 +53,20 @@ class OrderRecipients
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $phoneFieldName
|
||||
* @param $countryIdFieldName
|
||||
* @param string $phoneFieldName
|
||||
* @param string $countryIdFieldName
|
||||
* @return Recipient|null
|
||||
*/
|
||||
protected function getSmsRecipientByField($phoneFieldName, $countryIdFieldName): ?Recipient
|
||||
protected function getSmsRecipientByField(string $phoneFieldName, string $countryIdFieldName): ?Recipient
|
||||
{
|
||||
/** @var Country $country */
|
||||
$country = d3GetOxidDIC()->get('d3ox.linkmobility.'.Country::class);
|
||||
try {
|
||||
/** @var string $content */
|
||||
$content = $this->order->getFieldData($phoneFieldName) ?: '';
|
||||
$content = trim($content);
|
||||
|
||||
if (strlen($content)) {
|
||||
$country = d3GetOxidDIC()->get('d3ox.linkmobility.'.Country::class);
|
||||
/** @var string $countryId */
|
||||
$countryId = $this->order->getFieldData(trim($countryIdFieldName));
|
||||
$country->load($countryId);
|
||||
@ -77,7 +78,9 @@ class OrderRecipients
|
||||
return $recipient;
|
||||
}
|
||||
} catch (NumberParseException|RecipientException $e) {
|
||||
d3GetOxidDIC()->get(LoggerHandler::class)->getLogger()->info(
|
||||
/** @var LoggerHandler $loggerHandler */
|
||||
$loggerHandler = d3GetOxidDIC()->get(LoggerHandler::class);
|
||||
$loggerHandler->getLogger()->info(
|
||||
$e->getMessage(),
|
||||
[$content, $country->getFieldData('oxisoalpha2')]
|
||||
);
|
||||
|
@ -30,14 +30,15 @@ class RequestFactory extends \D3\LinkmobilityClient\SMS\RequestFactory
|
||||
$configuration = d3GetOxidDIC()->get(Configuration::class);
|
||||
|
||||
/** parent call */
|
||||
/** @var SmsRequestInterface $request */
|
||||
$request = $this->d3CallMockableFunction([\D3\LinkmobilityClient\SMS\RequestFactory::class, 'getSmsRequest']);
|
||||
|
||||
d3GetOxidDIC()->setParameter(Sender::class.'.args.number', $configuration->getSmsSenderNumber());
|
||||
d3GetOxidDIC()->setParameter(Sender::class.'.args.iso2countrycode', $configuration->getSmsSenderCountry());
|
||||
/** @var Sender $sender */
|
||||
$sender = d3GetOxidDIC()->get(Sender::class);
|
||||
$request->setTestMode($configuration->getTestMode())
|
||||
->setSenderAddress(
|
||||
d3GetOxidDIC()->get(Sender::class)
|
||||
)
|
||||
->setSenderAddress($sender)
|
||||
->setSenderAddressType(RequestInterface::SENDERADDRESSTYPE_INTERNATIONAL);
|
||||
|
||||
return $request;
|
||||
|
@ -53,18 +53,20 @@ class UserRecipients
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $fieldName
|
||||
* @param string $fieldName
|
||||
* @return Recipient|null
|
||||
*/
|
||||
protected function getSmsRecipientByField($fieldName): ?Recipient
|
||||
protected function getSmsRecipientByField(string $fieldName): ?Recipient
|
||||
{
|
||||
/** @var Country $country */
|
||||
$country = d3GetOxidDIC()->get('d3ox.linkmobility.'.Country::class);
|
||||
|
||||
try {
|
||||
/** @var string $content */
|
||||
$content = $this->user->getFieldData($fieldName) ?: '';
|
||||
$content = trim($content);
|
||||
|
||||
if (strlen($content)) {
|
||||
$country = d3GetOxidDIC()->get('d3ox.linkmobility.'.Country::class);
|
||||
/** @var string $countryId */
|
||||
$countryId = $this->user->getFieldData('oxcountryid');
|
||||
$country->load($countryId);
|
||||
@ -75,7 +77,9 @@ class UserRecipients
|
||||
return $recipient;
|
||||
}
|
||||
} catch (NumberParseException|RecipientException $e) {
|
||||
d3GetOxidDIC()->get(LoggerHandler::class)->getLogger()->info(
|
||||
/** @var LoggerHandler $loggerHandler */
|
||||
$loggerHandler = d3GetOxidDIC()->get(LoggerHandler::class);
|
||||
$loggerHandler->getLogger()->info(
|
||||
$e->getMessage(),
|
||||
[$content, $country->getFieldData('oxisoalpha2')]
|
||||
);
|
||||
|
@ -47,6 +47,7 @@ class EmailCore extends EmailCore_parent
|
||||
public function sendOrderEmailToUser($order, $subject = null)
|
||||
{
|
||||
// $ret = parent::sendOrderEmailToUser($order, $subject);
|
||||
/** @var bool $ret */
|
||||
$ret = $this->d3CallMockableFunction([EmailCore_parent::class, 'sendOrderEmailToUser'], [$order, $subject]);
|
||||
|
||||
$this->d3SendOrderFinishedMessageToUser($order);
|
||||
@ -65,6 +66,7 @@ class EmailCore extends EmailCore_parent
|
||||
public function sendSendedNowMail($order, $subject = null)
|
||||
{
|
||||
// $ret = parent::sendSendedNowMail($order, $subject);
|
||||
/** @var bool $ret */
|
||||
$ret = $this->d3CallMockableFunction([EmailCore_parent::class, 'sendSendedNowMail'], [$order, $subject]);
|
||||
|
||||
$this->d3SendedNowMessage($order);
|
||||
@ -82,6 +84,7 @@ class EmailCore extends EmailCore_parent
|
||||
*/
|
||||
public function d3SendOrderFinishedMessageToUser(Order $order): void
|
||||
{
|
||||
/** @var MessageSender $messageSender */
|
||||
$messageSender = d3GetOxidDIC()->get(MessageSender::class);
|
||||
$messageSender->sendOrderFinishedMessage($order, $this->d3GetOrderFinishedSmsMessageBody($order));
|
||||
}
|
||||
@ -111,6 +114,7 @@ class EmailCore extends EmailCore_parent
|
||||
*/
|
||||
public function d3SendedNowMessage(Order $order): void
|
||||
{
|
||||
/** @var MessageSender $messageSender */
|
||||
$messageSender = d3GetOxidDIC()->get(MessageSender::class);
|
||||
$messageSender->sendSendedNowMessage($order, $this->d3GetSendedNowSmsMessageBody($order));
|
||||
}
|
||||
@ -140,6 +144,7 @@ class EmailCore extends EmailCore_parent
|
||||
*/
|
||||
public function d3SendCancelMessage(Order $order): void
|
||||
{
|
||||
/** @var MessageSender $messageSender */
|
||||
$messageSender = d3GetOxidDIC()->get(MessageSender::class);
|
||||
$messageSender->sendCancelOrderMessage($order, $this->d3GetCancelOrderSmsMessageBody($order));
|
||||
}
|
||||
|
@ -17,8 +17,10 @@ namespace D3\Linkmobility4OXID\Setup;
|
||||
|
||||
use D3\Linkmobility4OXID\Application\Model\MessageTypes\AbstractMessage;
|
||||
use Doctrine\DBAL\Driver\Exception as DoctrineDriverException;
|
||||
use Doctrine\DBAL\Driver\ResultStatement;
|
||||
use Doctrine\DBAL\Exception as DoctrineException;
|
||||
use Doctrine\DBAL\Query\QueryBuilder;
|
||||
use Doctrine\DBAL\Statement;
|
||||
use Monolog\Logger;
|
||||
use OxidEsales\Eshop\Core\Database\Adapter\DatabaseInterface;
|
||||
use OxidEsales\Eshop\Core\Database\Adapter\Doctrine\Database;
|
||||
@ -30,6 +32,7 @@ use OxidEsales\Eshop\Core\Exception\StandardException;
|
||||
use OxidEsales\Eshop\Core\Registry;
|
||||
use OxidEsales\Eshop\Core\UtilsView;
|
||||
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Database\QueryBuilderFactory;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Database\QueryBuilderFactoryInterface;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\ContainerInterface;
|
||||
@ -55,7 +58,7 @@ class Actions
|
||||
$logger->error($e->getMessage());
|
||||
/** @var UtilsView $utilsView */
|
||||
$utilsView = d3GetOxidDIC()->get('d3ox.linkmobility.'.UtilsView::class);
|
||||
$utilsView->addErrorToDisplay($e);
|
||||
$utilsView->addErrorToDisplay($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,7 +67,7 @@ class Actions
|
||||
/**
|
||||
* Regenerate views for changed tables
|
||||
*/
|
||||
public function regenerateViews()
|
||||
public function regenerateViews(): void
|
||||
{
|
||||
/** @var DbMetaDataHandler $oDbMetaDataHandler */
|
||||
$oDbMetaDataHandler = d3GetOxidDIC()->get('d3ox.linkmobility.'.DbMetaDataHandler::class);
|
||||
@ -101,8 +104,10 @@ class Actions
|
||||
*/
|
||||
protected function getRemarkTypeFieldType(): string
|
||||
{
|
||||
/** @var QueryBuilderFactory $queryBuilderFactory */
|
||||
$queryBuilderFactory = $this->getContainer()->get(QueryBuilderFactoryInterface::class);
|
||||
/** @var QueryBuilder $qb */
|
||||
$qb = $this->getContainer()->get(QueryBuilderFactoryInterface::class)->create();
|
||||
$qb = $queryBuilderFactory->create();
|
||||
$qb->select('column_type')
|
||||
->from('INFORMATION_SCHEMA.COLUMNS')
|
||||
->where(
|
||||
@ -122,7 +127,10 @@ class Actions
|
||||
)
|
||||
);
|
||||
|
||||
return (string) $qb->execute()->fetchOne();
|
||||
/** @var Statement $statement */
|
||||
$statement = $qb->execute();
|
||||
|
||||
return (string) $statement->fetchOne();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -150,7 +158,7 @@ class Actions
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @return string[]
|
||||
* @throws DoctrineDriverException
|
||||
* @throws DoctrineException
|
||||
*/
|
||||
|
@ -33,7 +33,7 @@ class Events
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public static function onActivate()
|
||||
public static function onActivate(): void
|
||||
{
|
||||
/** @var Actions $actions */
|
||||
$actions = d3GetOxidDIC()->get(Actions::class);
|
||||
@ -41,7 +41,7 @@ class Events
|
||||
$actions->regenerateViews();
|
||||
}
|
||||
|
||||
public static function onDeactivate()
|
||||
public static function onDeactivate(): void
|
||||
{
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user