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

@ -48,7 +48,7 @@ class Membership_Query extends Query {
* @access public
* @var string
*/
protected $table_schema = '\\WP_Ultimo\\Database\\Memberships\\Memberships_Schema';
protected $table_schema = \WP_Ultimo\Database\Memberships\Memberships_Schema::class;
/** Item ******************************************************************/
@ -77,7 +77,7 @@ class Membership_Query extends Query {
* @access public
* @var mixed
*/
protected $item_shape = '\\WP_Ultimo\\Models\\Membership';
protected $item_shape = \WP_Ultimo\Models\Membership::class;
/**
* Group to cache queries and queried items in.
@ -104,7 +104,7 @@ class Membership_Query extends Query {
*
* @param string|array $query Array of query arguments.
*/
public function __construct($query = array()) {
public function __construct($query = []) {
parent::__construct($query);
}

View File

@ -41,14 +41,14 @@ class Membership_Status extends Enum {
*/
protected function classes() {
return array(
return [
static::PENDING => 'wu-bg-gray-200 wu-text-gray-700',
static::ACTIVE => 'wu-bg-green-200 wu-text-green-700',
static::TRIALING => 'wu-bg-orange-200 wu-text-orange-700',
static::ON_HOLD => 'wu-bg-blue-200 wu-text-blue-700',
static::EXPIRED => 'wu-bg-yellow-200 wu-text-yellow-700',
static::CANCELLED => 'wu-bg-red-200 wu-text-red-700',
);
];
}
/**
@ -59,13 +59,13 @@ class Membership_Status extends Enum {
*/
protected function labels() {
return array(
return [
static::PENDING => __('Pending', 'wp-ultimo'),
static::ACTIVE => __('Active', 'wp-ultimo'),
static::TRIALING => __('Trialing', 'wp-ultimo'),
static::ON_HOLD => __('On Hold', 'wp-ultimo'),
static::EXPIRED => __('Expired', 'wp-ultimo'),
static::CANCELLED => __('Cancelled', 'wp-ultimo'),
);
];
}
}

View File

@ -64,7 +64,7 @@ final class Memberships_Meta_Table extends Table {
* @since 2.0.0
* @return void
*/
protected function set_schema() {
protected function set_schema(): void {
$max_index_length = 191;

View File

@ -28,10 +28,10 @@ class Memberships_Schema extends Schema {
* @access public
* @var array
*/
public $columns = array(
public $columns = [
// id
array(
[
'name' => 'id',
'type' => 'bigint',
'length' => '20',
@ -40,69 +40,69 @@ class Memberships_Schema extends Schema {
'primary' => true,
'sortable' => true,
'searchable' => true,
),
],
// customer_id
array(
[
'name' => 'customer_id',
'type' => 'bigint',
'length' => '20',
'unsigned' => true,
),
],
// user_id
array(
[
'name' => 'user_id',
'type' => 'bigint',
'length' => '20',
'unsigned' => true,
'default' => null,
'allow_null' => true,
),
],
array(
[
'name' => 'migrated_from_id',
'type' => 'bigint',
'length' => '20',
'unsigned' => true,
'sortable' => true,
'allow_null' => true,
),
],
// object_id
array(
[
'name' => 'plan_id',
'type' => 'bigint',
'length' => '20',
'unsigned' => true,
'sortable' => true,
'transition' => true,
),
],
// addons
array(
[
'name' => 'addon_products',
'type' => 'longtext',
),
],
// currency
array(
[
'name' => 'currency',
'type' => 'varchar',
'length' => '20',
'default' => 'USD',
'sortable' => true,
),
],
array(
[
'name' => 'initial_amount',
'type' => 'decimal(13,4)',
'default' => '',
'sortable' => true,
'transition' => true,
),
],
array(
[
'name' => 'recurring',
'type' => 'tinyint',
'length' => '4',
@ -110,9 +110,9 @@ class Memberships_Schema extends Schema {
'default' => 1,
'transition' => true,
'sortable' => true,
),
],
array(
[
'name' => 'auto_renew',
'type' => 'tinyint',
'length' => '4',
@ -120,33 +120,33 @@ class Memberships_Schema extends Schema {
'default' => 0,
'transition' => true,
'sortable' => true,
),
],
array(
[
'name' => 'duration',
'type' => 'smallint',
'unsigned' => true,
'default' => '0',
'sortable' => true,
'transition' => true,
),
],
array(
[
'name' => 'duration_unit',
'type' => 'enum(\'day\', \'month\', \'week\', \'year\')',
'default' => 'none',
),
],
array(
[
'name' => 'amount',
'type' => 'decimal(13,4)',
'default' => '',
'sortable' => true,
'transition' => true,
),
],
// date_created
array(
[
'name' => 'date_created',
'type' => 'datetime',
'default' => null,
@ -154,50 +154,50 @@ class Memberships_Schema extends Schema {
'date_query' => true,
'sortable' => true,
'allow_null' => true,
),
],
// date_activated
array(
[
'name' => 'date_activated',
'type' => 'datetime',
'default' => null,
'date_query' => true,
'sortable' => true,
'allow_null' => true,
),
],
// date_trial_end
array(
[
'name' => 'date_trial_end',
'type' => 'datetime',
'default' => null,
'date_query' => true,
'sortable' => true,
'allow_null' => true,
),
],
// date_renewed
array(
[
'name' => 'date_renewed',
'type' => 'datetime',
'default' => null,
'date_query' => true,
'sortable' => true,
'allow_null' => true,
),
],
// date_cancellation
array(
[
'name' => 'date_cancellation',
'type' => 'datetime',
'default' => null,
'date_query' => true,
'sortable' => true,
'allow_null' => true,
),
],
// date_expiration
array(
[
'name' => 'date_expiration',
'type' => 'datetime',
'default' => null,
@ -205,10 +205,10 @@ class Memberships_Schema extends Schema {
'sortable' => true,
'transition' => true,
'allow_null' => true,
),
],
// date_payment_plan_completed
array(
[
'name' => 'date_payment_plan_completed',
'type' => 'datetime',
'default' => null,
@ -216,118 +216,118 @@ class Memberships_Schema extends Schema {
'sortable' => true,
'transition' => true,
'allow_null' => true,
),
],
// auto_renew
array(
[
'name' => 'auto_renew',
'type' => 'smallint',
'unsigned' => true,
'default' => '0',
'transition' => true,
),
],
// times_billed
array(
[
'name' => 'times_billed',
'type' => 'smallint',
'unsigned' => true,
'default' => '0',
'sortable' => true,
'transition' => true,
),
],
// billing_cycles
array(
[
'name' => 'billing_cycles',
'type' => 'smallint',
'unsigned' => true,
'default' => '0',
'sortable' => true,
),
],
// status
array(
[
'name' => 'status',
'type' => 'varchar',
'length' => '12',
'default' => 'pending',
'sortable' => true,
'transition' => true,
),
],
// gateway_customer_id
array(
[
'name' => 'gateway_customer_id',
'type' => 'tinytext',
'default' => '',
'searchable' => true,
'sortable' => true,
'transition' => true,
),
],
// gateway_subscription_id
array(
[
'name' => 'gateway_subscription_id',
'type' => 'tinytext',
'default' => '',
'searchable' => true,
'sortable' => true,
'transition' => true,
),
],
// gateway
array(
[
'name' => 'gateway',
'type' => 'tinytext',
'default' => '',
'searchable' => true,
),
],
// signup_method
array(
[
'name' => 'signup_method',
'type' => 'tinytext',
'default' => '',
),
],
// subscription_key
array(
[
'name' => 'subscription_key',
'type' => 'varchar',
'length' => '32',
'default' => '',
'searchable' => true,
'sortable' => true,
),
],
// upgraded_from
array(
[
'name' => 'upgraded_from',
'type' => 'bigint',
'length' => '20',
'unsigned' => true,
'default' => '',
),
],
// date_modified
array(
[
'name' => 'date_modified',
'type' => 'datetime',
'default' => null,
'modified' => true,
'date_query' => true,
'sortable' => true,
),
],
// disabled
array(
[
'name' => 'disabled',
'type' => 'smallint',
'unsigned' => true,
'default' => '',
'pattern' => '%d',
),
],
);
];
}

View File

@ -50,9 +50,9 @@ final class Memberships_Table extends Table {
*
* @var array
*/
protected $upgrades = array(
protected $upgrades = [
'2.0.1-revision.20230601' => 20_230_601,
);
];
/**
* Memberships constructor.
@ -73,7 +73,7 @@ final class Memberships_Table extends Table {
* @since 2.0.0
* @return void
*/
protected function set_schema() {
protected function set_schema(): void {
$this->schema = "id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
customer_id bigint(20) unsigned NOT NULL default '0',
@ -119,7 +119,7 @@ final class Memberships_Table extends Table {
*/
protected function __20230601(): bool {
$null_columns = array(
$null_columns = [
'date_created',
'date_activated',
'date_trial_end',
@ -128,7 +128,7 @@ final class Memberships_Table extends Table {
'date_expiration',
'date_payment_plan_completed',
'date_modified',
);
];
foreach ($null_columns as $column) {
$query = "ALTER TABLE {$this->table_name} MODIFY COLUMN `{$column}` datetime DEFAULT NULL;";