Skip to content

Commit

Permalink
Merge pull request #33 from AJenbo/level1
Browse files Browse the repository at this point in the history
Resolve remaning PHPStan level 1 issues
  • Loading branch information
condor2 authored Feb 1, 2024
2 parents e8643ba + c08adc9 commit f2a4754
Show file tree
Hide file tree
Showing 15 changed files with 41 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/Lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:

- name: PHPStan
run: |
composer require --dev phpstan/phpstan 1.10.56
composer require --dev phpstan/phpstan 1.10.57
./upload/system/storage/vendor/bin/phpstan analyze --no-progress
- name: Code style
Expand Down
2 changes: 1 addition & 1 deletion upload/admin/model/extension/payment/eway.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public function updateRefundStatus($eway_order_id, $status) {
$this->db->query("UPDATE `" . DB_PREFIX . "eway_order` SET `refund_status` = '" . (int)$status . "' WHERE `eway_order_id` = '" . (int)$eway_order_id . "'");
}

public function sendCurl($url, $data) {
public function sendCurl($url, $data, $is_post = true) {
$ch = curl_init($url);

$eway_username = html_entity_decode($this->config->get('eway_username'), ENT_QUOTES, 'UTF-8');
Expand Down
2 changes: 1 addition & 1 deletion upload/admin/model/extension/payment/opayo.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public function getTotalRebated($opayo_order_id) {
return (float)$query->row['total'];
}

public function sendCurl($url, $payment_data) {
public function sendCurl($url, $payment_data, $is_post = true) {
$curl = curl_init($url);

curl_setopt($curl, CURLOPT_PORT, 443);
Expand Down
4 changes: 2 additions & 2 deletions upload/catalog/controller/extension/module/pp_login.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function login() {
$customer_info = $this->model_account_customer->getCustomerByEmail($user->email);

if ($customer_info) {
if ($this->validate($user->email)) {
if (isset($tokens) && $this->validate($user->email)) {
$this->completeLogin($customer_info['customer_id'], $customer_info['email'], $tokens->access_token);
} else {
$this->model_extension_module_pp_login->log('Could not login to - ID: ' . $customer_info['customer_id'] . ', Email: ' . $customer_info['email']);
Expand Down Expand Up @@ -130,7 +130,7 @@ public function login() {

$this->model_extension_module_pp_login->log('Customer ID date_added: ' . $customer_id);

if ($this->validate($user->email)) {
if (isset($tokens) && $this->validate($user->email)) {
$this->completeLogin($customer_id, $user->email, $tokens->access_token);
} else {
$this->model_extension_module_pp_login->log('Could not login to - ID: ' . $customer_id . ', Email: ' . $user->email);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ public function confirm() {
}

// Totals
/** @var array<int, mixed> */
$totals = [];
$taxes = $this->cart->getTaxes();
$total = 0;
Expand Down Expand Up @@ -690,6 +691,8 @@ public function shippingQuotes() {
} elseif ($AddressLine1 != '') {
$address_1 = $AddressLine1;
$address_2 = '';
} else {
throw new \Exception('Missing address information');
}

$full_name = explode(' ', (string)$address_xml->Name);
Expand Down Expand Up @@ -821,6 +824,8 @@ public function setBillingAddress($order_info, $billing_address) {
} elseif ($AddressLine1 != '') {
$address_1 = $AddressLine1;
$address_2 = '';
} else {
throw new \Exception('Missing address information');
}

$result = $this->model_extension_payment_amazon_login_pay->getCountry((string)$billing_address->CountryCode);
Expand All @@ -831,6 +836,8 @@ public function setBillingAddress($order_info, $billing_address) {
$address_format = $result['address_format'];
$country_name = $result['name'];
$country_id = (int)$result['country_id'];
} else {
throw new \Exception('Missing amazon country information');
}

$order_info['payment_firstname'] = $first_name;
Expand Down
2 changes: 1 addition & 1 deletion upload/catalog/controller/extension/payment/cardinity.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,4 +294,4 @@ private function validate() {

return $error;
}
}
}
16 changes: 7 additions & 9 deletions upload/catalog/controller/extension/payment/g2apay.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ public function checkout(): void {

$order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);

$order_data = [];

$this->load->model('extension/extension');

$totals = [];
Expand All @@ -52,16 +50,16 @@ public function checkout(): void {
// We have to put the totals in an array so that they pass by reference.
$this->{'model_extension_total_' . $result['code']}->getTotal($total_data);

if (isset($order_data['totals'][$i])) {
if (strstr(strtolower($order_data['totals'][$i]['code']), 'total') === false) {
if (isset($total_data['totals'][$i])) {
if (strstr(strtolower($total_data['totals'][$i]['code']), 'total') === false) {
$item = new stdClass();

$item->sku = $order_data['totals'][$i]['code'];
$item->name = $order_data['totals'][$i]['title'];
$item->amount = number_format($order_data['totals'][$i]['value'], 2);
$item->sku = $total_data['totals'][$i]['code'];
$item->name = $total_data['totals'][$i]['title'];
$item->amount = number_format($total_data['totals'][$i]['value'], 2);
$item->qty = 1;
$item->id = $order_data['totals'][$i]['code'];
$item->price = $order_data['totals'][$i]['value'];
$item->id = $total_data['totals'][$i]['code'];
$item->price = $total_data['totals'][$i]['value'];
$item->url = $this->url->link('common/home', '', true);

$items[] = $item;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,8 @@ public function acsReturn() {
$this->response->redirect($this->url->link('checkout/checkout', '', true));
} else {
$this->response->redirect($this->url->link('checkout/success'));
}
}
}
} else {
$this->response->redirect($this->url->link('account/login', '', true));
}
Expand Down
6 changes: 6 additions & 0 deletions upload/catalog/controller/extension/payment/pp_express.php
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,8 @@ public function expressConfirm() {
$payment_address = $this->model_account_address->getAddress($this->session->data['payment_address_id']);
} elseif (isset($this->session->data['guest'])) {
$payment_address = $this->session->data['guest']['payment'];
} else {
throw new \Exception('Missing session data');
}

$method_data = [];
Expand Down Expand Up @@ -1093,6 +1095,8 @@ public function expressComplete() {
break;
case 'Voided':$order_status_id = $this->config->get('pp_express_voided_status_id');
break;
default:
throw new \Exception('Unknown payment status');
}

$this->model_checkout_order->addOrderHistory($order_id, $order_status_id);
Expand Down Expand Up @@ -1377,6 +1381,8 @@ public function checkoutReturn() {
break;
case 'Voided':$order_status_id = $this->config->get('pp_express_voided_status_id');
break;
default:
throw new \Exception('Unknown payment status');
}

$this->model_checkout_order->addOrderHistory($order_id, $order_status_id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,4 +348,4 @@ public function acsReturn(): void {
$this->response->redirect($this->url->link('account/login', '', true));
}
}
}
}
4 changes: 3 additions & 1 deletion upload/catalog/model/extension/payment/amazon_login_pay.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public function sendOrder($order_id, $total, $currency_code) {
}
}

$confirm_details = $this->offAmazon('ConfirmOrderReference');
$confirm_details = $this->offAmazon('ConfirmOrderReference', []);
$confirm_details_response = $this->validateResponse('Confirm', $confirm_details);
if ($confirm_details_response['redirect']) {
return $confirm_details_response;
Expand Down Expand Up @@ -523,6 +523,8 @@ private function getXmlFromIpnMessage($ipnMsg) {
$xml = simplexml_load_string($notificationData);
} catch (Exception $ex) {
$this->logger($notificationData);

return null;
}

return $xml;
Expand Down
6 changes: 3 additions & 3 deletions upload/catalog/model/extension/payment/cardinity.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,18 @@ public function log($data, $class_step = 6, $function_step = 6) {
}

private function exception(Exception $exception) {
$this->log($exception->getMessage(), 1, 2);
$this->log($exception->getMessage());

switch (true) {
case $exception instanceof CardinityException\Request:
if ($exception->getErrorsAsString()) {
$this->log($exception->getErrorsAsString(), 1, 2);
$this->log($exception->getErrorsAsString());
}

break;
case $exception instanceof CardinityException\InvalidAttributeValue:
foreach ($exception->getViolations() as $violation) {
$this->log($violation->getMessage(), 1, 2);
$this->log($violation->getMessage());
}

break;
Expand Down
3 changes: 2 additions & 1 deletion upload/system/engine/front.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class Front {
/**
* Constructor
*
* @param object $route
* @param Registry $registry
* @param object $route
*/
public function __construct($registry) {
$this->registry = $registry;
Expand Down
3 changes: 3 additions & 0 deletions upload/system/library/db.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class DB {
* @param string $password
* @param string $database
* @param int $port
* @param string $ssl_key
* @param string $ssl_cert
* @param string $ssl_ca
*/
public function __construct($adaptor, $hostname, $username, $password, $database, $port = '', $ssl_key = '', $ssl_cert = '', $ssl_ca = '') {
$class = 'DB\\' . $adaptor;
Expand Down
2 changes: 2 additions & 0 deletions upload/system/library/response.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public function getOutput(): string {
/**
* setOutput
*
* @param string $output
*
* @return void
*/
public function setOutput($output): void {
Expand Down

0 comments on commit f2a4754

Please sign in to comment.