From 2e2c7a9ae8f3a30024fc30d3436f713f06f1c25d Mon Sep 17 00:00:00 2001
From: "Matthew Wire (MJW Consulting)" <mjw@mjwconsult.co.uk>
Date: Thu, 6 Jun 2019 17:47:34 +0100
Subject: [PATCH] Switch to short array syntax and remove support for CiviCRM <
 5.13

---
 CRM/Civicrmpostcodelookup/Form/Setting.php    | 32 ++++++------
 CRM/Civicrmpostcodelookup/Page/Afd.php        | 20 +++-----
 .../Page/Civipostcode.php                     | 20 +++-----
 CRM/Civicrmpostcodelookup/Page/Experian.php   | 27 ++++------
 .../Page/GetAddressIo.php                     | 34 +++++--------
 .../Page/PostcodeAnywhere.php                 | 20 +++-----
 CRM/Civicrmpostcodelookup/Utils.php           | 12 +----
 CRM/PafUtils/Address.php                      | 10 ++--
 civicrmpostcodelookup.civix.php               | 40 +++++++--------
 civicrmpostcodelookup.php                     |  6 +--
 info.xml                                      |  6 +--
 lib/CommonClasses.php                         | 16 +++---
 lib/QASCapture.php                            | 48 +++++++++--------
 .../Form/Postcodelookup.tpl                   | 51 -------------------
 .../Form/Edit/Address/street_address.tpl      | 27 ----------
 15 files changed, 121 insertions(+), 248 deletions(-)

diff --git a/CRM/Civicrmpostcodelookup/Form/Setting.php b/CRM/Civicrmpostcodelookup/Form/Setting.php
index 2a08799..1e9975e 100755
--- a/CRM/Civicrmpostcodelookup/Form/Setting.php
+++ b/CRM/Civicrmpostcodelookup/Form/Setting.php
@@ -28,7 +28,7 @@ class CRM_Civicrmpostcodelookup_Form_Setting extends CRM_Core_Form {
       'text',
       'server',
       ts('Server URL'),
-      array('size' => 50),
+      ['size' => 50],
       true
     );
 
@@ -37,7 +37,7 @@ class CRM_Civicrmpostcodelookup_Form_Setting extends CRM_Core_Form {
       'text',
       'api_key',
       ts('API Key'),
-      array('size' => 50),
+      ['size' => 50],
       false
     );
 
@@ -46,7 +46,7 @@ class CRM_Civicrmpostcodelookup_Form_Setting extends CRM_Core_Form {
       'text',
       'serial_number',
       ts('Serial Number'),
-      array('size' => 20),
+      ['size' => 20],
       false
     );
 
@@ -55,7 +55,7 @@ class CRM_Civicrmpostcodelookup_Form_Setting extends CRM_Core_Form {
       'text',
       'username',
       ts('Username'),
-      array('size' => 20),
+      ['size' => 20],
       false
     );
 
@@ -64,7 +64,7 @@ class CRM_Civicrmpostcodelookup_Form_Setting extends CRM_Core_Form {
       'text',
       'password',
       ts('Password'),
-      array('size' => 20),
+      ['size' => 20],
       false
     );
 
@@ -75,20 +75,20 @@ class CRM_Civicrmpostcodelookup_Form_Setting extends CRM_Core_Form {
       ts('Location Types'),
       $locationTypes,
       NULL, NULL, NULL, NULL,
-      array('&nbsp;&nbsp;')
+      ['&nbsp;&nbsp;']
     );
 
-    $this->addButtons(array(
-      array(
+    $this->addButtons([
+      [
         'type' => 'submit',
         'name' => ts('Submit'),
         'isDefault' => TRUE,
-      ),
-    ));
+      ],
+    ]);
 
     $this->setDefaults($settingsArray);
 
-    $this->addFormRule( array( 'CRM_Civicrmpostcodelookup_Form_Setting', 'formRule' ) );
+    $this->addFormRule( ['CRM_Civicrmpostcodelookup_Form_Setting', 'formRule']);
 
     // export form elements
     $this->assign('elementNames', $this->getRenderableElementNames());
@@ -97,7 +97,7 @@ class CRM_Civicrmpostcodelookup_Form_Setting extends CRM_Core_Form {
 
   static function formRule( $values ){
 
-    $errors = array();
+    $errors = [];
 
     // Server is mandatory fo AFD and CiviPostcode. Server URL is in QAS lib for Experian
     if ($values['provider'] == 'afd' || $values['provider'] == 'civipostcode' || $values['provider'] == 'postcodeanywhere') {
@@ -159,7 +159,7 @@ class CRM_Civicrmpostcodelookup_Form_Setting extends CRM_Core_Form {
   function postProcess() {
     $values = $this->exportValues();
 
-    $settingsArray = array();
+    $settingsArray = [];
     $settingsArray['provider'] = $values['provider'];
 
     // AFD
@@ -211,9 +211,9 @@ class CRM_Civicrmpostcodelookup_Form_Setting extends CRM_Core_Form {
   }
 
   function getProviderOptions() {
-    $options = array(
+    $options = [
         '' => ts('- select -'),
-      ) + $GLOBALS["providers"];
+      ] + $GLOBALS["providers"];
 
     return $options;
   }
@@ -228,7 +228,7 @@ class CRM_Civicrmpostcodelookup_Form_Setting extends CRM_Core_Form {
     // auto-rendered in the loop -- such as "qfKey" and "buttons".  These
     // items don't have labels.  We'll identify renderable by filtering on
     // the 'label'.
-    $elementNames = array();
+    $elementNames = [];
     foreach ($this->_elements as $element) {
       /** @var HTML_QuickForm_Element $element */
       $label = $element->getLabel();
diff --git a/CRM/Civicrmpostcodelookup/Page/Afd.php b/CRM/Civicrmpostcodelookup/Page/Afd.php
index edff2a9..d8d4813 100755
--- a/CRM/Civicrmpostcodelookup/Page/Afd.php
+++ b/CRM/Civicrmpostcodelookup/Page/Afd.php
@@ -63,21 +63,13 @@ class CRM_Civicrmpostcodelookup_Page_Afd extends CRM_Civicrmpostcodelookup_Page_
     ##Close the XML source##
     fclose($filetoparse);
 
-    // Check CiviCRM version & return result as appropriate
-    $civiVersion = CRM_Civicrmpostcodelookup_Utils::getCiviVersion();
-    if ($civiVersion < 4.5) {
-      foreach ($addresslist as $key => $val) {
-        echo "{$val['label']}|{$val['id']}\n";
-      }
-    } else {
-      echo json_encode($addresslist);
-    }
+    echo json_encode($addresslist);
     exit;
   }
 
   private static function getAddressList($simpleXMLData, $postcode) {
-    $addressList = array();
-    $addressRow = array();
+    $addressList = [];
+    $addressRow = [];
     $AddressListItem = $simpleXMLData->AddressListItem;
     foreach ($AddressListItem as $key => $addressItem) {
       $addressRow["id"] = (string) $addressItem->PostKey;
@@ -101,9 +93,9 @@ class CRM_Civicrmpostcodelookup_Page_Afd extends CRM_Civicrmpostcodelookup_Page_
     }
 
     $address = self::getAddressByMoniker($moniker);
-    $response = array(
+    $response = [
       'address' => $address
-    );
+    ];
 
     echo json_encode($response);
     exit;
@@ -122,7 +114,7 @@ class CRM_Civicrmpostcodelookup_Page_Afd extends CRM_Civicrmpostcodelookup_Page_
     $data = stream_get_contents($filetoparse);
     $simpleXMLData = simplexml_load_string($data);
 
-    $address = array('id' => $moniker);
+    $address = ['id' => $moniker];
     $addressItem = (array) $simpleXMLData->Address;
 
     $address["street"] = empty($addressItem['Street']) ? '':$addressItem['Street'];
diff --git a/CRM/Civicrmpostcodelookup/Page/Civipostcode.php b/CRM/Civicrmpostcodelookup/Page/Civipostcode.php
index e47651c..dbdb8c3 100755
--- a/CRM/Civicrmpostcodelookup/Page/Civipostcode.php
+++ b/CRM/Civicrmpostcodelookup/Page/Civipostcode.php
@@ -70,21 +70,13 @@ class CRM_Civicrmpostcodelookup_Page_Civipostcode extends CRM_Civicrmpostcodeloo
     ##Close the JSON source##
     fclose($filetoparse);
 
-    // Check CiviCRM version & return result as appropriate
-    $civiVersion = CRM_Civicrmpostcodelookup_Utils::getCiviVersion();
-    if ($civiVersion < 4.5) {
-      foreach ($addresslist as $key => $val) {
-        echo "{$val['label']}|{$val['id']}\n";
-      }
-    } else {
-      echo json_encode($addresslist);
-    }
+    echo json_encode($addresslist);
     exit;
   }
 
   private static function getAddressList($simpleJSONData, $postcode) {
-    $addressList = array();
-    $addressRow = array();
+    $addressList = [];
+    $addressRow = [];
     $AddressListItem = $simpleJSONData->results;
     foreach ($AddressListItem as $key => $addressItem) {
       $addressLineArray = self::formatAddressLines($addressItem, TRUE);
@@ -116,9 +108,9 @@ class CRM_Civicrmpostcodelookup_Page_Civipostcode extends CRM_Civicrmpostcodeloo
     }
 
     $address = self::getAddressByMoniker($moniker);
-    $response = array(
+    $response = [
       'address' => $address
-    );
+    ];
 
     echo json_encode($response);
     exit;
@@ -173,7 +165,7 @@ class CRM_Civicrmpostcodelookup_Page_Civipostcode extends CRM_Civicrmpostcodeloo
     $addressLines = $addressLineObj->getAddressLines();
 
     if ($forList == FALSE) {
-      $address = array('id' => $addressObj->id);
+      $address = ['id' => $addressObj->id];
     }
 
     if (!empty($addressLines[0])) {
diff --git a/CRM/Civicrmpostcodelookup/Page/Experian.php b/CRM/Civicrmpostcodelookup/Page/Experian.php
index 94564c2..7a6c613 100755
--- a/CRM/Civicrmpostcodelookup/Page/Experian.php
+++ b/CRM/Civicrmpostcodelookup/Page/Experian.php
@@ -9,7 +9,7 @@ class CRM_PostcodeLookup_Page_Ajax extends CRM_Civicrmpostcodelookup_Page_Postco
   static private $qacampture;
 
   public static function getQasCredentials($account_type) {
-    $credentials = array();
+    $credentials = [];
 
     $settingsStr = CRM_Core_BAO_Setting::getItem('CiviCRM Postcode Lookup', 'api_details');
     $settingsArray = unserialize($settingsStr);
@@ -52,13 +52,13 @@ class CRM_PostcodeLookup_Page_Ajax extends CRM_Civicrmpostcodelookup_Page_Postco
     $qaCapture = self::getQACapture();
     $ret = $qaCapture->Search("$number, $postcode", 'GBR', 'Singleline', true);//, $intensity, $promptset, $threshold, $timeout, $layout, $formattedAddressInPicklist, $requestTag, $localisation)
 
-    $response = array();
-    $response['items'] = array();
+    $response = [];
+    $response['items'] = [];
     foreach($ret->Picklist->Items as $item) {
-      $response['items'][] = array(
+      $response['items'][] = [
         'id' => $item->Moniker,
         'label' => $item->PartialAddress,
-      );
+      ];
     }
 
     //mzeman: get the address details if it's the precise one
@@ -69,16 +69,7 @@ class CRM_PostcodeLookup_Page_Ajax extends CRM_Civicrmpostcodelookup_Page_Postco
       $response['address'] = $address;
     }
 
-    // Check CiviCRM version & return result as appropriate
-    $civiVersion = CRM_Civicrmpostcodelookup_Utils::getCiviVersion();
-    if ($civiVersion < 4.5) {
-      foreach ($response as $key => $val) {
-        echo "{$val['label']}|{$val['id']}\n";
-      }
-    } else {
-      echo json_encode($response);
-    }
-
+    echo json_encode($response);
     exit;
   }
 
@@ -89,9 +80,9 @@ class CRM_PostcodeLookup_Page_Ajax extends CRM_Civicrmpostcodelookup_Page_Postco
     }
 
     $address = self::getAddressByMoniker($moniker);
-    $response = array(
+    $response = [
       'address' => $address
-    );
+    ];
 
     echo json_encode($response);
     exit;
@@ -114,7 +105,7 @@ class CRM_PostcodeLookup_Page_Ajax extends CRM_Civicrmpostcodelookup_Page_Postco
   private static function getAddressByMoniker($moniker) {
     $addressRet = self::getQACapture()->GetAddress($moniker);
 
-    $address = array('id' => $moniker);
+    $address = ['id' => $moniker];
     $lineCounter = 0;
     foreach($addressRet->AddressLines as $line) {
       switch($line->Label) {
diff --git a/CRM/Civicrmpostcodelookup/Page/GetAddressIo.php b/CRM/Civicrmpostcodelookup/Page/GetAddressIo.php
index 3dcfcdc..2bc6015 100644
--- a/CRM/Civicrmpostcodelookup/Page/GetAddressIo.php
+++ b/CRM/Civicrmpostcodelookup/Page/GetAddressIo.php
@@ -3,7 +3,7 @@
 class CRM_Civicrmpostcodelookup_Page_GetAddressIo extends CRM_Civicrmpostcodelookup_Page_Postcode {
 
   public static function isValidPostcode($postcode) {
-    if (in_array($postcode, array('XX200X', 'XX404X', 'XX400X', 'XX401X', 'XX429X', 'XX500X'))) {
+    if (in_array($postcode, ['XX200X', 'XX404X', 'XX400X', 'XX401X', 'XX429X', 'XX500X'])) {
       // A getAddressIo test postcode
       return TRUE;
     }
@@ -23,7 +23,7 @@ class CRM_Civicrmpostcodelookup_Page_GetAddressIo extends CRM_Civicrmpostcodeloo
     // get address result from getAddress.io
     $addressData = self::addressAPIResult($apiUrl);
 
-    $addresslist = array();
+    $addresslist = [];
     if ($addressData['is_error']) {
       $addresslist[0]['value'] = '';
       $addresslist[0]['label'] = CRM_Utils_Array::value('Message', $addressData, 'Error in fetching address');
@@ -31,15 +31,7 @@ class CRM_Civicrmpostcodelookup_Page_GetAddressIo extends CRM_Civicrmpostcodeloo
       $addresslist = self::getAddressList($addressData, $postcode);
     }
 
-    // Check CiviCRM version & return result as appropriate
-    $civiVersion = CRM_Civicrmpostcodelookup_Utils::getCiviVersion();
-    if ($civiVersion < 4.5) {
-      foreach ($addresslist as $key => $val) {
-        echo "{$val['label']}|{$val['id']}\n";
-      }
-    } else {
-      echo json_encode($addresslist);
-    }
+    echo json_encode($addresslist);
     exit;
   }
 
@@ -62,9 +54,9 @@ class CRM_Civicrmpostcodelookup_Page_GetAddressIo extends CRM_Civicrmpostcodeloo
     // get address result from getAddress.io
     $addressData = self::addressAPIResult($apiUrl);
 
-    $addresslist = array();
+    $addresslist = [];
     if ($addressData['is_error']) {
-      $address = array();
+      $address = [];
     } else {
       $addressItems = $addressData['addresses'];
 
@@ -76,9 +68,9 @@ class CRM_Civicrmpostcodelookup_Page_GetAddressIo extends CRM_Civicrmpostcodeloo
       $address['postcode'] = $postcode;
     }
 
-    $response = array(
+    $response = [
       'address' => $address
-    );
+    ];
 
     echo json_encode($response);
     exit;
@@ -123,7 +115,7 @@ class CRM_Civicrmpostcodelookup_Page_GetAddressIo extends CRM_Civicrmpostcodeloo
    * @return array
    */
   private static function addressAPIResult($apiUrl) {
-    $addressData = array();
+    $addressData = [];
 
     if (empty($apiUrl)) {
       $addressData['is_error'] = 1;
@@ -133,11 +125,11 @@ class CRM_Civicrmpostcodelookup_Page_GetAddressIo extends CRM_Civicrmpostcodeloo
 
     // Get the Address Data
     $curlSession = curl_init();
-    curl_setopt_array($curlSession, array(
+    curl_setopt_array($curlSession, [
       CURLOPT_RETURNTRANSFER => 1,
       CURLOPT_URL => $apiUrl,
       CURLOPT_USERAGENT => 'CiviCRM'
-    ));
+    ]);
 
     $result = curl_exec($curlSession);
     $header = curl_getinfo($curlSession);
@@ -190,8 +182,8 @@ class CRM_Civicrmpostcodelookup_Page_GetAddressIo extends CRM_Civicrmpostcodeloo
    * @return array
    */
   private static function getAddressList($addressData, $postcode) {
-    $addressList = array();
-    $addressRow = array();
+    $addressList = [];
+    $addressRow = [];
 
     // return, if adddressData/postcode is empty
     if (empty($addressData) || empty($postcode)) {
@@ -236,7 +228,7 @@ class CRM_Civicrmpostcodelookup_Page_GetAddressIo extends CRM_Civicrmpostcodeloo
     $addressLines = explode(', ', $addressItem);
 
     if ($forList == FALSE) {
-      $address = array('id' => $addressId);
+      $address = ['id' => $addressId];
     }
     if (!empty($addressLines[0])) {
       $address["street_address"] = $addressLines[0];
diff --git a/CRM/Civicrmpostcodelookup/Page/PostcodeAnywhere.php b/CRM/Civicrmpostcodelookup/Page/PostcodeAnywhere.php
index 2631d2f..ddcf92e 100755
--- a/CRM/Civicrmpostcodelookup/Page/PostcodeAnywhere.php
+++ b/CRM/Civicrmpostcodelookup/Page/PostcodeAnywhere.php
@@ -54,21 +54,13 @@ class CRM_Civicrmpostcodelookup_Page_PostcodeAnywhere extends CRM_Civicrmpostcod
       $addresslist = self::getAddressList($simpleXMLData, $postcode);
     }
 
-    // Check CiviCRM version & return result as appropriate
-    $civiVersion = CRM_Civicrmpostcodelookup_Utils::getCiviVersion();
-    if ($civiVersion < 4.5) {
-      foreach ($addresslist as $key => $val) {
-        echo "{$val['label']}|{$val['id']}\n";
-      }
-    } else {
-      echo json_encode($addresslist);
-    }
+    echo json_encode($addresslist);
     exit;
   }
 
   private static function getAddressList($simpleXMLData, $postcode) {
-    $addressList = array();
-    $addressRow = array();
+    $addressList = [];
+    $addressRow = [];
     $AddressListItem = (array) $simpleXMLData->Rows;
     $AddressListItems = $AddressListItem['Row'];
 
@@ -103,9 +95,9 @@ class CRM_Civicrmpostcodelookup_Page_PostcodeAnywhere extends CRM_Civicrmpostcod
     }
 
     $address = self::getAddressByMoniker($moniker);
-    $response = array(
+    $response = [
       'address' => $address
-    );
+    ];
 
     echo json_encode($response);
     exit;
@@ -122,7 +114,7 @@ class CRM_Civicrmpostcodelookup_Page_PostcodeAnywhere extends CRM_Civicrmpostcod
     //Make the request to Postcode Anywhere and parse the XML returned
     $simpleXMLData = simplexml_load_file($querystring);
 
-    $address = array('id' => $moniker);
+    $address = ['id' => $moniker];
     $addressItemRow = (array) $simpleXMLData->Rows;
     $addressItem = (array) $addressItemRow['Row'];
 
diff --git a/CRM/Civicrmpostcodelookup/Utils.php b/CRM/Civicrmpostcodelookup/Utils.php
index cf3ad47..bbc1929 100755
--- a/CRM/Civicrmpostcodelookup/Utils.php
+++ b/CRM/Civicrmpostcodelookup/Utils.php
@@ -50,7 +50,7 @@ class CRM_Civicrmpostcodelookup_Utils {
     for($row = 0; $row < $rows; $row++) {
 
       $label = $a_json[$row]["label"];
-      $a_label_match = array();
+      $a_label_match = [];
 
       for($i = 0; $i < $p; $i++) {
 
@@ -103,14 +103,4 @@ class CRM_Civicrmpostcodelookup_Utils {
     return $a_json;
   }
 
-  /*
-   * Get CiviCRM version using SQL
-   * Using function to get version is not compatible with all versions
-   */
-  public static function getCiviVersion() {
-    $sql = "SELECT version FROM civicrm_domain";
-    $dao = CRM_Core_DAO::executeQuery($sql);
-    $dao->fetch();
-    return $dao->version;
-  }
 }
diff --git a/CRM/PafUtils/Address.php b/CRM/PafUtils/Address.php
index 0d0c5fd..923b198 100644
--- a/CRM/PafUtils/Address.php
+++ b/CRM/PafUtils/Address.php
@@ -37,7 +37,7 @@ class Address
 
   protected $addressLines = null;
 
-  protected $assembleDebugFlags = array();
+  protected $assembleDebugFlags = [];
 
 
   public function __construct()
@@ -398,10 +398,10 @@ class Address
    */
   protected function assembleAddressLines()
   {
-    $this->assembleDebugFlags = array('errors' => array());
+    $this->assembleDebugFlags = ['errors' => []];
     $processed = false;
     $processingError = false;
-    $addressLines = array();
+    $addressLines = [];
 
     // Take copies of the building name and number
     // This allows us to manipulate their values (specifically for the split building name rules)
@@ -413,7 +413,7 @@ class Address
     }
 
     // Exception 4 regex: Any of the specified prefixes followed by either a number with an alpha suffix or a numeric range
-    $specialPrefixes = array(
+    $specialPrefixes = [
       'Back of',
       'Block',
       'Blocks',
@@ -429,7 +429,7 @@ class Address
       'Suites',
       'Unit',
       'Units',
-    );
+    ];
     $ex4Regex = '/^(' . join('|', $specialPrefixes) . ')\s([0-9]+[a-zA-Z]+|[0-9]+\-[0-9]+|[a-zA-Z])$/';
 
     if (strlen($buildingName)) {
diff --git a/civicrmpostcodelookup.civix.php b/civicrmpostcodelookup.civix.php
index 0af5a8b..0a50fbe 100755
--- a/civicrmpostcodelookup.civix.php
+++ b/civicrmpostcodelookup.civix.php
@@ -24,9 +24,9 @@ class CRM_Civicrmpostcodelookup_ExtensionUtil {
    *   Translated text.
    * @see ts
    */
-  public static function ts($text, $params = array()) {
+  public static function ts($text, $params = []) {
     if (!array_key_exists('domain', $params)) {
-      $params['domain'] = array(self::LONG_NAME, NULL);
+      $params['domain'] = [self::LONG_NAME, NULL];
     }
     return ts($text, $params);
   }
@@ -100,7 +100,7 @@ function _civicrmpostcodelookup_civix_civicrm_config(&$config = NULL) {
     array_unshift($template->template_dir, $extDir);
   }
   else {
-    $template->template_dir = array($extDir, $template->template_dir);
+    $template->template_dir = [$extDir, $template->template_dir];
   }
 
   $include_path = $extRoot . PATH_SEPARATOR . get_include_path();
@@ -140,7 +140,7 @@ function _civicrmpostcodelookup_civix_civicrm_install() {
 function _civicrmpostcodelookup_civix_civicrm_postInstall() {
   _civicrmpostcodelookup_civix_civicrm_config();
   if ($upgrader = _civicrmpostcodelookup_civix_upgrader()) {
-    if (is_callable(array($upgrader, 'onPostInstall'))) {
+    if (is_callable([$upgrader, 'onPostInstall'])) {
       $upgrader->onPostInstall();
     }
   }
@@ -166,7 +166,7 @@ function _civicrmpostcodelookup_civix_civicrm_uninstall() {
 function _civicrmpostcodelookup_civix_civicrm_enable() {
   _civicrmpostcodelookup_civix_civicrm_config();
   if ($upgrader = _civicrmpostcodelookup_civix_upgrader()) {
-    if (is_callable(array($upgrader, 'onEnable'))) {
+    if (is_callable([$upgrader, 'onEnable'])) {
       $upgrader->onEnable();
     }
   }
@@ -181,7 +181,7 @@ function _civicrmpostcodelookup_civix_civicrm_enable() {
 function _civicrmpostcodelookup_civix_civicrm_disable() {
   _civicrmpostcodelookup_civix_civicrm_config();
   if ($upgrader = _civicrmpostcodelookup_civix_upgrader()) {
-    if (is_callable(array($upgrader, 'onDisable'))) {
+    if (is_callable([$upgrader, 'onDisable'])) {
       $upgrader->onDisable();
     }
   }
@@ -227,12 +227,12 @@ function _civicrmpostcodelookup_civix_upgrader() {
  * @return array(string)
  */
 function _civicrmpostcodelookup_civix_find_files($dir, $pattern) {
-  if (is_callable(array('CRM_Utils_File', 'findFiles'))) {
+  if (is_callable(['CRM_Utils_File', 'findFiles'])) {
     return CRM_Utils_File::findFiles($dir, $pattern);
   }
 
-  $todos = array($dir);
-  $result = array();
+  $todos = [$dir];
+  $result = [];
   while (!empty($todos)) {
     $subdir = array_shift($todos);
     foreach (_civicrmpostcodelookup_civix_glob("$subdir/$pattern") as $match) {
@@ -299,11 +299,11 @@ function _civicrmpostcodelookup_civix_civicrm_caseTypes(&$caseTypes) {
       CRM_Core_Error::fatal($errorMessage);
       // throw new CRM_Core_Exception($errorMessage);
     }
-    $caseTypes[$name] = array(
+    $caseTypes[$name] = [
       'module' => E::LONG_NAME,
       'name' => $name,
       'file' => $file,
-    );
+    ];
   }
 }
 
@@ -346,7 +346,7 @@ function _civicrmpostcodelookup_civix_civicrm_angularModules(&$angularModules) {
  */
 function _civicrmpostcodelookup_civix_glob($pattern) {
   $result = glob($pattern);
-  return is_array($result) ? $result : array();
+  return is_array($result) ? $result : [];
 }
 
 /**
@@ -361,12 +361,12 @@ function _civicrmpostcodelookup_civix_glob($pattern) {
 function _civicrmpostcodelookup_civix_insert_navigation_menu(&$menu, $path, $item) {
   // If we are done going down the path, insert menu
   if (empty($path)) {
-    $menu[] = array(
-      'attributes' => array_merge(array(
+    $menu[] = [
+      'attributes' => array_merge([
         'label'      => CRM_Utils_Array::value('name', $item),
         'active'     => 1,
-      ), $item),
-    );
+      ], $item),
+    ];
     return TRUE;
   }
   else {
@@ -377,7 +377,7 @@ function _civicrmpostcodelookup_civix_insert_navigation_menu(&$menu, $path, $ite
     foreach ($menu as $key => &$entry) {
       if ($entry['attributes']['name'] == $first) {
         if (!isset($entry['child'])) {
-          $entry['child'] = array();
+          $entry['child'] = [];
         }
         $found = _civicrmpostcodelookup_civix_insert_navigation_menu($entry['child'], implode('/', $path), $item, $key);
       }
@@ -390,7 +390,7 @@ function _civicrmpostcodelookup_civix_insert_navigation_menu(&$menu, $path, $ite
  * (Delegated) Implements hook_civicrm_navigationMenu().
  */
 function _civicrmpostcodelookup_civix_navigationMenu(&$nodes) {
-  if (!is_callable(array('CRM_Core_BAO_Navigation', 'fixNavigationMenu'))) {
+  if (!is_callable(['CRM_Core_BAO_Navigation', 'fixNavigationMenu'])) {
     _civicrmpostcodelookup_civix_fixNavigationMenu($nodes);
   }
 }
@@ -456,6 +456,6 @@ function _civicrmpostcodelookup_civix_civicrm_alterSettingsFolders(&$metaDataFol
  */
 
 function _civicrmpostcodelookup_civix_civicrm_entityTypes(&$entityTypes) {
-  $entityTypes = array_merge($entityTypes, array (
-  ));
+  $entityTypes = array_merge($entityTypes, [
+  ]);
 }
diff --git a/civicrmpostcodelookup.php b/civicrmpostcodelookup.php
index f1f53c6..c3a9e15 100755
--- a/civicrmpostcodelookup.php
+++ b/civicrmpostcodelookup.php
@@ -1,7 +1,7 @@
 <?php
 
 require_once 'civicrmpostcodelookup.civix.php';
-use CRM_Civigiftaid_ExtensionUtil as E;
+use CRM_Civicrmpostcodelookup_ExtensionUtil as E;
 
 // Postcode lookup providers
 // FIXME: Move this list to option values
@@ -159,10 +159,6 @@ function civicrmpostcodelookup_civicrm_buildForm($formName, &$form) {
       $form->assign('civiPostCodeLookupLocationTypeJson', json_encode($settingsArray['location_type_id']));
     }
 
-    // Get CiviCRM version
-    $civiVersion = CRM_Civicrmpostcodelookup_Utils::getCiviVersion();
-    $form->assign('civiVersion', $civiVersion);
-
     CRM_Core_Resources::singleton()
       ->addScriptFile(E::LONG_NAME, 'js/jquery.ui.autocomplete.html.js', 110, 'html-header', FALSE)
       ->addStyleFile(E::LONG_NAME, 'css/civipostcode.css', 110, 'page-header');
diff --git a/info.xml b/info.xml
index 3e9ea1e..d1041a1 100755
--- a/info.xml
+++ b/info.xml
@@ -14,11 +14,11 @@
     <url desc="Support">https://github.com/veda-consulting/uk.co.vedaconsulting.module.civicrmpostcodelookup</url>
     <url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
   </urls>
-  <releaseDate>2018-11-28</releaseDate>
-  <version>1.6</version>
+  <releaseDate>2019-06-06</releaseDate>
+  <version>1.7</version>
   <develStage>stable</develStage>
   <compatibility>
-    <ver>5.3</ver>
+    <ver>5.13</ver>
   </compatibility>
   <comments>Developed by Veda NFP Consulting LTD.</comments>
   <civix>
diff --git a/lib/CommonClasses.php b/lib/CommonClasses.php
index d79a40d..9e37f21 100755
--- a/lib/CommonClasses.php
+++ b/lib/CommonClasses.php
@@ -58,7 +58,7 @@ class AddressLine
 
 		{
 
-			$this->DataplusGroup = array();
+			$this->DataplusGroup = [];
 
 			if (is_array($result->DataplusGroup))
 
@@ -252,7 +252,7 @@ class Dataset
 
 	{
 
-		$aResults = array();
+		$aResults = [];
 
 		
 
@@ -348,7 +348,7 @@ class ExampleAddress
 
 	{
 
-		$aResults = array();
+		$aResults = [];
 
 		
 
@@ -436,7 +436,7 @@ class FormattedAddress
 
 		{
 
-			$this->AddressLines = array();
+			$this->AddressLines = [];
 
 			if (is_array($result->AddressLine))
 
@@ -522,7 +522,7 @@ class Layout
 
 	{
 
-		$aResults = array();
+		$aResults = [];
 
 		
 
@@ -654,7 +654,7 @@ class LicensedSet
 
 	{
 
-		$aResults = array();
+		$aResults = [];
 
 		
 
@@ -780,7 +780,7 @@ class Picklist
 
 		{
 
-			$this->Items = array();
+			$this->Items = [];
 
 			if (is_array($results->PicklistEntry))
 
@@ -1014,7 +1014,7 @@ class PromptSet
 
 		{
 
-			$this->Lines = array();
+			$this->Lines = [];
 
 			if (is_array($results->Line))
 
diff --git a/lib/QASCapture.php b/lib/QASCapture.php
index a73bb55..cc25675 100755
--- a/lib/QASCapture.php
+++ b/lib/QASCapture.php
@@ -89,13 +89,16 @@ class QASCapture implements IQASCapture
 
 			$this->soap = new SoapClient($this->wsdl_file_url, 
 
-										 array('soap_version' => SOAP_1_2,
+										 [
+                       'soap_version' => SOAP_1_2,
 
 												 'exceptions' => 0,
 
-												 'classmap' => array('QAAuthentication' => 'QAAuthentication',
+												 'classmap' => [
+                           'QAAuthentication' => 'QAAuthentication',
 
-												 				     'QAQueryHeader' => 'QAQueryHeader'),
+												 				     'QAQueryHeader' => 'QAQueryHeader'
+                         ],
 
 												 'proxy_host' => CONTROL_PROXY_NAME,
 
@@ -105,7 +108,7 @@ class QASCapture implements IQASCapture
 
 												 'proxy_password' => CONTROL_PROXY_PASSWORD
 
-											   )
+                     ]
 
 										 );
 
@@ -117,15 +120,18 @@ class QASCapture implements IQASCapture
 
 			$this->soap = new SoapClient($this->wsdl_file_url, 
 
-										 array('soap_version' => SOAP_1_2,
+										 [
+                       'soap_version' => SOAP_1_2,
 
 												 'exceptions' => 0,
 
-												 'classmap' => array('QAAuthentication' => 'QAAuthentication',
+												 'classmap' => [
+                           'QAAuthentication' => 'QAAuthentication',
 
-												 				     'QAQueryHeader' => 'QAQueryHeader')
+												 				     'QAQueryHeader' => 'QAQueryHeader'
+                         ]
 
-											  )
+                     ]
 
 										 );			
 
@@ -163,7 +169,7 @@ class QASCapture implements IQASCapture
 
 		
 
-		$this->soap->__setSoapHeaders(array($authHeader));
+		$this->soap->__setSoapHeaders([$authHeader]);
 
 	}
 
@@ -223,7 +229,7 @@ class QASCapture implements IQASCapture
 
 	{
 
-		$engineOptions = array("_" => $engine, self::PARAM_FLATTEN => $flatten);
+		$engineOptions = ["_" => $engine, self::PARAM_FLATTEN => $flatten];
 
 		
 
@@ -257,7 +263,7 @@ class QASCapture implements IQASCapture
 
 		
 
-		$args = array(self::PARAM_COUNTRY => $countryId, self::PARAM_SEARCH => $search, self::PARAM_ENGINE => $engineOptions);
+		$args = [self::PARAM_COUNTRY => $countryId, self::PARAM_SEARCH => $search, self::PARAM_ENGINE => $engineOptions];
 
 		
 
@@ -315,7 +321,7 @@ class QASCapture implements IQASCapture
 
 	{
 
-		$args = array(self::PARAM_MONIKER => $moniker, self::PARAM_REFINEMENT => $refinement);
+		$args = [self::PARAM_MONIKER => $moniker, self::PARAM_REFINEMENT => $refinement];
 
 		
 
@@ -383,7 +389,7 @@ class QASCapture implements IQASCapture
 
 	{
 
-		$args = array(self::PARAM_LAYOUT => $layout, self::PARAM_MONIKER => $moniker);
+		$args = [self::PARAM_LAYOUT => $layout, self::PARAM_MONIKER => $moniker];
 
 		
 
@@ -487,7 +493,7 @@ class QASCapture implements IQASCapture
 
 			{
 
-				return array($result->LicensedSet);
+				return [$result->LicensedSet];
 
 			}
 
@@ -533,7 +539,7 @@ class QASCapture implements IQASCapture
 
 			{
 
-				return array($result->SystemInfo);
+				return [$result->SystemInfo];
 
 			}
 
@@ -557,7 +563,7 @@ class QASCapture implements IQASCapture
 
 	{
 
-		$args = array(self::PARAM_COUNTRY => $countryId);
+		$args = [self::PARAM_COUNTRY => $countryId];
 
 		
 
@@ -595,7 +601,7 @@ class QASCapture implements IQASCapture
 
 	{
 
-		$args = array(self::PARAM_COUNTRY => $countryId, self::PARAM_LAYOUT => $layout);
+		$args = [self::PARAM_COUNTRY => $countryId, self::PARAM_LAYOUT => $layout];
 
 		
 
@@ -645,7 +651,7 @@ class QASCapture implements IQASCapture
 
 	{
 
-		$args = array(self::PARAM_COUNTRY => $countryId);
+		$args = [self::PARAM_COUNTRY => $countryId];
 
 		
 
@@ -683,7 +689,7 @@ class QASCapture implements IQASCapture
 
 	{	
 
-		$args = array(self::PARAM_COUNTRY => $countryId, self::PARAM_PROMPTSET => $promptset, self::PARAM_ENGINE => $engine);
+		$args = [self::PARAM_COUNTRY => $countryId, self::PARAM_PROMPTSET => $promptset, self::PARAM_ENGINE => $engine];
 
 		
 
@@ -721,11 +727,11 @@ class QASCapture implements IQASCapture
 
 	{
 
-		$engineOptions = array("_" => $engine, self::PARAM_FLATTEN => $flatten, self::PARAM_PROMPTSET => $promptset);
+		$engineOptions = ["_" => $engine, self::PARAM_FLATTEN => $flatten, self::PARAM_PROMPTSET => $promptset];
 
 		
 
-		$args = array(self::PARAM_COUNTRY => $countryId, self::PARAM_ENGINE => $engineOptions, self::PARAM_FLATTEN => $flatten);
+		$args = [self::PARAM_COUNTRY => $countryId, self::PARAM_ENGINE => $engineOptions, self::PARAM_FLATTEN => $flatten];
 
 		
 
diff --git a/templates/CRM/Civicrmpostcodelookup/Form/Postcodelookup.tpl b/templates/CRM/Civicrmpostcodelookup/Form/Postcodelookup.tpl
index 18e64ad..d477f2d 100755
--- a/templates/CRM/Civicrmpostcodelookup/Form/Postcodelookup.tpl
+++ b/templates/CRM/Civicrmpostcodelookup/Form/Postcodelookup.tpl
@@ -66,55 +66,6 @@
     cj(function() {
       var sourceUrl = CRM.url('civicrm/{/literal}{$civiPostCodeLookupProvider}{literal}/ajax/search', {"json": 1});
 
-      {/literal}{if $civiVersion < 4.5}{literal}
-
-      cj( postcodeElement ).autocomplete( sourceUrl, {
-        width: 400,
-        selectFirst: false,
-        minChars: minCharacters,
-        matchContains: true,
-        delay: delay,
-        max: 1000,
-        extraParams:{
-          term:function () {
-            return cj( postcodeElement ).val();
-          },
-          number:function () {
-            return cj(houseElement).val();
-          }
-        }
-      }).result(function(event, data, formatted) {
-        findAddressValues(data[1], blockNo, blockPrefix = '');
-        cj(postcodeElement).val('');
-        return false;
-      });
-
-      // Postcode lookup in billing section
-      if (cj('#billing_street_address-5').length > 0 ) {
-        cj( billingPostcodeElement ).autocomplete( sourceUrl, {
-          width: 400,
-          selectFirst: false,
-          minChars: minCharacters,
-          matchContains: true,
-          delay: delay,
-          max: 1000,
-          extraParams:{
-            term:function () {
-              return cj( billingPostcodeElement ).val();
-            },
-            number:function () {
-              return cj(houseElement).val();
-            }
-          }
-        }).result(function(event, data, formatted) {
-          findAddressValues(data[1], '5', blockPrefix = 'billing_');
-          cj(billingPostcodeElement).val('');
-          return false;
-        });
-      }
-
-      {/literal}{else}{literal}
-
       cj(postcodeElement).autocomplete({
         source: sourceUrl,
         minLength: minCharacters,
@@ -170,8 +121,6 @@
         });
       }
 
-      {/literal}{/if}{literal}
-
     });
   });
 
diff --git a/templates/CRM/Contact/Form/Edit/Address/street_address.tpl b/templates/CRM/Contact/Form/Edit/Address/street_address.tpl
index 152a3e1..2087880 100755
--- a/templates/CRM/Contact/Form/Edit/Address/street_address.tpl
+++ b/templates/CRM/Contact/Form/Edit/Address/street_address.tpl
@@ -57,31 +57,6 @@
     cj(function() {
       var sourceUrl = CRM.url('civicrm/{/literal}{$civiPostCodeLookupProvider}{literal}/ajax/search', {"json": 1});
 
-      {/literal}{if $civiVersion < 4.5}{literal}
-
-      cj( postcodeElement ).autocomplete( sourceUrl, {
-        width: 400,
-        selectFirst: false,
-        minChars: minCharacters,
-        matchContains: true,
-        delay: delay,
-        max: 1000,
-        extraParams:{
-          term:function () {
-            return  cj( postcodeElement ).val();
-          },
-          number:function () {
-            return cj(houseElement).val();
-          }
-        }
-      }).result(function(event, data, formatted) {
-        findAddressValues(data[1], blockNo);
-        cj(postcodeElement).val('');
-        return false;
-      });
-
-      {/literal}{else}{literal}
-
       cj(postcodeElement).autocomplete({
         source: sourceUrl,
         minLength: minCharacters,
@@ -110,8 +85,6 @@
         }
       });
 
-      {/literal}{/if}{literal}
-
     });
   });
 
-- 
GitLab