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

@ -10,7 +10,7 @@ body {
content: " ";
position: absolute;
top: 30;
background: url("../../../assets/img/logo.png");
background: url("../../../assets/img/logo.webp");
background-size: contain;
height: 40px;
background-position: left center;

View File

@ -21,7 +21,7 @@ body {
content: " ";
position: absolute;
top: 30;
background: url("../../../assets/img/logo.png");
background: url("../../../assets/img/logo.webp");
background-size: contain;
height: 40px;
background-position: left center;

View File

@ -32,7 +32,7 @@ class Toolkit {
* @since 2.0.11
* @var array
*/
protected $wp_hooks = array();
protected $wp_hooks = [];
/**
* Listeners registered.
@ -40,7 +40,7 @@ class Toolkit {
* @since 2.0.11
* @var array
*/
protected $listeners = array();
protected $listeners = [];
/**
* Keeps track of number of listeners run.
@ -72,15 +72,15 @@ class Toolkit {
* @since 2.0.11
* @return void
*/
public function init() {
public function init(): void {
$this->register_default_listeners();
$this->load_sandbox();
add_filter('qm/collectors', array($this, 'register_collector_overview'), 1, 2);
add_filter('qm/collectors', [$this, 'register_collector_overview'], 1, 2);
add_filter('qm/outputter/html', array($this, 'add_overview_panel'), 50, 2);
add_filter('qm/outputter/html', [$this, 'add_overview_panel'], 50, 2);
}
/**
@ -95,7 +95,7 @@ class Toolkit {
* In the case of an empty listener name (?development)
* adds the listener link.
*/
$this->listen('index', array($this, 'render_listeners_menu'), 'init');
$this->listen('index', [$this, 'render_listeners_menu'], 'init');
/**
* Saves the rest endpoints to the mpb data folder
@ -103,9 +103,9 @@ class Toolkit {
*/
$this->listen('save-rest-arguments', '__return_false', 'wu_rest_get_endpoint_schema_use_cache');
$this->listen('save-rest-arguments', array($this, 'save_route_arguments'), 'wu_rest_register_routes_general');
$this->listen('save-rest-arguments', [$this, 'save_route_arguments'], 'wu_rest_register_routes_general');
$this->listen('save-rest-arguments', array($this, 'save_route_arguments'), 'wu_rest_register_routes_with_id');
$this->listen('save-rest-arguments', [$this, 'save_route_arguments'], 'wu_rest_register_routes_with_id');
}
/**
@ -119,7 +119,7 @@ class Toolkit {
* @param \WP_Ultimo\Traits\Rest_Api $manager The model manager instance.
* @return void
*/
public function save_route_arguments($routes, $path, $context, $manager) {
public function save_route_arguments($routes, $path, $context, $manager): void {
$class_name = str_replace('_', '-', strtolower($path));
@ -182,9 +182,9 @@ class Toolkit {
* @param array $configs The config constants.
* @return void
*/
public function config($configs = array()) {
public function config($configs = []): void {
$allowed_configs = array(
$allowed_configs = [
'QM_DARK_MODE',
'QM_DB_EXPENSIVE',
'QM_DISABLED',
@ -194,7 +194,7 @@ class Toolkit {
'QM_HIDE_SELF',
'QM_NO_JQUERY',
'QM_SHOW_ALL_HOOKS',
);
];
foreach ($configs as $constant_name => $constant_value) {
if (in_array($constant_name, $allowed_configs, true)) {
@ -212,7 +212,7 @@ class Toolkit {
* @param string|bool $should_die False to prevent it from dying, or a WordPress hook to wait before dying.
* @return void
*/
public function die($should_die = true) {
public function die($should_die = true): void {
if ($should_die === true) {
$should_die = is_admin() ? 'admin_enqueue_scripts' : 'wp_enqueue_scripts';
@ -230,7 +230,7 @@ class Toolkit {
* @param array $arguments The arguments passed to the WordPress hook.
* @return mixed
*/
public function run_listener($wp_hook, $arguments = array()) {
public function run_listener($wp_hook, $arguments = []) {
$listener = wu_request(self::LISTENER_PARAM, 'no-dev-param');
@ -275,7 +275,7 @@ class Toolkit {
add_action($wp_hook, fn(...$arguments) => $this->run_listener($wp_hook, $arguments), 0, 100);
}
add_action('shutdown', array($this, 'setup_query_monitor'));
add_action('shutdown', [$this, 'setup_query_monitor']);
if ($this->should_die) {
$this->dump_and_die(end($wp_hooks));
@ -288,7 +288,7 @@ class Toolkit {
* @since 2.0.11
* @return void
*/
public function setup_query_monitor() {
public function setup_query_monitor(): void {
if (class_exists('\QM_Dispatchers')) {
// phpcs:ignore
@ -358,9 +358,9 @@ class Toolkit {
printf('<link rel="stylesheet" id="toolkit" href="%s" type="text/css" media="all">', wu_url('inc/development/assets/development.css'));
wp_print_styles(
array(
[
'wu-admin',
)
]
);
$dispatcher->manually_print_assets(); // phpcs:ignore
@ -457,7 +457,7 @@ class Toolkit {
* @since 2.0.11
* @return void
*/
public function render_listeners_menu() {
public function render_listeners_menu(): void {
/**
* Make sure we display it only once.

View File

@ -32,7 +32,7 @@ class Collector_Overview extends \QM_Collector {
* @since 2.0.11
* @return void
*/
public function set_up() {
public function set_up(): void {
parent::set_up();
}
@ -43,7 +43,7 @@ class Collector_Overview extends \QM_Collector {
* @since 2.0.11
* @return void
*/
public function tear_down() {
public function tear_down(): void {
parent::tear_down();
}
@ -57,7 +57,7 @@ class Collector_Overview extends \QM_Collector {
* @since 2.0.11
* @return void
*/
public function process() {
public function process(): void {
$this->data = $_REQUEST;
}

View File

@ -30,9 +30,9 @@ class Overview extends \QM_Output_Html {
parent::__construct($collector);
add_filter('qm/output/menus', array($this, 'admin_menu'), 1000);
add_filter('qm/output/menus', [$this, 'admin_menu'], 1000);
add_filter('qm/output/panel_menus', array($this, 'panel_menu'), 1000);
add_filter('qm/output/panel_menus', [$this, 'panel_menu'], 1000);
}
/**
@ -52,7 +52,7 @@ class Overview extends \QM_Output_Html {
* @since 2.0.11
* @return void
*/
public function output() {
public function output(): void {
$data = $this->collector->get_data();
@ -102,14 +102,14 @@ class Overview extends \QM_Output_Html {
*/
public function panel_menu(array $menu) {
$new_menu = array(
$new_menu = [
'wp-ultimo' => $this->menu(
array(
[
'title' => esc_html__('WP Multisite WaaS', 'wp-ultimo'),
'id' => 'wp-ultimo',
)
]
),
);
];
return $new_menu + $menu;
}