X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FUtils%2FAddress.php;h=4f2cdc5f5ce3efc376719ee8ad78bede747df3b8;hb=fd166980602c3c6dae366a7b19f7085b355c34e7;hp=c01662e604278fe6c90ff30a662b5d60f17e605f;hpb=7f874ed2330864693882bd7c1400ba43269df7b2;p=civicrm-core.git
diff --git a/CRM/Utils/Address.php b/CRM/Utils/Address.php
index c01662e604..4f2cdc5f5c 100644
--- a/CRM/Utils/Address.php
+++ b/CRM/Utils/Address.php
@@ -3,7 +3,7 @@
+--------------------------------------------------------------------+
| CiviCRM version 5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2018 |
+ | Copyright CiviCRM LLC (c) 2004-2019 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
@@ -29,7 +29,7 @@
* Address Utilities
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2018
+ * @copyright CiviCRM LLC (c) 2004-2019
*/
class CRM_Utils_Address {
@@ -81,13 +81,13 @@ class CRM_Utils_Address {
}
// make sure that some of the fields do have values
- $emptyFields = array(
+ $emptyFields = [
'supplemental_address_1',
'supplemental_address_2',
'supplemental_address_3',
'state_province_name',
'county',
- );
+ ];
foreach ($emptyFields as $f) {
if (!isset($fields[$f])) {
$fields[$f] = NULL;
@@ -98,7 +98,7 @@ class CRM_Utils_Address {
if ($mailing && !empty($fields['country'])) {
if (Civi::settings()->get('hideCountryMailingLabels')) {
$domain = CRM_Core_BAO_Domain::getDomain();
- $domainLocation = CRM_Core_BAO_Location::getValues(array('contact_id' => $domain->contact_id));
+ $domainLocation = CRM_Core_BAO_Location::getValues(['contact_id' => $domain->contact_id]);
$domainAddress = $domainLocation['address'][1];
$domainCountryId = $domainAddress['country_id'];
if ($fields['country'] == CRM_Core_PseudoConstant::country($domainCountryId)) {
@@ -116,7 +116,7 @@ class CRM_Utils_Address {
if (!$microformat) {
// replacements in case of Individual Name Format
- $replacements = array(
+ $replacements = [
'contact.display_name' => CRM_Utils_Array::value('display_name', $fields),
'contact.individual_prefix' => CRM_Utils_Array::value('individual_prefix', $fields),
'contact.formal_title' => CRM_Utils_Array::value('formal_title', $fields),
@@ -165,10 +165,10 @@ class CRM_Utils_Address {
'contact.addressee' => CRM_Utils_Array::value('addressee_display', $fields),
'contact.email_greeting' => CRM_Utils_Array::value('email_greeting_display', $fields),
'contact.postal_greeting' => CRM_Utils_Array::value('postal_greeting_display', $fields),
- );
+ ];
}
else {
- $replacements = array(
+ $replacements = [
'contact.address_name' => "" . $fields['address_name'] . "",
'contact.street_address' => "" . $fields['street_address'] . "",
'contact.supplemental_address_1' => "" . $fields['supplemental_address_1'] . "",
@@ -181,7 +181,7 @@ class CRM_Utils_Address {
'contact.postal_code' => "" . $fullPostalCode . "",
'contact.country' => "" . $fields['country'] . "",
'contact.world_region' => "" . $fields['world_region'] . "",
- );
+ ];
// erase all empty ones, so we dont get blank lines
foreach (array_keys($replacements) as $key) {
@@ -249,7 +249,7 @@ class CRM_Utils_Address {
$formatted = preg_replace('/{([^{}]*)}({[^{}]*})+/u', '\1', $formatted);
// drop any remaining curly braces leaving their contents
- $formatted = str_replace(array('{', '}'), '', $formatted);
+ $formatted = str_replace(['{', '}'], '', $formatted);
// drop any empty lines left after the replacements
$formatted = preg_replace('/^[ \t]*[\r\n]+/m', '', $formatted);
@@ -260,7 +260,7 @@ class CRM_Utils_Address {
else {
// remove \n from each line and only add at the end
// this hack solves formatting issue, when we convert nl2br
- $lines = array();
+ $lines = [];
$count = 1;
$finalFormatted = NULL;
$formattedArray = explode("\n", $formatted);
@@ -287,7 +287,7 @@ class CRM_Utils_Address {
*/
public static function sequence($format) {
// also compute and store the address sequence
- $addressSequence = array(
+ $addressSequence = [
'address_name',
'street_address',
'supplemental_address_1',
@@ -298,10 +298,10 @@ class CRM_Utils_Address {
'state_province',
'postal_code',
'country',
- );
+ ];
// get the field sequence from the format
- $newSequence = array();
+ $newSequence = [];
foreach ($addressSequence as $field) {
if (substr_count($format, $field)) {
$newSequence[strpos($format, $field)] = $field;
@@ -326,15 +326,15 @@ class CRM_Utils_Address {
* @return string
*/
public static function getFormattedBillingAddressFieldsFromParameters($params, $billingLocationTypeID) {
- $addressParts = array(
+ $addressParts = [
"street_address" => "billing_street_address-{$billingLocationTypeID}",
"city" => "billing_city-{$billingLocationTypeID}",
"postal_code" => "billing_postal_code-{$billingLocationTypeID}",
"state_province" => "state_province-{$billingLocationTypeID}",
"country" => "country-{$billingLocationTypeID}",
- );
+ ];
- $addressFields = array();
+ $addressFields = [];
foreach ($addressParts as $name => $field) {
$value = CRM_Utils_Array::value($field, $params);
$alternateName = 'billing_' . $name . '_id-' . $billingLocationTypeID;