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
.phpcs.xml.distcomposer.jsoncomposer.lock
data
inc
admin-pages
class-about-admin-page.phpclass-base-admin-page.phpclass-base-customer-facing-admin-page.phpclass-broadcast-edit-admin-page.phpclass-broadcast-list-admin-page.phpclass-checkout-form-edit-admin-page.phpclass-checkout-form-list-admin-page.phpclass-customer-edit-admin-page.phpclass-customer-list-admin-page.phpclass-customizer-admin-page.phpclass-dashboard-admin-page.phpclass-discount-code-edit-admin-page.phpclass-discount-code-list-admin-page.phpclass-domain-edit-admin-page.phpclass-domain-list-admin-page.phpclass-edit-admin-page.phpclass-email-edit-admin-page.phpclass-email-list-admin-page.phpclass-email-template-customize-admin-page.phpclass-event-list-admin-page.phpclass-event-view-admin-page.phpclass-hosting-integration-wizard-admin-page.phpclass-invoice-template-customize-admin-page.phpclass-jobs-list-admin-page.phpclass-list-admin-page.phpclass-membership-edit-admin-page.phpclass-membership-list-admin-page.phpclass-migration-alert-admin-page.phpclass-payment-edit-admin-page.phpclass-payment-list-admin-page.phpclass-placeholders-admin-page.phpclass-product-edit-admin-page.phpclass-product-list-admin-page.phpclass-settings-admin-page.phpclass-setup-wizard-admin-page.phpclass-shortcodes-admin-page.phpclass-site-edit-admin-page.phpclass-site-list-admin-page.phpclass-system-info-admin-page.phpclass-tax-rates-admin-page.phpclass-template-previewer-customize-admin-page.phpclass-top-admin-nav-menu.phpclass-view-logs-admin-page.phpclass-webhook-edit-admin-page.phpclass-webhook-list-admin-page.phpclass-wizard-admin-page.php
customer-panel
debug
api
builders
checkout
class-cart.phpclass-checkout-pages.phpclass-checkout.phpclass-legacy-checkout.phpclass-line-item.php
signup-fields
class-admin-notices.phpclass-admin-themes-compatibility.phpclass-ajax.phpclass-api.phpclass-async-calls.phpclass-autoloader.phpclass-cron.phpclass-current.phpclass-dashboard-statistics.phpclass-dashboard-widgets.phpclass-documentation.phpclass-domain-mapping.phpclass-faker.phpclass-geolocation.phpclass-helper.phpclass-hooks.phpclass-light-ajax.phpclass-logger.phpclass-maintenance-mode.phpclass-newsletter.phpclass-requirements.phpclass-scripts.phpclass-session-cookie.phpclass-settings.phpclass-sunrise.phpclass-user-switching.phpclass-views.phpclass-whitelabel.phpclass-wp-ultimo.php
compat
country
database
debug
deprecated
development
domain-mapping
duplication
functions
gateways
helpers
installers
integrations
internal
invoices
limitations
limits
list-tables
loaders
managers
models
objects
site-templates
sso
tax
traits
ui
phpstan.neon.distrector.phpsunrise.php
tests
uninstall.php
views
about.phpadmin-notices.php
admin-pages
base
broadcast
emails
checkout
customers
dashboard-statistics
dashboard-widgets
events
legacy
memberships
settings
ui
wizards

@@ -36,11 +36,11 @@ class Cron {
* @since 2.0.0
* @return void
*/
public function init() {
public function init(): void {
/*
* Creates general schedules for general uses.
*/
add_action('init', array($this, 'create_schedules'));
add_action('init', [$this, 'create_schedules']);
/*
* Deals with renewals for non-auto-renewing
@@ -50,22 +50,22 @@ class Cron {
* The second hook adds the handler to be called on that schedule.
* The third one deals with each membership that needs to be manually renewed.
*/
add_action('init', array($this, 'schedule_membership_check'));
add_action('init', [$this, 'schedule_membership_check']);
add_action('wu_membership_check', array($this, 'membership_renewal_check'), 10);
add_action('wu_membership_check', [$this, 'membership_renewal_check'], 10);
add_action('wu_membership_check', array($this, 'membership_trial_check'), 10);
add_action('wu_membership_check', [$this, 'membership_trial_check'], 10);
add_action('wu_async_create_renewal_payment', array($this, 'async_create_renewal_payment'), 10, 2);
add_action('wu_async_create_renewal_payment', [$this, 'async_create_renewal_payment'], 10, 2);
/*
* On that same check, we'll
* search for expired memberships
* and mark them as such.
*/
add_action('wu_membership_check', array($this, 'membership_expired_check'), 20);
add_action('wu_membership_check', [$this, 'membership_expired_check'], 20);
add_action('wu_async_mark_membership_as_expired', array($this, 'async_mark_membership_as_expired'), 10);
add_action('wu_async_mark_membership_as_expired', [$this, 'async_mark_membership_as_expired'], 10);
}
/**
@@ -76,21 +76,21 @@ class Cron {
* @since 2.0.0
* @return void
*/
public function create_schedules() {
public function create_schedules(): void {
/*
* Hourly check
*/
if (wu_next_scheduled_action('wu_hourly') === false) {
$next_hour = strtotime(gmdate('Y-m-d H:00:00', strtotime('+1 hour')));
wu_schedule_recurring_action($next_hour, HOUR_IN_SECONDS, 'wu_hourly', array(), 'wu_cron');
wu_schedule_recurring_action($next_hour, HOUR_IN_SECONDS, 'wu_hourly', [], 'wu_cron');
}
/*
* Daily check
*/
if (wu_next_scheduled_action('wu_daily') === false) {
wu_schedule_recurring_action(strtotime('tomorrow'), DAY_IN_SECONDS, 'wu_daily', array(), 'wu_cron');
wu_schedule_recurring_action(strtotime('tomorrow'), DAY_IN_SECONDS, 'wu_daily', [], 'wu_cron');
}
/*
@@ -99,7 +99,7 @@ class Cron {
if (wu_next_scheduled_action('wu_monthly') === false) {
$next_month = strtotime(gmdate('Y-m-01 00:00:00', strtotime('+1 month')));
wu_schedule_recurring_action($next_month, MONTH_IN_SECONDS, 'wu_monthly', array(), 'wu_cron');
wu_schedule_recurring_action($next_month, MONTH_IN_SECONDS, 'wu_monthly', [], 'wu_cron');
}
}
@@ -113,12 +113,12 @@ class Cron {
* @since 2.0.0
* @return void
*/
public function schedule_membership_check() {
public function schedule_membership_check(): void {
$interval = apply_filters('wu_schedule_membership_check_interval', 1 * HOUR_IN_SECONDS);
if (wu_next_scheduled_action('wu_membership_check') === false) {
wu_schedule_recurring_action(time(), $interval, 'wu_membership_check', array(), 'wu_cron');
wu_schedule_recurring_action(time(), $interval, 'wu_membership_check', [], 'wu_cron');
}
}
@@ -131,7 +131,7 @@ class Cron {
* @since 2.0.0
* @return void
*/
public function membership_renewal_check() {
public function membership_renewal_check(): void {
/*
* Define how many days before we need to
* create pending payments.
@@ -140,18 +140,18 @@ class Cron {
$query_params = apply_filters(
'wu_membership_renewal_check_query_params',
array(
[
'auto_renew' => false,
'status__in' => array(
'status__in' => [
Membership_Status::ACTIVE,
),
'date_query' => array(
],
'date_query' => [
'column' => 'date_expiration',
'before' => "+{$days_before_expiring} days",
'after' => 'yesterday',
'inclusive' => true,
),
),
],
],
$days_before_expiring
);
@@ -164,9 +164,9 @@ class Cron {
foreach ($memberships as $membership) {
wu_enqueue_async_action(
'wu_async_create_renewal_payment',
array(
[
'membership_id' => $membership->get_id(),
),
],
'wu_cron_check'
);
}
@@ -181,21 +181,21 @@ class Cron {
* @since 2.0.0
* @return void
*/
public function membership_trial_check() {
public function membership_trial_check(): void {
$query_params = apply_filters(
'wu_membership_trial_check_query_params',
array(
[
'auto_renew' => false,
'status__in' => array(
'status__in' => [
Membership_Status::TRIALING,
),
'date_query' => array(
],
'date_query' => [
'column' => 'date_trial_end',
'before' => '-3 hours',
'inclusive' => true,
),
)
],
]
);
$memberships = wu_get_memberships($query_params);
@@ -207,10 +207,10 @@ class Cron {
foreach ($memberships as $membership) {
wu_enqueue_async_action(
'wu_async_create_renewal_payment',
array(
[
'membership_id' => $membership->get_id(),
'trial' => true,
),
],
'wu_cron_check'
);
}
@@ -255,16 +255,16 @@ class Cron {
$saved = $membership->save();
$payment_url = add_query_arg(
array(
[
'payment' => $new_payment->get_hash(),
),
],
wu_get_registration_url()
);
$payload = array_merge(
array(
[
'default_payment_url' => $payment_url,
),
],
wu_generate_event_payload('payment', $new_payment),
wu_generate_event_payload('membership', $membership),
wu_generate_event_payload('customer', $membership->get_customer())
@@ -284,7 +284,7 @@ class Cron {
* @since 2.0.0
* @return void
*/
public function membership_expired_check() {
public function membership_expired_check(): void {
/*
* Define how many grace period
* days we allow for our customers.
@@ -293,19 +293,19 @@ class Cron {
$query_params = apply_filters(
'wu_membership_expired_check_query_params',
array(
[
'auto_renew' => false,
'status__in' => array(
'status__in' => [
Membership_Status::ACTIVE,
Membership_Status::ON_HOLD,
),
'date_expiration__not_in' => array(null, '0000-00-00 00:00:00'),
'date_query' => array(
],
'date_expiration__not_in' => [null, '0000-00-00 00:00:00'],
'date_query' => [
'column' => 'date_expiration',
'before' => "-{$grace_period_days} days",
'inclusive' => true,
),
),
],
],
$grace_period_days
);
@@ -318,9 +318,9 @@ class Cron {
foreach ($memberships as $membership) {
wu_enqueue_async_action(
'wu_async_mark_membership_as_expired',
array(
[
'membership_id' => $membership->get_id(),
),
],
'wu_cron_check'
);
}