Skip to content

Commit

Permalink
feat: Fix PHPStan level 1.
Browse files Browse the repository at this point in the history
Refs: #175
  • Loading branch information
eugene-shab committed Dec 19, 2023
1 parent 6423b48 commit 75efe8b
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 29 deletions.
10 changes: 8 additions & 2 deletions Block/Adminhtml/Order/Create/Items/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Swarming\SubscribePro\Block\Adminhtml\Order\Create\Items;

use Magento\Backend\Model\Session\Quote;
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\CatalogInventory\Api\StockRegistryInterface;
use Magento\CatalogInventory\Api\StockStateInterface;
Expand Down Expand Up @@ -30,9 +31,14 @@ class Grid extends \Magento\Sales\Block\Adminhtml\Order\Create\Items\Grid
*/
protected $platformProductManager;

/**
* @var Quote
*/
protected Quote $sessionQuote;

/**
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\Backend\Model\Session\Quote $sessionQuote
* @param Quote $sessionQuote
* @param \Magento\Sales\Model\AdminOrder\Create $orderCreate
* @param PriceCurrencyInterface $priceCurrency
* @param \Magento\Wishlist\Model\WishlistFactory $wishlistFactory
Expand All @@ -50,7 +56,7 @@ class Grid extends \Magento\Sales\Block\Adminhtml\Order\Create\Items\Grid
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Backend\Model\Session\Quote $sessionQuote,
Quote $sessionQuote,
\Magento\Sales\Model\AdminOrder\Create $orderCreate,
PriceCurrencyInterface $priceCurrency,
\Magento\Wishlist\Model\WishlistFactory $wishlistFactory,
Expand Down
16 changes: 16 additions & 0 deletions Block/Adminhtml/System/Config/TestConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ class TestConnection extends PlatformField
*/
protected $_template = 'system/config/test_connection.phtml';

/**
* @var string
*/
protected string $_htmlId;

/**
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @return string
Expand Down Expand Up @@ -80,4 +85,15 @@ public function getWebsiteCode()
{
return $this->getRequest()->getParam('website', '');
}

/**
* Set html id
*
* @param string $htmlId
* @return void
*/
public function setHtmlId(string $htmlId): void
{
$this->_htmlId = $htmlId;
}
}
17 changes: 8 additions & 9 deletions Block/Customer/SubscriptionsDirectoryDataProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

namespace Swarming\SubscribePro\Block\Customer;

use Magento\Checkout\Block\Checkout\LayoutProcessorInterface;
use Magento\Directory\Helper\Data as DirectoryHelper;
use Magento\Directory\Model\ResourceModel\Region\CollectionFactory;
use Magento\Framework\App\ObjectManager;
use Magento\Store\Api\StoreResolverInterface;
use Magento\Store\Model\StoreManagerInterface;

/**
Expand All @@ -13,7 +14,7 @@
* This class adds various country and region dictionaries to checkout page.
* This data can be used by other UI components during checkout flow.
*/
class SubscriptionsDirectoryDataProcessor implements \Magento\Checkout\Block\Checkout\LayoutProcessorInterface
class SubscriptionsDirectoryDataProcessor implements LayoutProcessorInterface
{
/**
* @var array
Expand All @@ -26,12 +27,12 @@ class SubscriptionsDirectoryDataProcessor implements \Magento\Checkout\Block\Che
protected $regionOptions;

/**
* @var \Magento\Directory\Model\ResourceModel\Region\CollectionFactory
* @var CollectionFactory
*/
protected $regionCollectionFactory;

/**
* @var \Magento\Directory\Model\ResourceModel\Region\CollectionFactory
* @var CollectionFactory
*/
protected $countryCollectionFactory;

Expand All @@ -47,16 +48,14 @@ class SubscriptionsDirectoryDataProcessor implements \Magento\Checkout\Block\Che

/**
* @param \Magento\Directory\Model\ResourceModel\Country\CollectionFactory $countryCollection
* @param \Magento\Directory\Model\ResourceModel\Region\CollectionFactory $regionCollection
* @param StoreResolverInterface $storeResolver @deprecated
* @param CollectionFactory $regionCollection
* @param DirectoryHelper $directoryHelper
* @param StoreManagerInterface $storeManager
* @param StoreManagerInterface|null $storeManager
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function __construct(
\Magento\Directory\Model\ResourceModel\Country\CollectionFactory $countryCollection,
\Magento\Directory\Model\ResourceModel\Region\CollectionFactory $regionCollection,
StoreResolverInterface $storeResolver,
CollectionFactory $regionCollection,
DirectoryHelper $directoryHelper,
StoreManagerInterface $storeManager = null
) {
Expand Down
2 changes: 0 additions & 2 deletions Block/Product/Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ class Subscription extends \Magento\Catalog\Block\Product\AbstractProduct
* @param \Magento\Tax\Api\TaxCalculationInterface $taxCalculation
* @param \Swarming\SubscribePro\Ui\ConfigProvider\PriceConfig $priceConfigProvider
* @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency
* @param \Magento\Framework\Locale\FormatInterface $localeFormat
* @param \Swarming\SubscribePro\Helper\Product $productHelper
* @param \Magento\Checkout\Model\Cart $cart
* @param \Swarming\SubscribePro\Helper\QuoteItem $quoteItemHelper
Expand All @@ -78,7 +77,6 @@ public function __construct(
\Magento\Tax\Api\TaxCalculationInterface $taxCalculation,
\Swarming\SubscribePro\Ui\ConfigProvider\PriceConfig $priceConfigProvider,
\Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency,
\Magento\Framework\Locale\FormatInterface $localeFormat,
\Swarming\SubscribePro\Helper\Product $productHelper,
\Magento\Checkout\Model\Cart $cart,
\Swarming\SubscribePro\Helper\QuoteItem $quoteItemHelper,
Expand Down
6 changes: 4 additions & 2 deletions Block/Vault/Edit/CardExpiration.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace Swarming\SubscribePro\Block\Vault\Edit;

class CardExpiration extends \Swarming\SubscribePro\Block\Vault\CardRenderer
use Swarming\SubscribePro\Block\Vault\CardRenderer;

class CardExpiration extends CardRenderer
{
/**
* @return string
Expand All @@ -14,7 +16,7 @@ public function getJsLayout()
}

/**
* @return string[]
* @return void
*/
protected function updateJsLayout()
{
Expand Down
3 changes: 0 additions & 3 deletions Controller/Applepay/PaymentAuthorized.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ public function execute()
try {
$this->implementExecute($result);
} catch (LocalizedException $e) {
if (isset($quoteId)) {
$this->logger->error('QuoteId: ' . $quoteId);
}
$this->logger->error($e->getMessage());

$response = [
Expand Down
2 changes: 1 addition & 1 deletion Controller/Applepay/ShippingList.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public function execute()
// Build response
$response = [
'success' => true,
'newShippingMethods' => ($shippingMethodsForApplePay)?? [],
'newShippingMethods' => $shippingMethodsForApplePay ?: [],
'newTotal' => $grandTotalForApplePay,
'newLineItems' => $rowItemsApplePay,
];
Expand Down
2 changes: 1 addition & 1 deletion Gateway/Config/ApplePayConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ public function getApiBaseUrl($websiteCode = null): string
{
$value = $this->generalConfig->getBaseUrl($websiteCode);

return ($value)?? '';
return $value ?: '';
}
}
2 changes: 1 addition & 1 deletion Helper/OrderItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ protected function getAdditionalOptions($orderItem)
/**
* @param \Magento\Sales\Model\Order\Item $orderItem
* @param array $additionalOptions
* @return array
* @return void
*/
protected function setAdditionalOptions($orderItem, $additionalOptions)
{
Expand Down
6 changes: 2 additions & 4 deletions Helper/QuoteItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,13 @@ public function getSubscriptionParams($item)
{
$buyRequest = $item->getOptionByCode('info_buyRequest');
$buyRequest = $buyRequest ? json_decode($buyRequest->getValue(), true) : [];
return isset($buyRequest[OptionProcessor::KEY_SUBSCRIPTION_OPTION])
? $buyRequest[OptionProcessor::KEY_SUBSCRIPTION_OPTION]
: [];
return $buyRequest[OptionProcessor::KEY_SUBSCRIPTION_OPTION] ?? [];
}

/**
* @param \Magento\Quote\Model\Quote\Item\AbstractItem $item
* @param array $params
* @return array
* @return void
*/
protected function setSubscriptionParams($item, $params)
{
Expand Down
2 changes: 1 addition & 1 deletion Model/ApplePay/PaymentRequestConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ public function getAccessToken()
} catch (LocalizedException $e) {
$this->logger->error('QuoteId: ' . $quote->getId());
$this->logger->error('WebsiteId: ' . $websiteId);
if ($subscriberProCustomerId) {
if ($customerId && $subscriberProCustomerId) {
$this->logger->error('SubscriberProCustomerId: ' . $subscriberProCustomerId);
}
$this->logger->error($e->getMessage());
Expand Down
14 changes: 14 additions & 0 deletions Model/Rule/Condition/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ class Base extends \Magento\Rule\Model\Condition\AbstractCondition
*/
protected $discountRuleHelper;

/**
* @var array
*/
protected array $attribute_option;

/**
* Constructor
* @param Context $context
Expand Down Expand Up @@ -155,4 +160,13 @@ protected function subscriptionOptionsAreFalse(\Magento\Framework\Model\Abstract
$this->quoteItemHelper->getSubscriptionParams($model)
);
}

/**
* @param array $attributes
* @return void
*/
protected function setAttributeOption(array $attributes): void
{
$this->attribute_option = $attributes;
}
}
2 changes: 1 addition & 1 deletion Model/Rule/Condition/Interval.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ public function loadAttributeOptions()
public function validate(\Magento\Framework\Model\AbstractModel $model)
{
$interval = $this->discountRuleHelper->validateInterval($this->quoteItemHelper->getSubscriptionParams($model));
return false === $interval ? false : $this->validateAttribute($interval);
return !(false === $interval) && $this->validateAttribute($interval);
}
}
5 changes: 3 additions & 2 deletions Plugin/ShipperHQ/ShipperMapperPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct(
* @return array
*/
public function aroundPopulateAttributes(
\ShipperHQ\Shipper\Model\Carrier\Processor\ShipperMapper $mapper,
\ShipperHQ\Shipper\Model\Carrier\Processor\ShipperMapper $mapper, /* @phpstan-ignore-line */
callable $proceed,
$reqdAttributeNames,
$item
Expand All @@ -43,6 +43,7 @@ public function aroundPopulateAttributes(

if ($recurringShippingCode = $this->determineSubscriptionCode($item)) {
$shippingGroup = '';
$shippingKey = '';
$shippingGroupSet = false;

if (is_array($attributes)) {
Expand All @@ -55,7 +56,7 @@ public function aroundPopulateAttributes(
}
if (!$shippingGroupSet) {
$attributes[] = ['name' => 'shipperhq_shipping_group', 'value' => $recurringShippingCode];
} else {
} else{
$attributes[$shippingKey] = ['name' => 'shipperhq_shipping_group', 'value' => $shippingGroup];
}
}
Expand Down

0 comments on commit 75efe8b

Please sign in to comment.