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 Payment_Query extends Query {
* @access public
* @var string
*/
protected $table_schema = '\\WP_Ultimo\\Database\\Payments\\Payments_Schema';
protected $table_schema = \WP_Ultimo\Database\Payments\Payments_Schema::class;
/** Item ******************************************************************/
@ -77,7 +77,7 @@ class Payment_Query extends Query {
* @access public
* @var mixed
*/
protected $item_shape = '\\WP_Ultimo\\Models\\Payment';
protected $item_shape = \WP_Ultimo\Models\Payment::class;
/**
* Group to cache queries and queried items in.
@ -104,7 +104,7 @@ class Payment_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

@ -42,7 +42,7 @@ class Payment_Status extends Enum {
*/
protected function classes() {
return array(
return [
static::PENDING => 'wu-bg-gray-200 wu-text-gray-700',
static::COMPLETED => 'wu-bg-green-200 wu-text-green-700',
static::REFUND => 'wu-bg-blue-200 wu-text-gray-700',
@ -50,7 +50,7 @@ class Payment_Status extends Enum {
static::PARTIAL => 'wu-bg-yellow-200 wu-text-yellow-700',
static::FAILED => 'wu-bg-red-200 wu-text-red-700',
static::CANCELLED => 'wu-bg-orange-200 wu-text-orange-700',
);
];
}
/**
@ -61,7 +61,7 @@ class Payment_Status extends Enum {
*/
protected function icon_classes() {
return array(
return [
static::PENDING => 'wu-align-middle dashicons-wu-clock wu-text-gray-700',
static::COMPLETED => 'wu-align-middle dashicons-wu-check wu-text-green-700',
static::REFUND => 'wu-align-middle dashicons-wu-cw wu-text-gray-700',
@ -69,7 +69,7 @@ class Payment_Status extends Enum {
static::PARTIAL => 'wu-align-middle dashicons-wu-cw wu-text-yellow-700',
static::FAILED => 'wu-align-middle dashicons-wu-circle-with-cross wu-text-red-700',
static::CANCELLED => 'wu-align-middle dashicons-wu-circle-with-cross wu-text-orange-700',
);
];
}
/**
@ -80,7 +80,7 @@ class Payment_Status extends Enum {
*/
protected function labels() {
return array(
return [
static::PENDING => __('Pending', 'wp-ultimo'),
static::COMPLETED => __('Completed', 'wp-ultimo'),
static::REFUND => __('Refunded', 'wp-ultimo'),
@ -88,6 +88,6 @@ class Payment_Status extends Enum {
static::PARTIAL => __('Partially Paid', 'wp-ultimo'),
static::FAILED => __('Failed', 'wp-ultimo'),
static::CANCELLED => __('Cancelled', 'wp-ultimo'),
);
];
}
}

View File

@ -64,7 +64,7 @@ final class Payments_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 Payments_Schema extends Schema {
* @access public
* @var array
*/
public $columns = array(
public $columns = [
// id
array(
[
'name' => 'id',
'type' => 'bigint',
'length' => '20',
@ -40,152 +40,152 @@ class Payments_Schema extends Schema {
'primary' => true,
'sortable' => true,
'searchable' => true,
),
],
array(
[
'name' => 'status',
'type' => 'varchar',
'length' => '12',
'default' => 'pending',
'sortable' => true,
'transition' => true,
),
],
// customer_id
array(
[
'name' => 'customer_id',
'type' => 'bigint',
'length' => '20',
'unsigned' => true,
'transition' => true,
),
],
array(
[
'name' => 'membership_id',
'type' => 'bigint',
'length' => '20',
'unsigned' => true,
'transition' => true,
),
],
array(
[
'name' => 'parent_id',
'type' => 'bigint',
'length' => '20',
'unsigned' => true,
'transition' => true,
'sortable' => true,
),
],
array(
[
'name' => 'product_id',
'type' => 'bigint',
'length' => '20',
'unsigned' => true,
'sortable' => true,
'transition' => true,
),
],
array(
[
'name' => 'migrated_from_id',
'type' => 'bigint',
'length' => '20',
'unsigned' => true,
'sortable' => true,
'allow_null' => true,
),
],
// currency
array(
[
'name' => 'currency',
'type' => 'varchar',
'length' => '20',
'default' => 'USD',
'sortable' => true,
),
],
array(
[
'name' => 'discount_code',
'type' => 'tinytext',
'default' => '',
'searchable' => true,
'sortable' => true,
),
],
array(
[
'name' => 'discount_total',
'type' => 'decimal(13,4)',
'default' => '',
'sortable' => true,
),
],
array(
[
'name' => 'subtotal',
'type' => 'decimal(13,4)',
'default' => '',
'sortable' => true,
'transition' => true,
),
],
array(
[
'name' => 'refund_total',
'type' => 'decimal(13,4)',
'default' => '',
'sortable' => true,
'transition' => true,
),
],
array(
[
'name' => 'tax_total',
'type' => 'decimal(13,4)',
'default' => '',
'sortable' => true,
'transition' => true,
),
],
array(
[
'name' => 'total',
'type' => 'decimal(13,4)',
'default' => '',
'sortable' => true,
'transition' => true,
),
],
// gateway
array(
[
'name' => 'gateway',
'type' => 'tinytext',
'default' => '',
'searchable' => true,
),
],
// gateway
array(
[
'name' => 'gateway_payment_id',
'type' => 'tinytext',
'default' => '',
'searchable' => true,
),
],
// date_created
array(
[
'name' => 'date_created',
'type' => 'datetime',
'created' => true,
'date_query' => true,
'sortable' => true,
'allow_null' => true,
),
],
// date_modified
array(
[
'name' => 'date_modified',
'type' => 'datetime',
'modified' => true,
'date_query' => true,
'sortable' => true,
'allow_null' => true,
),
],
);
];
}

View File

@ -50,11 +50,11 @@ final class Payments_Table extends Table {
*
* @var array
*/
protected $upgrades = array(
protected $upgrades = [
'2.0.1-revision.20210417' => 20_210_417,
'2.0.1-revision.20210607' => 20_210_607,
'2.0.1-revision.20230601' => 20_230_601,
);
];
/**
* Payments constructor.
@ -75,7 +75,7 @@ final class Payments_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,
status varchar(20) NOT NULL DEFAULT 'pending',
@ -162,10 +162,10 @@ final class Payments_Table extends Table {
*/
protected function __20230601(): bool {
$null_columns = array(
$null_columns = [
'date_created',
'date_modified',
);
];
foreach ($null_columns as $column) {
$query = "ALTER TABLE {$this->table_name} MODIFY COLUMN `{$column}` datetime DEFAULT NULL;";