From cf13ae745113e5c024aca98f56df03fdce9b1c21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B0=D0=B2=D0=B5=D0=BB?= Date: Wed, 8 Apr 2020 16:49:48 +0300 Subject: [PATCH] php 5.3 compliance --- .../class-wc-retailcrm-abstracts-address.php | 4 +- .../api/class-wc-retailcrm-client-v5.php | 70 ++++++++++--------- src/include/class-wc-retailcrm-history.php | 8 +-- src/include/class-wc-retailcrm-plugin.php | 2 +- .../class-wc-retailcrm-customer-address.php | 4 +- 5 files changed, 47 insertions(+), 41 deletions(-) diff --git a/src/include/abstracts/class-wc-retailcrm-abstracts-address.php b/src/include/abstracts/class-wc-retailcrm-abstracts-address.php index 52f6871..699a115 100644 --- a/src/include/abstracts/class-wc-retailcrm-abstracts-address.php +++ b/src/include/abstracts/class-wc-retailcrm-abstracts-address.php @@ -76,7 +76,9 @@ abstract class WC_Retailcrm_Abstracts_Address extends WC_Retailcrm_Abstracts_Dat */ protected function getOrderAddress($order) { - return (empty($order->get_address($this->address_type)) && $this->fallback_to_billing) + $orderAddress = $order->get_address($this->address_type); + + return (empty($orderAddress) && $this->fallback_to_billing) ? $order->get_address(self::ADDRESS_TYPE_BILLING) : $order->get_address($this->address_type); } diff --git a/src/include/api/class-wc-retailcrm-client-v5.php b/src/include/api/class-wc-retailcrm-client-v5.php index 721b7ef..7ae24ff 100644 --- a/src/include/api/class-wc-retailcrm-client-v5.php +++ b/src/include/api/class-wc-retailcrm-client-v5.php @@ -87,9 +87,9 @@ class WC_Retailcrm_Client_V5 * * @return WC_Retailcrm_Response */ - public function customersCorporateList(array $filter = [], $page = null, $limit = null) + public function customersCorporateList(array $filter= array(), $page = null, $limit = null) { - $parameters = []; + $parameters= array(); if (count($filter)) { $parameters['filter'] = $filter; } @@ -130,7 +130,7 @@ class WC_Retailcrm_Client_V5 return $this->client->makeRequest( '/customers-corporate/create', "POST", - $this->fillSite($site, ['customerCorporate' => json_encode($customerCorporate)]) + $this->fillSite($site, array('customerCorporate' => json_encode($customerCorporate))) ); } @@ -156,7 +156,7 @@ class WC_Retailcrm_Client_V5 return $this->client->makeRequest( '/customers-corporate/fix-external-ids', "POST", - ['customersCorporate' => json_encode($ids)] + array('customersCorporate' => json_encode($ids)) ); } @@ -168,9 +168,9 @@ class WC_Retailcrm_Client_V5 * * @return WC_Retailcrm_Response */ - public function customersCorporateHistory(array $filter = [], $page = null, $limit = null) + public function customersCorporateHistory(array $filter= array(), $page = null, $limit = null) { - $parameters = []; + $parameters= array(); if (count($filter)) { $parameters['filter'] = $filter; } @@ -201,9 +201,9 @@ class WC_Retailcrm_Client_V5 * * @return WC_Retailcrm_Response */ - public function customersCorporateNotesList(array $filter = [], $page = null, $limit = null) + public function customersCorporateNotesList(array $filter= array(), $page = null, $limit = null) { - $parameters = []; + $parameters= array(); if (count($filter)) { $parameters['filter'] = $filter; } @@ -244,7 +244,7 @@ class WC_Retailcrm_Client_V5 return $this->client->makeRequest( '/customers-corporate/notes/create', "POST", - $this->fillSite($site, ['note' => json_encode($note)]) + $this->fillSite($site, array('note' => json_encode($note))) ); } @@ -296,7 +296,7 @@ class WC_Retailcrm_Client_V5 return $this->client->makeRequest( '/customers-corporate/upload', "POST", - $this->fillSite($site, ['customersCorporate' => json_encode($customersCorporate)]) + $this->fillSite($site, array('customersCorporate' => json_encode($customersCorporate))) ); } @@ -320,7 +320,7 @@ class WC_Retailcrm_Client_V5 return $this->client->makeRequest( "/customers-corporate/$id", "GET", - $this->fillSite($site, ['by' => $by]) + $this->fillSite($site, array('by' => $by)) ); } @@ -342,14 +342,14 @@ class WC_Retailcrm_Client_V5 */ public function customersCorporateAddresses( $id, - array $filter = [], + array $filter= array(), $page = null, $limit = null, $by = 'externalId', $site = null ) { $this->checkIdParameter($by); - $parameters = ['by' => $by]; + $parameters = array('by' => $by); if (count($filter)) { $parameters['filter'] = $filter; } @@ -381,13 +381,13 @@ class WC_Retailcrm_Client_V5 * * @return WC_Retailcrm_Response */ - public function customersCorporateAddressesCreate($id, array $address = [], $by = 'externalId', $site = null) + public function customersCorporateAddressesCreate($id, array $address= array(), $by = 'externalId', $site = null) { /* @noinspection PhpUndefinedMethodInspection */ return $this->client->makeRequest( "/customers-corporate/$id/addresses/create", "POST", - $this->fillSite($site, ['address' => json_encode($address), 'by' => $by]) + $this->fillSite($site, array('address' => json_encode($address), 'by' => $by)) ); } @@ -410,7 +410,7 @@ class WC_Retailcrm_Client_V5 public function customersCorporateAddressesEdit( $customerId, $addressId, - array $address = [], + array $address= array(), $customerBy = 'externalId', $addressBy = 'externalId', $site = null @@ -429,11 +429,11 @@ class WC_Retailcrm_Client_V5 return $this->client->makeRequest( "/customers-corporate/$customerId/addresses/$addressId/edit", "POST", - $this->fillSite($site, [ + $this->fillSite($site, array( 'address' => json_encode($address), 'by' => $customerBy, 'entityBy' => $addressBy - ]) + )) ); } @@ -455,14 +455,14 @@ class WC_Retailcrm_Client_V5 */ public function customersCorporateCompanies( $id, - array $filter = [], + array $filter= array(), $page = null, $limit = null, $by = 'externalId', $site = null ) { $this->checkIdParameter($by); - $parameters = ['by' => $by]; + $parameters = array('by' => $by); if (count($filter)) { $parameters['filter'] = $filter; } @@ -494,13 +494,13 @@ class WC_Retailcrm_Client_V5 * * @return WC_Retailcrm_Response */ - public function customersCorporateCompaniesCreate($id, array $company = [], $by = 'externalId', $site = null) + public function customersCorporateCompaniesCreate($id, array $company= array(), $by = 'externalId', $site = null) { /* @noinspection PhpUndefinedMethodInspection */ return $this->client->makeRequest( "/customers-corporate/$id/companies/create", "POST", - $this->fillSite($site, ['company' => json_encode($company), 'by' => $by]) + $this->fillSite($site, array('company' => json_encode($company), 'by' => $by)) ); } @@ -523,7 +523,7 @@ class WC_Retailcrm_Client_V5 public function customersCorporateCompaniesEdit( $customerId, $companyId, - array $company = [], + array $company= array(), $customerBy = 'externalId', $companyBy = 'externalId', $site = null @@ -532,11 +532,11 @@ class WC_Retailcrm_Client_V5 return $this->client->makeRequest( "/customers-corporate/$customerId/companies/$companyId/edit", "POST", - $this->fillSite($site, [ + $this->fillSite($site, array( 'company' => json_encode($company), 'by' => $customerBy, 'entityBy' => $companyBy - ]) + )) ); } @@ -558,14 +558,14 @@ class WC_Retailcrm_Client_V5 */ public function customersCorporateContacts( $id, - array $filter = [], + array $filter= array(), $page = null, $limit = null, $by = 'externalId', $site = null ) { $this->checkIdParameter($by); - $parameters = ['by' => $by]; + $parameters = array('by' => $by); if (count($filter)) { $parameters['filter'] = $filter; } @@ -597,13 +597,13 @@ class WC_Retailcrm_Client_V5 * * @throws InvalidArgumentException */ - public function customersCorporateContactsCreate($id, array $contact = [], $by = 'externalId', $site = null) + public function customersCorporateContactsCreate($id, array $contact= array(), $by = 'externalId', $site = null) { /* @noinspection PhpUndefinedMethodInspection */ return $this->client->makeRequest( "/customers-corporate/$id/contacts/create", "POST", - $this->fillSite($site, ['contact' => json_encode($contact), 'by' => $by]) + $this->fillSite($site, array('contact' => json_encode($contact), 'by' => $by)) ); } @@ -626,7 +626,7 @@ class WC_Retailcrm_Client_V5 public function customersCorporateContactsEdit( $customerId, $contactId, - array $contact = [], + array $contact= array(), $customerBy = 'externalId', $contactBy = 'externalId', $site = null @@ -635,11 +635,11 @@ class WC_Retailcrm_Client_V5 return $this->client->makeRequest( "/customers-corporate/$customerId/contacts/$contactId/edit", "POST", - $this->fillSite($site, [ + $this->fillSite($site, array( 'contact' => json_encode($contact), 'by' => $customerBy, 'entityBy' => $contactBy - ]) + )) ); } @@ -675,7 +675,7 @@ class WC_Retailcrm_Client_V5 "POST", $this->fillSite( $site, - ['customerCorporate' => json_encode($customerCorporate), 'by' => $by] + array('customerCorporate' => json_encode($customerCorporate), 'by' => $by) ) ); } @@ -2976,7 +2976,9 @@ class WC_Retailcrm_Client_V5 */ public function getSingleSiteForKey() { - if (!empty($this->getSite())) { + $site = $this->getSite(); + + if (!empty($site)) { return $this->getSite(); } diff --git a/src/include/class-wc-retailcrm-history.php b/src/include/class-wc-retailcrm-history.php index 0dfbf00..2511de3 100644 --- a/src/include/class-wc-retailcrm-history.php +++ b/src/include/class-wc-retailcrm-history.php @@ -327,7 +327,7 @@ if ( ! class_exists( 'WC_Retailcrm_History' ) ) : */ protected function orderUpdate($order, $options) { - $crmOrder = []; + $crmOrder = array(); $wc_order = wc_get_order($order['externalId']); if (!$wc_order instanceof WC_Order) { @@ -742,9 +742,9 @@ if ( ! class_exists( 'WC_Retailcrm_History' ) ) : */ protected function editOrder($settings, $wc_order, $order, $event = 'create') { - $data = []; - $crmOrder = []; - $order_items = []; + $data= array(); + $crmOrder= array(); + $order_items= array(); if ($event == 'update') { $result = $this->retailcrm->ordersGet($order['externalId']); diff --git a/src/include/class-wc-retailcrm-plugin.php b/src/include/class-wc-retailcrm-plugin.php index a4f3e7d..f66761d 100644 --- a/src/include/class-wc-retailcrm-plugin.php +++ b/src/include/class-wc-retailcrm-plugin.php @@ -146,7 +146,7 @@ class WC_Retailcrm_Plugin { return $arr; } - $result = []; + $result = array(); foreach ($arr as $index => $node) { $result[$index] = (is_array($node)) diff --git a/src/include/customer/class-wc-retailcrm-customer-address.php b/src/include/customer/class-wc-retailcrm-customer-address.php index 69a20c6..88edf00 100644 --- a/src/include/customer/class-wc-retailcrm-customer-address.php +++ b/src/include/customer/class-wc-retailcrm-customer-address.php @@ -24,7 +24,9 @@ class WC_Retailcrm_Customer_Address extends WC_Retailcrm_Abstracts_Address */ public function build($customer, $order = null) { - if ($order instanceof WC_Order && empty($customer->get_billing_address())) { + $customerBillingAddress = $customer->get_billing_address(); + + if ($order instanceof WC_Order && empty($customerBillingAddress)) { $data = array( 'index' => $order->get_billing_postcode(), 'countryIso' => $order->get_billing_country(),