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

@ -36,7 +36,7 @@ class Checkout_Steps extends Rule {
* @since 2.0.0
* @var array
*/
protected $fillableParams = array(); // phpcs:ignore
protected $fillableParams = []; // phpcs:ignore
/**
* Performs the actual check.
*
@ -90,11 +90,11 @@ class Checkout_Steps extends Rule {
*/
$submittable_field_types = apply_filters(
'wu_checkout_step_validation_submittable_field_types',
array(
[
'submit_button',
'pricing_table',
'template_selection',
)
]
);
/**
@ -103,11 +103,11 @@ class Checkout_Steps extends Rule {
foreach ($value as $step) {
$found_submittable_field_types = \Arrch\Arrch::find(
$step['fields'],
array(
'where' => array(
array('type', $submittable_field_types),
),
)
[
'where' => [
['type', $submittable_field_types],
],
]
);
if (empty($found_submittable_field_types)) {

View File

@ -27,7 +27,7 @@ class City extends Rule {
* @since 2.0.4
* @var array
*/
protected $fillableParams = array('country', 'state');
protected $fillableParams = ['country', 'state'];
/**
* Performs the actual check.
*
@ -35,7 +35,7 @@ class City extends Rule {
*
* @param mixed $city The city value detected.
*/
public function check($city) : bool {
public function check($city): bool {
$check = true;

View File

@ -27,7 +27,7 @@ class Country extends Rule {
* @since 2.0.4
* @var array
*/
protected $fillableParams = array(); // phpcs:ignore
protected $fillableParams = []; // phpcs:ignore
/**
* Performs the actual check.
*

View File

@ -35,7 +35,7 @@ class Domain extends Rule {
* @since 2.0.0
* @var array
*/
protected $fillableParams = array(); // phpcs:ignore
protected $fillableParams = []; // phpcs:ignore
/**
* Performs the actual check.
*

View File

@ -35,7 +35,7 @@ class Exists extends Rule {
* @since 2.0.0
* @var array
*/
protected $fillableParams = array('model', 'column', 'except'); // phpcs:ignore
protected $fillableParams = ['model', 'column', 'except']; // phpcs:ignore
/**
* Performs the actual check.
@ -47,10 +47,10 @@ class Exists extends Rule {
public function check($value): bool {
$this->requireParameters(
array(
[
'model',
'column',
)
]
);
$column = $this->parameter('column');

View File

@ -35,7 +35,7 @@ class Price_Variations extends Rule {
* @since 2.0.0
* @var array
*/
protected $fillableParams = array('duration', 'duration_unit'); // phpcs:ignore
protected $fillableParams = ['duration', 'duration_unit']; // phpcs:ignore
/**
* Performs the actual check.
*
@ -75,12 +75,12 @@ class Price_Variations extends Rule {
*/
$unit = wu_get_isset($price_variation, 'duration_unit', false);
$allowed_units = array(
$allowed_units = [
'day',
'week',
'month',
'year',
);
];
if (!in_array($unit, $allowed_units, true)) {

View File

@ -35,7 +35,7 @@ class Products extends Rule {
* @since 2.0.4
* @var array
*/
protected $fillableParams = array(); // phpcs:ignore
protected $fillableParams = []; // phpcs:ignore
/**
* Performs the actual check.
*
@ -49,7 +49,7 @@ class Products extends Rule {
$product_objects = array_map('wu_get_product', $products);
list($plan, $additional_products) = wu_segregate_products($product_objects);
[$plan, $additional_products] = wu_segregate_products($product_objects);
if ($plan) {
return true;

View File

@ -37,7 +37,7 @@ class Site_Template extends Rule {
* @since 2.0.4
* @var array
*/
protected $fillableParams = array(); // phpcs:ignore
protected $fillableParams = []; // phpcs:ignore
/**
* Performs the actual check.
*
@ -81,7 +81,7 @@ class Site_Template extends Rule {
$allowed_templates = false;
$product_ids_or_slugs = Checkout::get_instance()->request_or_session('products', array());
$product_ids_or_slugs = Checkout::get_instance()->request_or_session('products', []);
$product_ids_or_slugs = array_unique($product_ids_or_slugs);
@ -90,9 +90,9 @@ class Site_Template extends Rule {
$limits = new \WP_Ultimo\Objects\Limitations();
list($plan, $additional_products) = wu_segregate_products($products);
[$plan, $additional_products] = wu_segregate_products($products);
$products = array_merge(array($plan), $additional_products);
$products = array_merge([$plan], $additional_products);
foreach ($products as $product) {
$limits = $limits->merge($product->get_limitations());

View File

@ -27,7 +27,7 @@ class State extends Rule {
* @since 2.0.4
* @var array
*/
protected $fillableParams = array('country'); // phpcs:ignore
protected $fillableParams = ['country']; // phpcs:ignore
/**
* Performs the actual check.
*

View File

@ -35,7 +35,7 @@ class Unique_Site extends Rule {
* @since 2.0.0
* @var array
*/
protected $fillableParams = array('self_id'); // phpcs:ignore
protected $fillableParams = ['self_id']; // phpcs:ignore
/**
* Performs the actual check.
*
@ -45,7 +45,7 @@ class Unique_Site extends Rule {
*/
public function check($value) : bool { // phpcs:ignore
$this->requireParameters(array());
$this->requireParameters([]);
$self_id = $this->parameter('self_id');

View File

@ -35,7 +35,7 @@ class Unique extends Rule {
* @since 2.0.0
* @var array
*/
protected $fillableParams = array('model', 'column', 'self_id'); // phpcs:ignore
protected $fillableParams = ['model', 'column', 'self_id']; // phpcs:ignore
/**
* Performs the actual check.
@ -47,10 +47,10 @@ class Unique extends Rule {
public function check($value): bool {
$this->requireParameters(
array(
[
'model',
'column',
)
]
);
$column = $this->parameter('column');
@ -62,17 +62,17 @@ class Unique extends Rule {
$callback = 'get_user_by';
break;
default:
$callback = array($model, 'get_by');
$callback = [$model, 'get_by'];
break;
}
// do query
$existing = call_user_func($callback, $column, $value);
$user_models = array(
$user_models = [
'\WP_User',
'\WP_Ultimo\Models\Customer',
);
\WP_Ultimo\Models\Customer::class,
];
/*
* Customize the error message for the customer.