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

#175 Fix phpstan errors level 4 #266

Merged
merged 1 commit into from
Jan 15, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions Block/Cart/ApplePay.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
namespace Swarming\SubscribePro\Block\Cart;

use Magento\Checkout\Model\Session;
use Magento\Directory\Helper\Data as DirectoryHelper;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Serialize\Serializer\Json as JsonSerializer;
Expand All @@ -21,10 +20,6 @@ class ApplePay extends Template
* @var Quote
*/
private $quote;
/**
* @var DirectoryHelper
*/
private $directoryHelper;
/**
* @var PaymentRequestConfig
*/
Expand Down Expand Up @@ -58,7 +53,6 @@ class ApplePay extends Template
*
* @param Context $context
* @param Quote $quote
* @param DirectoryHelper $directoryHelper
* @param PaymentRequestConfig $paymentRequestConfig
* @param ApplePayConfigProvider $applePayConfigProvider
* @param JsonSerializer $jsonJsonSerializer
Expand All @@ -70,7 +64,6 @@ class ApplePay extends Template
public function __construct(
Context $context,
Quote $quote,
DirectoryHelper $directoryHelper,
PaymentRequestConfig $paymentRequestConfig,
ApplePayConfigProvider $applePayConfigProvider,
JsonSerializer $jsonJsonSerializer,
Expand All @@ -81,7 +74,6 @@ public function __construct(
) {
parent::__construct($context, $data);
$this->quote = $quote;
$this->directoryHelper = $directoryHelper;
$this->paymentRequestConfig = $paymentRequestConfig;
$this->applePayConfigProvider = $applePayConfigProvider;
$this->jsonJsonSerializer = $jsonJsonSerializer;
Expand Down
5 changes: 3 additions & 2 deletions Block/Customer/SubscriptionsDirectoryDataProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function process($jsLayout)
*/
protected function getCountryOptions()
{
if (!isset($this->countryOptions)) {
if (!$this->countryOptions) {
$this->countryOptions = $this->countryCollectionFactory->create()->loadByStore(
$this->storeManager->getStore()->getId()
)->toOptionArray();
Expand All @@ -107,10 +107,11 @@ protected function getCountryOptions()
* Get region options list.
*
* @return array
* @throws NoSuchEntityException
*/
protected function getRegionOptions()
{
if (!isset($this->regionOptions)) {
if (!$this->regionOptions) {
$this->regionOptions = $this->regionCollectionFactory->create()->addAllowedCountriesFilter(
$this->storeManager->getStore()->getId()
)->toOptionArray();
Expand Down
4 changes: 2 additions & 2 deletions Block/Vault/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ protected function loadToken($publicHash)
protected function loadProfile()
{
$profile = $this->platformPaymentProfileService->loadProfile($this->token->getGatewayToken());
if (!$profile) {
if (!$profile->getId()) {
throw new LocalizedException(__('The saved credit is not found.'));
}
$this->profile = $profile;
Expand All @@ -148,7 +148,7 @@ protected function initPageTitle()
{
/** @var \Magento\Theme\Block\Html\Title $pageMainTitle */
$pageMainTitle = $this->getLayout()->getBlock('page.main.title');
if ($pageMainTitle) {
if ($pageMainTitle !== null) {
$message = $this->token ? __('Edit Card: ending %1', $this->getNumberLast4Digits()) : __('Add New Card');
$pageMainTitle->setPageTitle($message);
}
Expand Down
4 changes: 1 addition & 3 deletions Gateway/Command/ApplePay/AuthorizeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ protected function processTransaction(array $requestData)
}

$transaction = $this->platformTransactionService->createTransaction($requestData);
if (!empty($requestData[VaultConfigProvider::IS_ACTIVE_CODE])
&& $requestData[VaultConfigProvider::IS_ACTIVE_CODE]
) {
if (!empty($requestData[VaultConfigProvider::IS_ACTIVE_CODE])) {
$profileId = $requestData[PaymentDataBuilder::PLATFORM_PROFILE_ID];
$this->platformTransactionService->authorizeByProfile([
VaultDataBuilder::PAYMENT_PROFILE_ID => $profileId
Expand Down
4 changes: 1 addition & 3 deletions Gateway/Command/ApplePay/PurchaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ protected function processTransaction(array $requestData)
throw new \InvalidArgumentException(__('Payment token is not passed'));
}
$transaction = $this->platformTransactionService->createTransaction($requestData);
if (!empty($requestData[VaultConfigProvider::IS_ACTIVE_CODE])
&& $requestData[VaultConfigProvider::IS_ACTIVE_CODE]
) {
if (!empty($requestData[VaultConfigProvider::IS_ACTIVE_CODE])) {
$this->platformTransactionService->purchaseByProfile([
VaultDataBuilder::PAYMENT_PROFILE_ID => $requestData[ApplePayPaymentDataBuilder::PLATFORM_PROFILE_ID]
], $transaction);
Expand Down
3 changes: 1 addition & 2 deletions Gateway/Command/AuthorizeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ protected function processTransaction(array $requestData)
}

$transaction = $this->platformTransactionService->createTransaction($requestData);
if (!empty($requestData[VaultConfigProvider::IS_ACTIVE_CODE])
&& $requestData[VaultConfigProvider::IS_ACTIVE_CODE]) {
if (!empty($requestData[VaultConfigProvider::IS_ACTIVE_CODE])) {
$profile = $this->createProfile($requestData);
$this->platformTransactionService->authorizeByProfile([
VaultDataBuilder::PAYMENT_PROFILE_ID => $profile->getId()
Expand Down
3 changes: 1 addition & 2 deletions Gateway/Command/PurchaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ protected function processTransaction(array $requestData)
}

$transaction = $this->platformTransactionService->createTransaction($requestData);
if (!empty($requestData[VaultConfigProvider::IS_ACTIVE_CODE])
&& $requestData[VaultConfigProvider::IS_ACTIVE_CODE]) {
if (!empty($requestData[VaultConfigProvider::IS_ACTIVE_CODE])) {
$profile = $this->createProfile($requestData);
$this->platformTransactionService->purchaseByProfile([
VaultDataBuilder::PAYMENT_PROFILE_ID => $profile->getId()
Expand Down
56 changes: 4 additions & 52 deletions Model/ApplePay/OrderService.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,11 @@
namespace Swarming\SubscribePro\Model\ApplePay;

use Magento\Checkout\Helper\Data as CheckoutHelperData;
use Magento\Checkout\Model\Session as CheckoutSession;
use Magento\Framework\Exception\LocalizedException;
use Magento\Payment\Model\Method\Logger as PaymentLogger;
use Magento\Quote\Api\CartRepositoryInterface;
use Magento\Quote\Model\BillingAddressManagement;
use Magento\Quote\Model\Quote;
use Magento\Quote\Model\Quote\Address as QuoteAddress;
use Magento\Quote\Model\Quote\AddressFactory;
use Magento\Quote\Model\QuoteManagement;
use Magento\Quote\Model\ShippingAddressManagement;
use Magento\Sales\Model\Order\Email\Sender\OrderSender;
use Psr\Log\LoggerInterface;

class OrderService
Expand All @@ -27,34 +21,10 @@ class OrderService
* @var QuoteManagement
*/
private $quoteManagement;
/**
* @var AddressFactory
*/
private $addressFactory;
/**
* @var ShippingAddressManagement
*/
private $shippingAddressManagement;
/**
* @var BillingAddressManagement
*/
private $billingAddressManagement;
/**
* @var PaymentLogger
*/
private $paymentLogger;
/**
* @var CheckoutSession
*/
private $checkoutSession;
/**
* @var CheckoutHelperData
*/
private $checkoutHelperData;
/**
* @var OrderSender
*/
private $orderSender;
/**
* @var LoggerInterface
*/
Expand All @@ -63,38 +33,20 @@ class OrderService
/**
* OrderService constructor.
*
* @param CartRepositoryInterface $quoteRepository
* @param QuoteManagement $quoteManagement
* @param CheckoutSession $checkoutSession
* @param AddressFactory $addressFactory
* @param ShippingAddressManagement $shippingAddressManagement
* @param BillingAddressManagement $billingAddressManagement
* @param PaymentLogger $paymentLogger
* @param CheckoutHelperData $checkoutHelperData
* @param OrderSender $orderSender
* @param LoggerInterface $logger
* @param CartRepositoryInterface $quoteRepository
* @param QuoteManagement $quoteManagement
* @param CheckoutHelperData $checkoutHelperData
* @param LoggerInterface $logger
*/
public function __construct(
CartRepositoryInterface $quoteRepository,
QuoteManagement $quoteManagement,
CheckoutSession $checkoutSession,
AddressFactory $addressFactory,
ShippingAddressManagement $shippingAddressManagement,
BillingAddressManagement $billingAddressManagement,
PaymentLogger $paymentLogger,
CheckoutHelperData $checkoutHelperData,
OrderSender $orderSender,
LoggerInterface $logger
) {
$this->quoteRepository = $quoteRepository;
$this->quoteManagement = $quoteManagement;
$this->addressFactory = $addressFactory;
$this->shippingAddressManagement = $shippingAddressManagement;
$this->billingAddressManagement = $billingAddressManagement;
$this->paymentLogger = $paymentLogger;
$this->checkoutSession = $checkoutSession;
$this->checkoutHelperData = $checkoutHelperData;
$this->orderSender = $orderSender;
$this->logger = $logger;
}

Expand Down
16 changes: 4 additions & 12 deletions Model/ApplePay/PaymentRequestConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

namespace Swarming\SubscribePro\Model\ApplePay;

use Magento\Checkout\Helper\Data as CheckoutHelper;
use Magento\Checkout\Model\Session as CheckoutSession;
use Magento\Directory\Helper\Data as DirectoryHelper;
use Magento\Directory\Model\Currency;
Expand Down Expand Up @@ -31,10 +30,6 @@ class PaymentRequestConfig extends DataObject
* @var SessionManagerInterface
*/
private $checkoutSession;
/**
* @var CheckoutHelper
*/
private $checkoutHelper;
/**
* @var Currency
*/
Expand All @@ -56,25 +51,22 @@ class PaymentRequestConfig extends DataObject
* PaymentRequestConfig constructor.
*
* @param SessionManagerInterface $checkoutSession
* @param DirectoryHelper $directoryHelper
* @param Currency $currency
* @param CheckoutHelper $checkoutHelper
* @param PlatformOAuth $platformOAuth
* @param DirectoryHelper $directoryHelper
* @param Currency $currency
* @param PlatformOAuth $platformOAuth
* @param PlatformManagerCustomer $platformManagerCustomer
* @param LoggerInterface $logger
* @param LoggerInterface $logger
*/
public function __construct(
SessionManagerInterface $checkoutSession,
DirectoryHelper $directoryHelper,
Currency $currency,
CheckoutHelper $checkoutHelper,
PlatformOAuth $platformOAuth,
PlatformManagerCustomer $platformManagerCustomer,
LoggerInterface $logger
) {
$this->checkoutSession = $checkoutSession;
$this->directoryHelper = $directoryHelper;
$this->checkoutHelper = $checkoutHelper;
$this->currency = $currency;
$this->platformOAuth = $platformOAuth;
$this->platformManagerCustomer = $platformManagerCustomer;
Expand Down
42 changes: 10 additions & 32 deletions Model/ApplePay/PaymentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Magento\Framework\Serialize\Serializer\Json as JsonSerializer;
use Magento\Framework\Session\SessionManagerInterface;
use Magento\Quote\Api\Data\AddressInterface;
use Magento\Quote\Api\Data\CartInterface;
use Magento\Quote\Model\Quote;
use Magento\Quote\Model\Quote\Address as QuoteAddress;
use Magento\Quote\Model\QuoteManagement;
Expand Down Expand Up @@ -49,10 +48,6 @@ class PaymentService
* @var CustomerSession
*/
private $customerSession;
/**
* @var Currency
*/
private $currency;
/**
* @var DirectoryRegion
*/
Expand All @@ -69,10 +64,6 @@ class PaymentService
* @var OrderService
*/
private $orderService;
/**
* @var QuoteManagement
*/
private $quoteManagement;
/**
* @var QuotePaymentResourceModel
*/
Expand All @@ -85,56 +76,43 @@ class PaymentService
* @var JsonSerializer
*/
private $jsonSerializer;
/**
* @var LoggerInterface
*/
private $logger;

/**
* Construct the payment service.
*
* @param SessionManagerInterface $checkoutSession
* @param CustomerSession $customerSession
* @param Currency $currency
* @param DirectoryRegion $directoryRegion
* @param PlatformCustomer $platformCustomer
* @param SessionManagerInterface $checkoutSession
* @param CustomerSession $customerSession
* @param DirectoryRegion $directoryRegion
* @param PlatformCustomer $platformCustomer
* @param PlatformApplePayPaymentProfile $platformPaymentProfile
* @param OrderService $orderService
* @param QuoteManagement $quoteManagement
* @param QuotePaymentResourceModel $quotePaymentResourceModel
* @param QuoteResourceModel $quoteResourceModel
* @param JsonSerializer $jsonSerializer
* @param ApplePayVaultHelper $vault
* @param LoggerInterface $logger
* @param OrderService $orderService
* @param QuotePaymentResourceModel $quotePaymentResourceModel
* @param QuoteResourceModel $quoteResourceModel
* @param JsonSerializer $jsonSerializer
* @param ApplePayVaultHelper $vault
*/
public function __construct(
SessionManagerInterface $checkoutSession,
CustomerSession $customerSession,
Currency $currency,
DirectoryRegion $directoryRegion,
PlatformCustomer $platformCustomer,
PlatformApplePayPaymentProfile $platformPaymentProfile,
OrderService $orderService,
QuoteManagement $quoteManagement,
QuotePaymentResourceModel $quotePaymentResourceModel,
QuoteResourceModel $quoteResourceModel,
JsonSerializer $jsonSerializer,
ApplePayVaultHelper $vault,
LoggerInterface $logger
ApplePayVaultHelper $vault
) {
$this->checkoutSession = $checkoutSession;
$this->customerSession = $customerSession;
$this->currency = $currency;
$this->directoryRegion = $directoryRegion;
$this->platformCustomer = $platformCustomer;
$this->platformPaymentProfile = $platformPaymentProfile;
$this->orderService = $orderService;
$this->quoteManagement = $quoteManagement;
$this->quotePaymentResourceModel = $quotePaymentResourceModel;
$this->quoteResourceModel = $quoteResourceModel;
$this->jsonSerializer = $jsonSerializer;
$this->applePayVaultHelper = $vault;
$this->logger = $logger;
}

/**
Expand Down
Loading