Use PHP 7.4 featers and PHP 8 polyfills
This commit is contained in:
@ -48,7 +48,7 @@ class Discount_Code_Query extends Query {
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
protected $table_schema = '\\WP_Ultimo\\Database\\Discount_Codes\\Discount_Codes_Schema';
|
||||
protected $table_schema = \WP_Ultimo\Database\Discount_Codes\Discount_Codes_Schema::class;
|
||||
|
||||
/** Item ******************************************************************/
|
||||
|
||||
@ -77,7 +77,7 @@ class Discount_Code_Query extends Query {
|
||||
* @access public
|
||||
* @var mixed
|
||||
*/
|
||||
protected $item_shape = '\\WP_Ultimo\\Models\\Discount_Code';
|
||||
protected $item_shape = \WP_Ultimo\Models\Discount_Code::class;
|
||||
|
||||
/**
|
||||
* Group to cache queries and queried items in.
|
||||
@ -104,7 +104,7 @@ class Discount_Code_Query extends Query {
|
||||
*
|
||||
* @param string|array $query Array of query arguments.
|
||||
*/
|
||||
public function __construct($query = array()) {
|
||||
public function __construct($query = []) {
|
||||
|
||||
parent::__construct($query);
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ final class Discount_Codes_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 Discount_Codes_Schema extends Schema {
|
||||
* @access public
|
||||
* @var array
|
||||
*/
|
||||
public $columns = array(
|
||||
public $columns = [
|
||||
|
||||
array(
|
||||
[
|
||||
'name' => 'id',
|
||||
'type' => 'bigint',
|
||||
'length' => '20',
|
||||
@ -38,40 +38,40 @@ class Discount_Codes_Schema extends Schema {
|
||||
'extra' => 'auto_increment',
|
||||
'primary' => true,
|
||||
'sortable' => true,
|
||||
),
|
||||
],
|
||||
|
||||
array(
|
||||
[
|
||||
'name' => 'name',
|
||||
'type' => 'varchar',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
),
|
||||
],
|
||||
|
||||
array(
|
||||
[
|
||||
'name' => 'code',
|
||||
'type' => 'varchar',
|
||||
'length' => '20',
|
||||
'sortable' => true,
|
||||
'searchable' => true,
|
||||
'transition' => true,
|
||||
),
|
||||
],
|
||||
|
||||
array(
|
||||
[
|
||||
'name' => 'description',
|
||||
'type' => 'longtext',
|
||||
'default' => '',
|
||||
'searchable' => true,
|
||||
),
|
||||
],
|
||||
|
||||
array(
|
||||
[
|
||||
'name' => 'uses',
|
||||
'type' => 'int',
|
||||
'unsigned' => true,
|
||||
'sortable' => true,
|
||||
'transition' => true,
|
||||
),
|
||||
],
|
||||
|
||||
array(
|
||||
[
|
||||
'name' => 'max_uses',
|
||||
'type' => 'int',
|
||||
'unsigned' => true,
|
||||
@ -79,9 +79,9 @@ class Discount_Codes_Schema extends Schema {
|
||||
'transition' => true,
|
||||
'allow_null' => true,
|
||||
'default' => 0,
|
||||
),
|
||||
],
|
||||
|
||||
array(
|
||||
[
|
||||
'name' => 'apply_to_renewals',
|
||||
'type' => 'tinyint',
|
||||
'length' => '4',
|
||||
@ -89,39 +89,39 @@ class Discount_Codes_Schema extends Schema {
|
||||
'default' => 0,
|
||||
'transition' => true,
|
||||
'sortable' => true,
|
||||
),
|
||||
],
|
||||
|
||||
array(
|
||||
[
|
||||
'name' => 'type',
|
||||
'type' => 'enum(\'percentage\', \'absolute\')',
|
||||
'default' => 'percentage',
|
||||
'transition' => true,
|
||||
),
|
||||
],
|
||||
|
||||
array(
|
||||
[
|
||||
'name' => 'value',
|
||||
'type' => 'decimal(13,4)',
|
||||
'default' => '',
|
||||
'sortable' => true,
|
||||
'transition' => true,
|
||||
),
|
||||
],
|
||||
|
||||
array(
|
||||
[
|
||||
'name' => 'setup_fee_type',
|
||||
'type' => 'enum(\'percentage\', \'absolute\')',
|
||||
'default' => 'percentage',
|
||||
'transition' => true,
|
||||
),
|
||||
],
|
||||
|
||||
array(
|
||||
[
|
||||
'name' => 'setup_fee_value',
|
||||
'type' => 'decimal(13,4)',
|
||||
'default' => '',
|
||||
'sortable' => true,
|
||||
'transition' => true,
|
||||
),
|
||||
],
|
||||
|
||||
array(
|
||||
[
|
||||
'name' => 'active',
|
||||
'type' => 'tinyint',
|
||||
'length' => '4',
|
||||
@ -129,9 +129,9 @@ class Discount_Codes_Schema extends Schema {
|
||||
'default' => 1,
|
||||
'transition' => true,
|
||||
'sortable' => true,
|
||||
),
|
||||
],
|
||||
|
||||
array(
|
||||
[
|
||||
'name' => 'date_start',
|
||||
'type' => 'datetime',
|
||||
'default' => null,
|
||||
@ -139,9 +139,9 @@ class Discount_Codes_Schema extends Schema {
|
||||
'sortable' => true,
|
||||
'transition' => true,
|
||||
'allow_null' => true,
|
||||
),
|
||||
],
|
||||
|
||||
array(
|
||||
[
|
||||
'name' => 'date_expiration',
|
||||
'type' => 'datetime',
|
||||
'default' => null,
|
||||
@ -149,9 +149,9 @@ class Discount_Codes_Schema extends Schema {
|
||||
'sortable' => true,
|
||||
'transition' => true,
|
||||
'allow_null' => true,
|
||||
),
|
||||
],
|
||||
|
||||
array(
|
||||
[
|
||||
'name' => 'date_created',
|
||||
'type' => 'datetime',
|
||||
'default' => null,
|
||||
@ -159,9 +159,9 @@ class Discount_Codes_Schema extends Schema {
|
||||
'date_query' => true,
|
||||
'sortable' => true,
|
||||
'allow_null' => true,
|
||||
),
|
||||
],
|
||||
|
||||
array(
|
||||
[
|
||||
'name' => 'date_modified',
|
||||
'type' => 'datetime',
|
||||
'default' => null,
|
||||
@ -169,7 +169,7 @@ class Discount_Codes_Schema extends Schema {
|
||||
'date_query' => true,
|
||||
'sortable' => true,
|
||||
'allow_null' => true,
|
||||
),
|
||||
],
|
||||
|
||||
);
|
||||
];
|
||||
}
|
||||
|
@ -50,9 +50,9 @@ final class Discount_Codes_Table extends Table {
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $upgrades = array(
|
||||
protected $upgrades = [
|
||||
'2.0.1-revision.20230601' => 20_230_601,
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Discount_Code constructor.
|
||||
@ -73,7 +73,7 @@ final class Discount_Codes_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 '',
|
||||
@ -100,10 +100,10 @@ final class Discount_Codes_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