Merge pull request #15820 from seamuslee001/dev_core_183_custom_contribsybnt
[civicrm-core.git] / CRM / Contact / BAO / ProximityQuery.php
index 7ee0be7ad9886e7574256e6b3b664c41c594a04f..8119557cd02ebe6e5ee7459512192112c7264b87 100644 (file)
@@ -1,34 +1,18 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 5                                                  |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019                                |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM.                                    |
- |                                                                    |
- | CiviCRM is free software; you can copy, modify, and distribute it  |
- | under the terms of the GNU Affero General Public License           |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
+ | Copyright CiviCRM LLC. All rights reserved.                        |
  |                                                                    |
- | CiviCRM is distributed in the hope that it will be useful, but     |
- | WITHOUT ANY WARRANTY; without even the implied warranty of         |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
- | See the GNU Affero General Public License for more details.        |
- |                                                                    |
- | You should have received a copy of the GNU Affero General Public   |
- | License and the CiviCRM Licensing Exception along                  |
- | with this program; if not, contact CiviCRM LLC                     |
- | at info[AT]civicrm[DOT]org. If you have questions about the        |
- | GNU Affero General Public License or the licensing of CiviCRM,     |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
+ | This work is published under the GNU AGPLv3 license with some      |
+ | permitted exceptions and without any warranty. For full license    |
+ | and copyright information, see https://civicrm.org/licensing       |
  +--------------------------------------------------------------------+
  */
 
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2019
+ * @copyright CiviCRM LLC https://civicrm.org/licensing
  */
 class CRM_Contact_BAO_ProximityQuery {
 
@@ -50,6 +34,9 @@ class CRM_Contact_BAO_ProximityQuery {
    * This version has been taken from Drupal's location module: http://drupal.org/project/location
    */
 
+  /**
+   * @var string
+   */
   static protected $_earthFlattening;
   static protected $_earthRadiusSemiMinor;
   static protected $_earthRadiusSemiMajor;
@@ -114,7 +101,7 @@ class CRM_Contact_BAO_ProximityQuery {
     $y = ($radius + $height) * $cosLat * $sinLong;
     $z = ($radius * (1 - self::$_earthEccentricitySQ) + $height) * $sinLat;
 
-    return array($x, $y, $z);
+    return [$x, $y, $z];
   }
 
   /**
@@ -154,10 +141,10 @@ class CRM_Contact_BAO_ProximityQuery {
       $maxLong = $maxLong - pi() * 2;
     }
 
-    return array(
+    return [
       rad2deg($minLong),
       rad2deg($maxLong),
-    );
+    ];
   }
 
   /**
@@ -198,10 +185,10 @@ class CRM_Contact_BAO_ProximityQuery {
       $maxLat = $rightangle;
     }
 
-    return array(
+    return [
       rad2deg($minLat),
       rad2deg($maxLat),
-    );
+    ];
   }
 
   /**
@@ -215,15 +202,15 @@ class CRM_Contact_BAO_ProximityQuery {
   public static function where($latitude, $longitude, $distance, $tablePrefix = 'civicrm_address') {
     self::initialize();
 
-    $params = array();
-    $clause = array();
+    $params = [];
+    $clause = [];
 
     list($minLongitude, $maxLongitude) = self::earthLongitudeRange($longitude, $latitude, $distance);
     list($minLatitude, $maxLatitude) = self::earthLatitudeRange($longitude, $latitude, $distance);
 
     // DONT consider NAN values (which is returned by rad2deg php function)
     // for checking BETWEEN geo_code's criteria as it throws obvious 'NAN' field not found DB: Error
-    $geoCodeWhere = array();
+    $geoCodeWhere = [];
     if (!is_nan($minLatitude)) {
       $geoCodeWhere[] = "{$tablePrefix}.geo_code_1  >= $minLatitude ";
     }
@@ -264,7 +251,7 @@ ACOS(
     list($name, $op, $distance, $grouping, $wildcard) = $values;
 
     // also get values array for all address related info
-    $proximityVars = array(
+    $proximityVars = [
       'street_address' => 1,
       'city' => 1,
       'postal_code' => 1,
@@ -275,10 +262,10 @@ ACOS(
       'distance_unit' => 0,
       'geo_code_1' => 0,
       'geo_code_2' => 0,
-    );
+    ];
 
-    $proximityAddress = array();
-    $qill = array();
+    $proximityAddress = [];
+    $qill = [];
     foreach ($proximityVars as $var => $recordQill) {
       $proximityValues = $query->getWhereValues("prox_{$var}", $grouping);
       if (!empty($proximityValues) &&
@@ -329,10 +316,10 @@ ACOS(
     }
 
     $qill = ts('Proximity search to a distance of %1 from %2',
-      array(
+      [
         1 => $qillUnits,
         2 => implode(', ', $qill),
-      )
+      ]
     );
 
     $query->_tables['civicrm_address'] = $query->_whereTables['civicrm_address'] = 1;
@@ -374,7 +361,7 @@ ACOS(
     foreach ($input as $param) {
       if (CRM_Utils_Array::value('0', $param) == 'prox_distance') {
         // add prox_ prefix to these
-        $param_alter = array('street_address', 'city', 'postal_code', 'state_province', 'country');
+        $param_alter = ['street_address', 'city', 'postal_code', 'state_province', 'country'];
 
         foreach ($input as $key => $_param) {
           if (in_array($_param[0], $param_alter)) {