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 Post_Query extends Query {
* @access public
* @var string
*/
protected $table_schema = '\\WP_Ultimo\\Database\\Posts\\Posts_Schema';
protected $table_schema = \WP_Ultimo\Database\Posts\Posts_Schema::class;
/** Item ******************************************************************/
@ -77,7 +77,7 @@ class Post_Query extends Query {
* @access public
* @var mixed
*/
protected $item_shape = '\\WP_Ultimo\\Models\\Post_Base_Model';
protected $item_shape = \WP_Ultimo\Models\Post_Base_Model::class;
/**
* Group to cache queries and queried items in.
@ -96,7 +96,7 @@ class Post_Query extends Query {
*
* @param string|array $query Array of query arguments.
*/
public function query($query = array()) {
public function query($query = []) {
if ( ! isset($query['type__in'])) {
$query['type'] = $this->item_name;

View File

@ -64,7 +64,7 @@ final class Posts_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,9 +28,9 @@ class Posts_Schema extends Schema {
* @access public
* @var array
*/
public $columns = array(
public $columns = [
array(
[
'name' => 'id',
'type' => 'bigint',
'length' => '20',
@ -38,51 +38,51 @@ class Posts_Schema extends Schema {
'extra' => 'auto_increment',
'primary' => true,
'sortable' => true,
),
],
array(
[
'name' => 'author_id',
'type' => 'bigint',
'length' => '20',
'unsigned' => true,
),
],
array(
[
'name' => 'type',
'type' => 'varchar',
'searchable' => true,
'sortable' => true,
),
],
array(
[
'name' => 'slug',
'type' => 'varchar',
'searchable' => true,
'sortable' => true,
),
],
array(
[
'name' => 'title',
'type' => 'varchar',
'searchable' => true,
'sortable' => true,
),
],
array(
[
'name' => 'content',
'type' => 'longtext',
'default' => '',
'searchable' => true,
),
],
array(
[
'name' => 'excerpt',
'type' => 'longtext',
'default' => '',
'searchable' => true,
),
],
array(
[
'name' => 'list_order',
'type' => 'tinyint',
'length' => '4',
@ -90,17 +90,17 @@ class Posts_Schema extends Schema {
'default' => 10,
'transition' => true,
'sortable' => true,
),
],
array(
[
'name' => 'status',
'type' => 'varchar', // An "enum" here would possibly limit custom post status.
'default' => 'draft',
'transition' => true,
'sortable' => true,
),
],
array(
[
'name' => 'date_created',
'type' => 'datetime',
'default' => null,
@ -108,9 +108,9 @@ class Posts_Schema extends Schema {
'date_query' => true,
'sortable' => true,
'allow_null' => true,
),
],
array(
[
'name' => 'date_modified',
'type' => 'datetime',
'default' => null,
@ -118,7 +118,7 @@ class Posts_Schema extends Schema {
'date_query' => true,
'sortable' => true,
'allow_null' => true,
),
],
);
];
}

View File

@ -50,9 +50,9 @@ final class Posts_Table extends Table {
*
* @var array
*/
protected $upgrades = array(
protected $upgrades = [
'2.0.1-revision.20230601' => 20_230_601,
);
];
/**
* Posts constructor.
@ -73,7 +73,7 @@ final class Posts_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,
author_id bigint(20) NOT NULL,
@ -95,10 +95,10 @@ final class Posts_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;";