Use PHP 7.4 featers and PHP 8 polyfills

This commit is contained in:
David Stone
2025-02-08 13:57:32 -07:00
parent 8bea6067cd
commit b41dc2b2eb
550 changed files with 15270 additions and 14627 deletions

View File

@ -68,11 +68,11 @@ class Country_BR extends Country {
* @since 2.0.11
* @var array
*/
protected $attributes = array(
protected $attributes = [
'country_code' => 'BR',
'currency' => 'BRL',
'phone_code' => 55,
);
];
/**
* The type of nomenclature used to refer to the country sub-divisions.
@ -101,7 +101,7 @@ class Country_BR extends Country {
*/
protected function states() {
return array(
return [
'AC' => __('Acre', 'wp-ultimo'),
'AL' => __('Alagoas', 'wp-ultimo'),
'AP' => __('Amapá', 'wp-ultimo'),
@ -129,6 +129,6 @@ class Country_BR extends Country {
'SE' => __('Sergipe', 'wp-ultimo'),
'SP' => __('São Paulo', 'wp-ultimo'),
'TO' => __('Tocantins', 'wp-ultimo'),
);
];
}
}

View File

@ -54,11 +54,11 @@ class Country_CA extends Country {
* @since 2.0.11
* @var array
*/
protected $attributes = array(
protected $attributes = [
'country_code' => 'CA',
'currency' => 'CAD',
'phone_code' => 1,
);
];
/**
* The type of nomenclature used to refer to the country sub-divisions.
@ -87,7 +87,7 @@ class Country_CA extends Country {
*/
protected function states() {
return array(
return [
'AB' => __('Alberta', 'wp-ultimo'),
'BC' => __('British Columbia', 'wp-ultimo'),
'MB' => __('Manitoba', 'wp-ultimo'),
@ -101,6 +101,6 @@ class Country_CA extends Country {
'QC' => __('Quebec', 'wp-ultimo'),
'SK' => __('Saskatchewan', 'wp-ultimo'),
'YT' => __('Yukon', 'wp-ultimo'),
);
];
}
}

View File

@ -73,11 +73,11 @@ class Country_CN extends Country {
* @since 2.0.11
* @var array
*/
protected $attributes = array(
protected $attributes = [
'country_code' => 'CN',
'currency' => 'CNY',
'phone_code' => 86,
);
];
/**
* The type of nomenclature used to refer to the country sub-divisions.
@ -106,7 +106,7 @@ class Country_CN extends Country {
*/
protected function states() {
return array(
return [
'AH' => __('Anhui', 'wp-ultimo'),
'BJ' => __('Beijing', 'wp-ultimo'),
'CQ' => __('Chongqing', 'wp-ultimo'),
@ -141,6 +141,6 @@ class Country_CN extends Country {
'XZ' => __('Xizang', 'wp-ultimo'),
'YN' => __('Yunnan', 'wp-ultimo'),
'ZJ' => __('Zhejiang', 'wp-ultimo'),
);
];
}
}

View File

@ -57,11 +57,11 @@ class Country_DE extends Country {
* @since 2.0.11
* @var array
*/
protected $attributes = array(
protected $attributes = [
'country_code' => 'DE',
'currency' => 'EUR',
'phone_code' => 49,
);
];
/**
* The type of nomenclature used to refer to the country sub-divisions.
@ -90,7 +90,7 @@ class Country_DE extends Country {
*/
protected function states() {
return array(
return [
'BW' => __('Baden-Württemberg', 'wp-ultimo'),
'BY' => __('Bavaria', 'wp-ultimo'),
'BE' => __('Berlin', 'wp-ultimo'),
@ -107,6 +107,6 @@ class Country_DE extends Country {
'ST' => __('Saxony-Anhalt', 'wp-ultimo'),
'SH' => __('Schleswig-Holstein', 'wp-ultimo'),
'TH' => __('Thuringia', 'wp-ultimo'),
);
];
}
}

View File

@ -52,19 +52,19 @@ class Country_Default extends Country {
* @param array $attributes The country attributes.
* @return \WP_Ultimo\Country\Country
*/
public static function build($code, $name = null, $attributes = array()) {
public static function build($code, $name = null, $attributes = []) {
$instance = new self();
$instance->name = $name ? $name : wu_get_country_name($code);
$instance->name = $name ?: wu_get_country_name($code);
$instance->attributes = wp_parse_args(
$attributes,
array(
[
'country_code' => strtoupper($code),
'currency' => strtoupper($code),
'phone_code' => 00,
)
]
);
return $instance;

View File

@ -59,11 +59,11 @@ class Country_ES extends Country {
* @since 2.0.11
* @var array
*/
protected $attributes = array(
protected $attributes = [
'country_code' => 'ES',
'currency' => 'EUR',
'phone_code' => 34,
);
];
/**
* The type of nomenclature used to refer to the country sub-divisions.
@ -92,7 +92,7 @@ class Country_ES extends Country {
*/
protected function states() {
return array(
return [
'AN' => __('Andalusia', 'wp-ultimo'),
'AR' => __('Aragon', 'wp-ultimo'),
'AS' => __('Asturias', 'wp-ultimo'),
@ -121,6 +121,6 @@ class Country_ES extends Country {
'VA' => __('Valladolid Province', 'wp-ultimo'),
'ZA' => __('Zamora Province', 'wp-ultimo'),
'AV' => __('Ávila', 'wp-ultimo'),
);
];
}
}

View File

@ -54,11 +54,11 @@ class Country_FR extends Country {
* @since 2.0.11
* @var array
*/
protected $attributes = array(
protected $attributes = [
'country_code' => 'FR',
'currency' => 'EUR',
'phone_code' => 33,
);
];
/**
* The type of nomenclature used to refer to the country sub-divisions.
@ -87,7 +87,7 @@ class Country_FR extends Country {
*/
protected function states() {
return array(
return [
'10' => __('Aube', 'wp-ultimo'),
'11' => __('Aude', 'wp-ultimo'),
'12' => __('Aveyron', 'wp-ultimo'),
@ -211,6 +211,6 @@ class Country_FR extends Country {
'MF' => __('Saint-Martin', 'wp-ultimo'),
'WF' => __('Wallis and Futuna', 'wp-ultimo'),
'IDF' => __('Île-de-France', 'wp-ultimo'),
);
];
}
}

View File

@ -45,11 +45,11 @@ class Country_GB extends Country {
* @since 2.0.11
* @var array
*/
protected $attributes = array(
protected $attributes = [
'country_code' => 'GB',
'currency' => 'GBP',
'phone_code' => 44,
);
];
/**
* The type of nomenclature used to refer to the country sub-divisions.
@ -78,7 +78,7 @@ class Country_GB extends Country {
*/
protected function states() {
return array(
return [
'ABE' => __('Aberdeen', 'wp-ultimo'),
'ABD' => __('Aberdeenshire', 'wp-ultimo'),
'ANS' => __('Angus', 'wp-ultimo'),
@ -326,6 +326,6 @@ class Country_GB extends Country {
'WOK' => __('Wokingham', 'wp-ultimo'),
'WOR' => __('Worcestershire', 'wp-ultimo'),
'WRX' => __('Wrexham County Borough', 'wp-ultimo'),
);
];
}
}

View File

@ -77,11 +77,11 @@ class Country_IN extends Country {
* @since 2.0.11
* @var array
*/
protected $attributes = array(
protected $attributes = [
'country_code' => 'IN',
'currency' => 'INR',
'phone_code' => 91,
);
];
/**
* The type of nomenclature used to refer to the country sub-divisions.
@ -110,7 +110,7 @@ class Country_IN extends Country {
*/
protected function states() {
return array(
return [
'AN' => __('Andaman and Nicobar Islands', 'wp-ultimo'),
'AP' => __('Andhra Pradesh', 'wp-ultimo'),
'AR' => __('Arunachal Pradesh', 'wp-ultimo'),
@ -147,6 +147,6 @@ class Country_IN extends Country {
'UP' => __('Uttar Pradesh', 'wp-ultimo'),
'UT' => __('Uttarakhand', 'wp-ultimo'),
'WB' => __('West Bengal', 'wp-ultimo'),
);
];
}
}

View File

@ -88,11 +88,11 @@ class Country_JP extends Country {
* @since 2.0.11
* @var array
*/
protected $attributes = array(
protected $attributes = [
'country_code' => 'JP',
'currency' => 'JPY',
'phone_code' => 81,
);
];
/**
* The type of nomenclature used to refer to the country sub-divisions.
@ -121,7 +121,7 @@ class Country_JP extends Country {
*/
protected function states() {
return array(
return [
'10' => __('Gunma Prefecture', 'wp-ultimo'),
'11' => __('Saitama Prefecture', 'wp-ultimo'),
'12' => __('Chiba Prefecture', 'wp-ultimo'),
@ -169,6 +169,6 @@ class Country_JP extends Country {
'04' => __('Miyagi Prefecture', 'wp-ultimo'),
'09' => __('Tochigi Prefecture', 'wp-ultimo'),
'06' => __('Yamagata Prefecture', 'wp-ultimo'),
);
];
}
}

View File

@ -73,11 +73,11 @@ class Country_MX extends Country {
* @since 2.0.11
* @var array
*/
protected $attributes = array(
protected $attributes = [
'country_code' => 'MX',
'currency' => 'MXN',
'phone_code' => 52,
);
];
/**
* The type of nomenclature used to refer to the country sub-divisions.
@ -106,7 +106,7 @@ class Country_MX extends Country {
*/
protected function states() {
return array(
return [
'AGU' => __('Aguascalientes', 'wp-ultimo'),
'BCN' => __('Baja California', 'wp-ultimo'),
'BCS' => __('Baja California Sur', 'wp-ultimo'),
@ -139,6 +139,6 @@ class Country_MX extends Country {
'VER' => __('Veracruz de Ignacio de la Llave', 'wp-ultimo'),
'YUC' => __('Yucatán', 'wp-ultimo'),
'ZAC' => __('Zacatecas', 'wp-ultimo'),
);
];
}
}

View File

@ -57,11 +57,11 @@ class Country_MY extends Country {
* @since 2.0.11
* @var array
*/
protected $attributes = array(
protected $attributes = [
'country_code' => 'MY',
'currency' => 'MYR',
'phone_code' => 60,
);
];
/**
* The type of nomenclature used to refer to the country sub-divisions.
@ -90,7 +90,7 @@ class Country_MY extends Country {
*/
protected function states() {
return array(
return [
'10' => __('Selangor', 'wp-ultimo'),
'11' => __('Terengganu', 'wp-ultimo'),
'12' => __('Sabah', 'wp-ultimo'),
@ -107,6 +107,6 @@ class Country_MY extends Country {
'07' => __('Penang', 'wp-ultimo'),
'08' => __('Perak', 'wp-ultimo'),
'09' => __('Perlis', 'wp-ultimo'),
);
];
}
}

View File

@ -48,11 +48,11 @@ class Country_NE extends Country {
* @since 2.0.11
* @var array
*/
protected $attributes = array(
protected $attributes = [
'country_code' => 'NE',
'currency' => 'XOF',
'phone_code' => 227,
);
];
/**
* The type of nomenclature used to refer to the country sub-divisions.
@ -81,7 +81,7 @@ class Country_NE extends Country {
*/
protected function states() {
return array(
return [
'1' => __('Agadez Region', 'wp-ultimo'),
'2' => __('Diffa Region', 'wp-ultimo'),
'3' => __('Dosso Region', 'wp-ultimo'),
@ -89,6 +89,6 @@ class Country_NE extends Country {
'5' => __('Tahoua Region', 'wp-ultimo'),
'6' => __('Tillabéri Region', 'wp-ultimo'),
'7' => __('Zinder Region', 'wp-ultimo'),
);
];
}
}

View File

@ -53,11 +53,11 @@ class Country_NL extends Country {
* @since 2.0.11
* @var array
*/
protected $attributes = array(
protected $attributes = [
'country_code' => 'NL',
'currency' => 'EUR',
'phone_code' => 31,
);
];
/**
* The type of nomenclature used to refer to the country sub-divisions.
@ -86,7 +86,7 @@ class Country_NL extends Country {
*/
protected function states() {
return array(
return [
'BQ1' => __('Bonaire', 'wp-ultimo'),
'DR' => __('Drenthe', 'wp-ultimo'),
'FL' => __('Flevoland', 'wp-ultimo'),
@ -102,6 +102,6 @@ class Country_NL extends Country {
'ZH' => __('South Holland', 'wp-ultimo'),
'UT' => __('Utrecht', 'wp-ultimo'),
'ZE' => __('Zeeland', 'wp-ultimo'),
);
];
}
}

View File

@ -124,11 +124,11 @@ class Country_RU extends Country {
* @since 2.0.11
* @var array
*/
protected $attributes = array(
protected $attributes = [
'country_code' => 'RU',
'currency' => 'RUB',
'phone_code' => 7,
);
];
/**
* The type of nomenclature used to refer to the country sub-divisions.
@ -157,7 +157,7 @@ class Country_RU extends Country {
*/
protected function states() {
return array(
return [
'ALT' => __('Altai Krai', 'wp-ultimo'),
'AL' => __('Altai Republic', 'wp-ultimo'),
'AMU' => __('Amur Oblast', 'wp-ultimo'),
@ -242,6 +242,6 @@ class Country_RU extends Country {
'YAN' => __('Yamalo-Nenets Autonomous Okrug', 'wp-ultimo'),
'YAR' => __('Yaroslavl Oblast', 'wp-ultimo'),
'ZAB' => __('Zabaykalsky Krai', 'wp-ultimo'),
);
];
}
}

View File

@ -43,11 +43,11 @@ class Country_SG extends Country {
* @since 2.0.11
* @var array
*/
protected $attributes = array(
protected $attributes = [
'country_code' => 'SG',
'currency' => 'SGD',
'phone_code' => 65,
);
];
/**
* The type of nomenclature used to refer to the country sub-divisions.
@ -76,12 +76,12 @@ class Country_SG extends Country {
*/
protected function states() {
return array(
return [
'01' => __('Central Singapore Community Development Council', 'wp-ultimo'),
'02' => __('North East Community Development Council', 'wp-ultimo'),
'03' => __('North West Community Development Council', 'wp-ultimo'),
'04' => __('South East Community Development Council', 'wp-ultimo'),
'05' => __('South West Community Development Council', 'wp-ultimo'),
);
];
}
}

View File

@ -122,11 +122,11 @@ class Country_TR extends Country {
* @since 2.0.11
* @var array
*/
protected $attributes = array(
protected $attributes = [
'country_code' => 'TR',
'currency' => 'TRY',
'phone_code' => 90,
);
];
/**
* The type of nomenclature used to refer to the country sub-divisions.
@ -155,7 +155,7 @@ class Country_TR extends Country {
*/
protected function states() {
return array(
return [
'10' => __('Balıkesir', 'wp-ultimo'),
'11' => __('Bilecik', 'wp-ultimo'),
'12' => __('Bingöl', 'wp-ultimo'),
@ -237,6 +237,6 @@ class Country_TR extends Country {
'08' => __('Artvin', 'wp-ultimo'),
'09' => __('Aydın', 'wp-ultimo'),
'04' => __('Ağrı', 'wp-ultimo'),
);
];
}
}

View File

@ -93,11 +93,11 @@ class Country_US extends Country {
* @since 2.0.11
* @var array
*/
protected $attributes = array(
protected $attributes = [
'country_code' => 'US',
'currency' => 'USD',
'phone_code' => 1,
);
];
/**
* The type of nomenclature used to refer to the country sub-divisions.
@ -126,7 +126,7 @@ class Country_US extends Country {
*/
protected function states() {
return array(
return [
'AL' => __('Alabama', 'wp-ultimo'),
'AK' => __('Alaska', 'wp-ultimo'),
'AS' => __('American Samoa', 'wp-ultimo'),
@ -193,6 +193,6 @@ class Country_US extends Country {
'WV' => __('West Virginia', 'wp-ultimo'),
'WI' => __('Wisconsin', 'wp-ultimo'),
'WY' => __('Wyoming', 'wp-ultimo'),
);
];
}
}

View File

@ -50,11 +50,11 @@ class Country_ZA extends Country {
* @since 2.0.11
* @var array
*/
protected $attributes = array(
protected $attributes = [
'country_code' => 'ZA',
'currency' => 'ZAR',
'phone_code' => 27,
);
];
/**
* The type of nomenclature used to refer to the country sub-divisions.
@ -83,7 +83,7 @@ class Country_ZA extends Country {
*/
protected function states() {
return array(
return [
'EC' => __('Eastern Cape', 'wp-ultimo'),
'FS' => __('Free State', 'wp-ultimo'),
'GP' => __('Gauteng', 'wp-ultimo'),
@ -93,6 +93,6 @@ class Country_ZA extends Country {
'NW' => __('North West', 'wp-ultimo'),
'NC' => __('Northern Cape', 'wp-ultimo'),
'WC' => __('Western Cape', 'wp-ultimo'),
);
];
}
}

View File

@ -30,7 +30,7 @@ abstract class Country {
* @since 2.0.11
* @var array
*/
protected $attributes = array();
protected $attributes = [];
/**
* The type of nomenclature used to refer to the country sub-divisions.
@ -98,7 +98,7 @@ abstract class Country {
$options = $this->get_states();
$placeholder_option = array();
$placeholder_option = [];
if ($placeholder !== false && $options) {
$division_name = $this->get_administrative_division_name();
@ -121,13 +121,13 @@ abstract class Country {
public function get_cities($state_code = '') {
if (empty($state_code)) {
return array();
return [];
}
$repository_file = wu_path("inc/country/{$this->country_code}/{$state_code}.php");
if (file_exists($repository_file) === false) {
return array();
return [];
}
$cities = include $repository_file;
@ -159,7 +159,7 @@ abstract class Country {
$options = $this->get_cities($state_code);
$placeholder_option = array();
$placeholder_option = [];
if ($placeholder !== false && $options) {
$placeholder_option[''] = $placeholder !== '' ? $placeholder : __('Select your city', 'wp-ultimo');
@ -178,7 +178,7 @@ abstract class Country {
*/
protected function states() {
return array();
return [];
}
/**
@ -216,7 +216,7 @@ abstract class Country {
*/
public function get_administrative_division_name($state_code = null, $ucwords = false) {
$denominations = array(
$denominations = [
'province' => __('province', 'wp-ultimo'),
'state' => __('state', 'wp-ultimo'),
'territory' => __('territory', 'wp-ultimo'),
@ -229,7 +229,7 @@ abstract class Country {
'county' => __('county', 'wp-ultimo'),
'division' => __('division', 'wp-ultimo'),
'unknown' => __('state / province', 'wp-ultimo'),
);
];
$name = wu_get_isset($denominations, $this->state_type, $denominations['unknown']);