Skip to content

Commit

Permalink
Fix error issues reported by PhpSta level2 tool in Helper folder
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmccombs1 committed Dec 15, 2023
1 parent 4633ac7 commit 79fff75
Show file tree
Hide file tree
Showing 27 changed files with 221 additions and 223 deletions.
4 changes: 4 additions & 0 deletions .circleci/phpstan/mocks/unirgy_giftcert_helper_data.mock
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
namespace Unirgy\Giftcert\Helper {
class Data{}
}
15 changes: 13 additions & 2 deletions .circleci/phpstan/mocks/unirgy_giftcert_model_cert.mock
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
<?php
namespace Unirgy\Giftcert\Model;
class Cert{}
namespace Unirgy\Giftcert\Model {
class Cert{
const GIFTCERT_CODE = 'GIFTCERT_CODE';
public function get($code){}
public function getCertNumber(){}
public function getBalance(){}
public function getStoreId(){}
public function getData($key){}
}
class GiftcertRepository{
public function get($code){}
}
}
18 changes: 9 additions & 9 deletions Helper/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class Api extends AbstractHelper


/**
* @var HttpClientAdapterFactory
* @var HttpClientAdapterFactory|mixed
*/
private $httpClientAdapterFactory;

Expand All @@ -138,14 +138,14 @@ class Api extends AbstractHelper
/**
* Response factory
*
* @var ResponseFactory
* @var ResponseFactory|mixed
*/
private $responseFactory;

/**
* Request factory
*
* @var RequestFactory
* @var RequestFactory|mixed
*/
private $requestFactory;

Expand All @@ -156,7 +156,7 @@ class Api extends AbstractHelper

/**
* @param Context $context
* @param HttpClientAdapterFactory $httpClientFactory
* @param HttpClientAdapterFactory $httpClientAdapterFactory
* @param ConfigHelper $configHelper
* @param ResponseFactory $responseFactory
* @param RequestFactory $requestFactory
Expand Down Expand Up @@ -184,9 +184,9 @@ public function __construct(
/**
* Send request to Bolt Gateway and return response
*
* @param Request $request
* @param Request|mixed $request
*
* @return Response|int
* @return Response|mixed
* @throws LocalizedException
*/
public function sendRequest($request)
Expand Down Expand Up @@ -241,7 +241,7 @@ public function sendRequest($request)
]);
});
} catch (Exception $e) {
throw new LocalizedException(__('Gateway error: %1', $e->getMessage()));
throw new LocalizedException(__('Gateway error: %1', $e->getMessage())); /** @phpstan-ignore-line */
}

if ($request->getStatusOnly() && $response) {
Expand All @@ -252,15 +252,15 @@ public function sendRequest($request)
$resultFromJSON = ApiUtils::getJSONFromResponseBody($responseBody);
$result->setResponse($resultFromJSON);
} else {
throw new LocalizedException(__('Something went wrong in the payment gateway.'));
throw new LocalizedException(__('Something went wrong in the payment gateway.')); /** @phpstan-ignore-line */
}
return $result;
}

/**
* Build request
*
* @param DataObject $requestData
* @param DataObject|mixed $requestData
*
* @return Request
*/
Expand Down
1 change: 1 addition & 0 deletions Helper/AutomatedTesting.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ protected function getProduct($type)
$searchCriteria = $searchCriteriaBuilder->create();

$products = $this->productRepository->getList($searchCriteria)->getItems();
/** @var Product $product */
foreach ($products as $product) {
if ($this->stockRegistry->getStockItem($product->getId())->getIsInStock() && (
$type !== 'sale' ||
Expand Down
7 changes: 2 additions & 5 deletions Helper/Bugsnag.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use Magento\Framework\App\Helper\AbstractHelper;
use Magento\Framework\App\Helper\Context;
use Bolt\Boltpay\Helper\Config as ConfigHelper;
use Magento\Framework\Filesystem\DirectoryList;
use Magento\Store\Model\StoreManagerInterface;
use Bolt\Boltpay\Helper\Log as BoltLogger;

Expand All @@ -38,7 +37,7 @@ class Bugsnag extends AbstractHelper
const STAGE_TEST = 'test';

/**
* @var BugsnagClient
* @var \Bugsnag\Client
*/
private $bugsnag;

Expand All @@ -59,14 +58,12 @@ class Bugsnag extends AbstractHelper
* Bugsnag constructor.
* @param Context $context
* @param Config $configHelper
* @param DirectoryList $directoryList
* @param StoreManagerInterface $storeManager
* @param BoltLogger $boltLogger
*/
public function __construct(
Context $context,
ConfigHelper $configHelper,
DirectoryList $directoryList,
StoreManagerInterface $storeManager,
BoltLogger $boltLogger
) {
Expand Down Expand Up @@ -99,7 +96,7 @@ public function __construct(
/**
* Notify Bugsnag of a non-fatal/handled throwable.
*
* @param \Throwable $throwable the throwable to notify Bugsnag about
* @param mixed $throwable the throwable to notify Bugsnag about
* @param callable|null $callback the customization callback
*
* @return void
Expand Down
Loading

0 comments on commit 79fff75

Please sign in to comment.