Skip to content

Commit

Permalink
Fix error issues reported by PhpSta level2 tool in Model folder
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmccombs1 committed Dec 21, 2023
1 parent 79fff75 commit 68e9af2
Show file tree
Hide file tree
Showing 37 changed files with 153 additions and 123 deletions.
2 changes: 1 addition & 1 deletion Api/CreateOrderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ interface CreateOrderInterface
* @param mixed $order - which contain token and cart nodes.
* @param string $currency
*
* @return void
* @return mixed
*/
public function execute(
$type = null,
Expand Down
6 changes: 3 additions & 3 deletions Api/LegacyApiInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ interface LegacyApiInterface
* @param mixed $display_id
* @param mixed $source_transaction_id
* @param mixed $source_transaction_reference
* @return void
* @return mixed
*/

public function manage(
Expand All @@ -61,7 +61,7 @@ public function manage(
* @param mixed $remove_items
* @param mixed $discount_codes_to_add
* @param mixed $discount_codes_to_remove
* @return Bolt\Boltpay\Api\Data\UpdateCartResultInterface|mixed
* @return \Bolt\Boltpay\Api\Data\UpdateCartResultInterface|mixed
*/
public function updateCart(
$cart,
Expand Down Expand Up @@ -123,7 +123,7 @@ public function validateDiscount();
* @param mixed $order - which contain token and cart nodes.
* @param string $currency
*
* @return void
* @return mixed
*/
public function createOrder($type = null, $order = null, $currency = null);
}
2 changes: 1 addition & 1 deletion Api/OrderManagementInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ interface OrderManagementInterface
* @param mixed $source_transaction_id
* @param mixed $source_transaction_reference
*
* @return void
* @return mixed
*/
public function manage(
$id = null,
Expand Down
11 changes: 10 additions & 1 deletion Api/ShippingInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,14 @@ interface ShippingInterface
* @param mixed $shipping_address shipping address
* @return \Bolt\Boltpay\Api\Data\ShippingDataInterface
*/
public function execute($cart, $shipping_address);

/**
* @param $cart
* @param $shipping_address
* @param $shipping_option
* @param $ship_to_store_option
* @return \Bolt\Boltpay\Api\Data\ShippingDataInterface
*/
public function execute($cart, $shipping_address, $shipping_option = null, $ship_to_store_option = null);

}
3 changes: 2 additions & 1 deletion Helper/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -2426,10 +2426,11 @@ private function isFullyCaptured ($order, $transaction)
* @param float $amount
* @param bool $notify
*
* @return bool
* @return Invoice|mixed
* @throws \Exception
* @throws LocalizedException
*/

public function createOrderInvoice($order, $amount, $notify = false, $transactionId = null)
{
$currencyCode = $order->getOrderCurrencyCode();
Expand Down
12 changes: 6 additions & 6 deletions Model/Api/CartManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class CartManagement implements CartManagementInterface
private $bugsnag;

/**
* @var QuoteIdMaskFactory
* @var QuoteIdMaskFactory|mixed
*/
private $quoteIdMaskFactory;

Expand Down Expand Up @@ -101,7 +101,7 @@ public function getMaskedId($cartId = '')
if (!$maskedQuoteID) {
$maskedQuoteID = $this->generateMaskQuoteId($cartId);
if (!$maskedQuoteID) {
throw new WebapiException(__('Masked quote ID does not found'), 0, WebapiException::HTTP_NOT_FOUND);
throw new WebapiException(__('Masked quote ID does not found'), 0, WebapiException::HTTP_NOT_FOUND); // @phpstan-ignore-line
}

}
Expand All @@ -112,7 +112,7 @@ public function getMaskedId($cartId = '')
throw $e;
} catch (Exception $e) {
$this->bugsnag->notifyException($e);
throw new WebapiException(__($e->getMessage()), 0, WebapiException::HTTP_INTERNAL_ERROR);
throw new WebapiException(__($e->getMessage()), 0, WebapiException::HTTP_INTERNAL_ERROR); // @phpstan-ignore-line
}
}

Expand Down Expand Up @@ -143,7 +143,7 @@ public function update($cartId = null, $isActive = null)
try {
$quote = $this->cartHelper->getQuoteById($cartId);
if (!$quote) {
throw new WebapiException(__('Quote does not found'), 0, WebapiException::HTTP_NOT_FOUND);
throw new WebapiException(__('Quote does not found'), 0, WebapiException::HTTP_NOT_FOUND); // @phpstan-ignore-line
}

$quote->setIsActive((bool)$isActive)->save();
Expand All @@ -152,7 +152,7 @@ public function update($cartId = null, $isActive = null)
throw $e;
} catch (Exception $e) {
$this->bugsnag->notifyException($e);
throw new WebapiException(__($e->getMessage()), 0, WebapiException::HTTP_INTERNAL_ERROR);
throw new WebapiException(__($e->getMessage()), 0, WebapiException::HTTP_INTERNAL_ERROR); // @phpstan-ignore-line
}
}

Expand All @@ -178,7 +178,7 @@ public function getCartIdByMaskedId($maskedQuoteId)
throw $e;
} catch (Exception $e) {
$this->bugsnag->notifyException($e);
throw new WebapiException(__($e->getMessage()), 0, WebapiException::HTTP_INTERNAL_ERROR);
throw new WebapiException(__($e->getMessage()), 0, WebapiException::HTTP_INTERNAL_ERROR); // @phpstan-ignore-line
}
}

Expand Down
30 changes: 17 additions & 13 deletions Model/Api/CreateOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
use Magento\CatalogInventory\Helper\Data as CatalogInventoryData;
use Bolt\Boltpay\Helper\Session as SessionHelper;
use Bolt\Boltpay\Model\EventsForThirdPartyModules;
use Magento\Sales\Model\Order;

/**
* Class CreateOrder
Expand Down Expand Up @@ -313,7 +314,7 @@ public function execute(
/**
* @param Quote $immutableQuote
* @param \stdClass $transaction
* @return OrderModel
* @return Order
* @throws \Exception
* @throws BoltException
*/
Expand Down Expand Up @@ -471,7 +472,7 @@ public function validateQuoteData($quote, $transaction)
/**
* Validate minimum order amount
*
* @param Quote $quote
* @param Quote|mixed $quote
* @throws BoltException
*/
public function validateMinimumAmount($quote)
Expand Down Expand Up @@ -511,7 +512,7 @@ private function arrayDiff($A, $B)
}

/**
* @param Quote $quote
* @param Quote|mixed $quote
* @param $transaction
* @throws BoltException
* @throws NoSuchEntityException
Expand Down Expand Up @@ -570,7 +571,7 @@ function ($item) {
/**
* Check if quote have errors.
*
* @param QuoteItem $quoteItem
* @param QuoteItem|mixed $quoteItem
* @return bool
* @throws BoltException
*/
Expand Down Expand Up @@ -647,14 +648,17 @@ public function validateItemPrice($itemSku, $itemPrice, &$transactionItems)
return true;
}
}
$this->bugsnag->registerCallback(function ($report) use ($itemPrice, $transactionUnitPrice) {
$report->setMetaData([
'Pre Auth' => [
'item.price' => $itemPrice,
'transaction.unit_price' => $transactionUnitPrice,
]
]);
});
if (isset($transactionUnitPrice)) {
$this->bugsnag->registerCallback(function ($report) use ($itemPrice, $transactionUnitPrice) {
$report->setMetaData([
'Pre Auth' => [
'item.price' => $itemPrice,
'transaction.unit_price' => $transactionUnitPrice,
]
]);
});
}

throw new BoltException(
__('Price does not match. Item sku: ' . $itemSku),
null,
Expand Down Expand Up @@ -693,7 +697,7 @@ public function validateTax($quote, $transaction)
}

/**
* @param Quote $quote
* @param Quote|mixed $quote
* @param \stdClass $transaction
* @return void
* @throws BoltException
Expand Down
2 changes: 1 addition & 1 deletion Model/Api/Data/AutomatedTesting/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public function setCountry($country)
}

/**
* @return array|mixed
* @return array
*/
public function jsonSerialize(): array
{
Expand Down
2 changes: 1 addition & 1 deletion Model/Api/Data/AutomatedTesting/OrderItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public function setTotal($total)
}

/**
* @return array|mixed
* @return array
*/
public function jsonSerialize(): array
{
Expand Down
4 changes: 2 additions & 2 deletions Model/Api/Data/DebugInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function getBoltConfigSettings()
}

/**
* @param \Bolt\Boltpay\Model\Api\Data\BoltConfigSetting[]
* @param \Bolt\Boltpay\Model\Api\Data\BoltConfigSetting[] $boltConfigSettings
*
* @return $this
*/
Expand All @@ -151,7 +151,7 @@ public function getOtherPluginVersions()
}

/**
* @param \Bolt\Boltpay\Model\Api\Data\PluginVersion[]
* @param \Bolt\Boltpay\Model\Api\Data\PluginVersion[] $otherPluginVersions
*
* @return $this
*/
Expand Down
2 changes: 1 addition & 1 deletion Model/Api/Data/GetProductData.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function getParent()
* Set parent info.
*
* @api
* @param ProductInventoryInfoInterface
* @param ProductInventoryInfoInterface $parent
*
* @return $this
*/
Expand Down
10 changes: 4 additions & 6 deletions Model/Api/Data/ProductInventoryInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
class ProductInventoryInfo implements ProductInventoryInfoInterface, \JsonSerializable
{
/**
* @var Bolt\Boltpay\Api\Data\ProductInterface
* @var \Bolt\Boltpay\Api\Data\ProductInterface
*/
private $product;

Expand All @@ -41,7 +41,7 @@ class ProductInventoryInfo implements ProductInventoryInfoInterface, \JsonSerial
* Get product info.
*
* @api
* @return Bolt\Boltpay\Api\Data\ProductInterface
* @return \Bolt\Boltpay\Api\Data\ProductInterface
*/
public function getProduct()
{
Expand All @@ -52,7 +52,7 @@ public function getProduct()
* Set product info.
*
* @api
* @param Bolt\Boltpay\Api\Data\ProductInterface $product
* @param \Bolt\Boltpay\Api\Data\ProductInterface $product
*
* @return $this
*/
Expand All @@ -77,7 +77,7 @@ public function getStock()
* Get stock info.
*
* @api
* @param \Magento\CatalogInventory\Api\Data\StockStatusInterface $stockItem
* @param \Magento\CatalogInventory\Api\Data\StockStatusInterface $stockStatus
* @return $this
*/
public function setStock($stockStatus)
Expand All @@ -86,8 +86,6 @@ public function setStock($stockStatus)
return $this;
}



/**
* @inheritDoc
*/
Expand Down
2 changes: 1 addition & 1 deletion Model/Api/Data/ShipToStoreOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public function getAddress()
* Set store address.
*
* @api
* @param \Bolt\Boltpay\Api\Data\StoreAddressInterface $storeAddress
* @param \Bolt\Boltpay\Api\Data\StoreAddressInterface $address
* @return $this
*/
public function setAddress($address)
Expand Down
4 changes: 2 additions & 2 deletions Model/Api/Data/ShippingData.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function getShippingOptions()
* Set available shipping options.
*
* @api
* @param ShippingOptionInterface[]
* @param ShippingOptionInterface[] $shippingOptions
* @return $this
*/
public function setShippingOptions($shippingOptions)
Expand All @@ -76,7 +76,7 @@ public function getShipToStoreOptions()
* Set available ship to store options.
*
* @api
* @param \Bolt\Boltpay\Api\Data\ShipToStoreOptionInterface[]
* @param \Bolt\Boltpay\Api\Data\ShipToStoreOptionInterface[] $shipToStoreOptions
* @return $this
*/
public function setShipToStoreOptions($shipToStoreOptions)
Expand Down
4 changes: 2 additions & 2 deletions Model/Api/Data/ShippingOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function getShippingOptions()
* Set available shipping options.
*
* @api
* @param ShippingOptionInterface[]
* @param ShippingOptionInterface[] $shippingOptions
*
* @return $this
*/
Expand All @@ -80,7 +80,7 @@ public function getTaxResult()
* Set available shipping options.
*
* @api
* @param ShippingTaxInterface
* @param ShippingTaxInterface $taxResult
*
* @return $this
*/
Expand Down
6 changes: 3 additions & 3 deletions Model/Api/Data/TaxData.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function getTaxResult()
* Set available shipping options.
*
* @api
* @param TaxResultInterface
* @param TaxResultInterface $taxResult
*
* @return $this
*/
Expand All @@ -84,7 +84,7 @@ public function getShippingOption()
* Set selected shipping option.
*
* @api
* @param ShippingOptionInterface
* @param ShippingOptionInterface $shippingOption
* @return $this
*/
public function setShippingOption($shippingOption)
Expand All @@ -108,7 +108,7 @@ public function getShipToStoreOption()
* Set available ship to store option.
*
* @api
* @param \Bolt\Boltpay\Api\Data\ShipToStoreOptionInterface
* @param \Bolt\Boltpay\Api\Data\ShipToStoreOptionInterface $shipToStoreOption
* @return $this
*/
public function setShipToStoreOption($shipToStoreOption)
Expand Down
6 changes: 3 additions & 3 deletions Model/Api/Data/UniversalWebhookResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class UniversalWebhookResult implements UniversalWebhookResultInterface
private $status;

/**
* @var []
* @var array
*/
private $error;

Expand Down Expand Up @@ -61,7 +61,7 @@ public function setStatus($status)
* Get error object
*
* @api
* @return []
* @return array
*/

public function getError()
Expand All @@ -73,7 +73,7 @@ public function getError()
* Set error object
*
* @api
* @param [] $error
* @param array $error
* @return \Bolt\Boltpay\Api\Data\UniversalWebhookResultInterface
*/
public function setError($error)
Expand Down
Loading

0 comments on commit 68e9af2

Please sign in to comment.