Use PHP 7.4 featers and PHP 8 polyfills
This commit is contained in:
@ -48,7 +48,7 @@ class Product_Query extends Query {
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
protected $table_schema = '\\WP_Ultimo\\Database\\Products\\Products_Schema';
|
||||
protected $table_schema = \WP_Ultimo\Database\Products\Products_Schema::class;
|
||||
|
||||
/** Item ******************************************************************/
|
||||
|
||||
@ -77,7 +77,7 @@ class Product_Query extends Query {
|
||||
* @access public
|
||||
* @var mixed
|
||||
*/
|
||||
protected $item_shape = '\\WP_Ultimo\\Models\\Product';
|
||||
protected $item_shape = \WP_Ultimo\Models\Product::class;
|
||||
|
||||
/**
|
||||
* Group to cache queries and queried items in.
|
||||
@ -104,7 +104,7 @@ class Product_Query extends Query {
|
||||
*
|
||||
* @param string|array $query Array of query arguments.
|
||||
*/
|
||||
public function __construct($query = array()) {
|
||||
public function __construct($query = []) {
|
||||
|
||||
parent::__construct($query);
|
||||
}
|
||||
|
@ -38,11 +38,11 @@ class Product_Type extends Enum {
|
||||
*/
|
||||
protected function classes() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
static::PLAN => 'wu-bg-green-200 wu-text-green-700',
|
||||
static::PACKAGE => 'wu-bg-gray-200 wu-text-blue-700',
|
||||
static::SERVICE => 'wu-bg-yellow-200 wu-text-yellow-700',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -53,10 +53,10 @@ class Product_Type extends Enum {
|
||||
*/
|
||||
protected function labels() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
static::PLAN => __('Plan', 'wp-ultimo'),
|
||||
static::PACKAGE => __('Package', 'wp-ultimo'),
|
||||
static::SERVICE => __('Service', 'wp-ultimo'),
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ final class Products_Meta_Table extends Table {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
protected function set_schema() {
|
||||
protected function set_schema(): void {
|
||||
|
||||
$max_index_length = 191;
|
||||
|
||||
|
@ -28,9 +28,9 @@ class Products_Schema extends Schema {
|
||||
* @access public
|
||||
* @var array
|
||||
*/
|
||||
public $columns = array(
|
||||
public $columns = [
|
||||
|
||||
array(
|
||||
[
|
||||
'name' => 'id',
|
||||
'type' => 'bigint',
|
||||
'length' => '20',
|
||||
@ -38,16 +38,16 @@ class Products_Schema extends Schema {
|
||||
'extra' => 'auto_increment',
|
||||
'primary' => true,
|
||||
'sortable' => true,
|
||||
),
|
||||
],
|
||||
|
||||
array(
|
||||
[
|
||||
'name' => 'slug',
|
||||
'type' => 'varchar',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
),
|
||||
],
|
||||
|
||||
array(
|
||||
[
|
||||
'name' => 'parent_id',
|
||||
'type' => 'bigint',
|
||||
'length' => '20',
|
||||
@ -55,72 +55,72 @@ class Products_Schema extends Schema {
|
||||
'sortable' => true,
|
||||
'transition' => true,
|
||||
'allow_null' => true,
|
||||
),
|
||||
],
|
||||
|
||||
array(
|
||||
[
|
||||
'name' => 'migrated_from_id',
|
||||
'type' => 'bigint',
|
||||
'length' => '20',
|
||||
'unsigned' => true,
|
||||
'sortable' => true,
|
||||
'allow_null' => true,
|
||||
),
|
||||
],
|
||||
|
||||
array(
|
||||
[
|
||||
'name' => 'name',
|
||||
'type' => 'varchar',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
),
|
||||
],
|
||||
|
||||
array(
|
||||
[
|
||||
'name' => 'description',
|
||||
'type' => 'longtext',
|
||||
'default' => '',
|
||||
'searchable' => true,
|
||||
),
|
||||
],
|
||||
|
||||
array(
|
||||
[
|
||||
'name' => 'product_group',
|
||||
'type' => 'varchar',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'allow_null' => true,
|
||||
),
|
||||
],
|
||||
|
||||
array(
|
||||
[
|
||||
'name' => 'currency',
|
||||
'type' => 'varchar',
|
||||
'length' => '10',
|
||||
'default' => 'USD',
|
||||
'sortable' => true,
|
||||
),
|
||||
],
|
||||
|
||||
array(
|
||||
[
|
||||
'name' => 'pricing_type',
|
||||
'type' => 'varchar',
|
||||
'length' => '10',
|
||||
'default' => 'paid',
|
||||
'sortable' => true,
|
||||
),
|
||||
],
|
||||
|
||||
array(
|
||||
[
|
||||
'name' => 'amount',
|
||||
'type' => 'decimal(13,4)',
|
||||
'default' => '',
|
||||
'sortable' => true,
|
||||
'transition' => true,
|
||||
),
|
||||
],
|
||||
|
||||
array(
|
||||
[
|
||||
'name' => 'setup_fee',
|
||||
'type' => 'decimal(13,4)',
|
||||
'default' => '',
|
||||
'sortable' => true,
|
||||
'transition' => true,
|
||||
),
|
||||
],
|
||||
|
||||
array(
|
||||
[
|
||||
'name' => 'recurring',
|
||||
'type' => 'tinyint',
|
||||
'length' => '4',
|
||||
@ -128,48 +128,48 @@ class Products_Schema extends Schema {
|
||||
'default' => 1,
|
||||
'transition' => true,
|
||||
'sortable' => true,
|
||||
),
|
||||
],
|
||||
|
||||
array(
|
||||
[
|
||||
'name' => 'trial_duration',
|
||||
'type' => 'smallint',
|
||||
'unsigned' => true,
|
||||
'default' => '0',
|
||||
'sortable' => true,
|
||||
'transition' => true,
|
||||
),
|
||||
],
|
||||
|
||||
array(
|
||||
[
|
||||
'name' => 'trial_duration_unit',
|
||||
'type' => 'enum(\'day\', \'month\', \'week\', \'year\')',
|
||||
'default' => 'none',
|
||||
),
|
||||
],
|
||||
|
||||
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' => 'billing_cycles',
|
||||
'type' => 'smallint',
|
||||
'unsigned' => true,
|
||||
'default' => '0',
|
||||
'sortable' => true,
|
||||
'transition' => true,
|
||||
),
|
||||
],
|
||||
|
||||
array(
|
||||
[
|
||||
'name' => 'list_order',
|
||||
'type' => 'tinyint',
|
||||
'length' => '4',
|
||||
@ -177,9 +177,9 @@ class Products_Schema extends Schema {
|
||||
'default' => 10,
|
||||
'transition' => true,
|
||||
'sortable' => true,
|
||||
),
|
||||
],
|
||||
|
||||
array(
|
||||
[
|
||||
'name' => 'active',
|
||||
'type' => 'tinyint',
|
||||
'length' => '4',
|
||||
@ -187,9 +187,9 @@ class Products_Schema extends Schema {
|
||||
'default' => 1,
|
||||
'transition' => true,
|
||||
'sortable' => true,
|
||||
),
|
||||
],
|
||||
|
||||
array(
|
||||
[
|
||||
'name' => 'date_created',
|
||||
'type' => 'datetime',
|
||||
'default' => null,
|
||||
@ -197,9 +197,9 @@ class Products_Schema extends Schema {
|
||||
'date_query' => true,
|
||||
'sortable' => true,
|
||||
'allow_null' => true,
|
||||
),
|
||||
],
|
||||
|
||||
array(
|
||||
[
|
||||
'name' => 'date_modified',
|
||||
'type' => 'datetime',
|
||||
'default' => null,
|
||||
@ -207,14 +207,14 @@ class Products_Schema extends Schema {
|
||||
'date_query' => true,
|
||||
'sortable' => true,
|
||||
'allow_null' => true,
|
||||
),
|
||||
],
|
||||
|
||||
array(
|
||||
[
|
||||
'name' => 'type',
|
||||
'type' => 'varchar',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
),
|
||||
],
|
||||
|
||||
);
|
||||
];
|
||||
}
|
||||
|
@ -50,11 +50,11 @@ final class Products_Table extends Table {
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $upgrades = array(
|
||||
protected $upgrades = [
|
||||
'2.0.1-revision.20210419' => 20_210_419,
|
||||
'2.0.1-revision.20210607' => 20_210_607,
|
||||
'2.0.1-revision.20230601' => 20_230_601,
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Products constructor.
|
||||
@ -75,7 +75,7 @@ final class Products_Table extends Table {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
protected function set_schema() {
|
||||
protected function set_schema(): void {
|
||||
|
||||
$this->schema = "id bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
name tinytext NOT NULL DEFAULT '',
|
||||
@ -161,10 +161,10 @@ final class Products_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;";
|
||||
|
Reference in New Issue
Block a user