From 9aeae86b5386a027df339d78dc564358b9695a62 Mon Sep 17 00:00:00 2001 From: arunshenoy99 Date: Tue, 19 Mar 2024 14:02:11 +0530 Subject: [PATCH] Fix PHP warnings --- includes/Models/PriorityQueue.php | 14 -------------- includes/Services/PluginInstaller.php | 10 +++++----- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/includes/Models/PriorityQueue.php b/includes/Models/PriorityQueue.php index ac2b52a..29bb0b9 100644 --- a/includes/Models/PriorityQueue.php +++ b/includes/Models/PriorityQueue.php @@ -6,20 +6,6 @@ */ class PriorityQueue extends \SplPriorityQueue { - /** - * Defines the logic to use when comparing two priorities. - * - * @param mixed $priority1 First Priority Queue - * @param mixed $priority2 Second Priority Queue - * @return int - */ - public function compare( $priority1, $priority2 ) : int { - if ( $priority1 === $priority2 ) { - return 0; - } - return $priority1 < $priority2 ? -1 : 1; - } - /** * Converts the max heap to an array. * diff --git a/includes/Services/PluginInstaller.php b/includes/Services/PluginInstaller.php index 7ceb0da..ad8cf69 100644 --- a/includes/Services/PluginInstaller.php +++ b/includes/Services/PluginInstaller.php @@ -309,11 +309,11 @@ public static function get_plugin_type( $plugin ) { * * @param string $plugin The slug of the plugin. * @param string $plugin_type The type of plugin. - * @return string + * @return string|false */ public static function get_plugin_path( $plugin, $plugin_type ) { $plugin_list = Plugins::get(); - return $plugin_list[ $plugin_type ][ $plugin ]['path']; + return isset( $plugin_list[ $plugin_type ][ $plugin ] ) ? $plugin_list[ $plugin_type ][ $plugin ]['path'] : false; } /** @@ -326,7 +326,7 @@ public static function get_plugin_path( $plugin, $plugin_type ) { public static function exists( $plugin, $activate ) { $plugin_type = self::get_plugin_type( $plugin ); $plugin_path = self::get_plugin_path( $plugin, $plugin_type ); - if ( ! self::is_plugin_installed( $plugin_path ) ) { + if ( ! ( $plugin_path && self::is_plugin_installed( $plugin_path ) ) ) { return false; } @@ -355,7 +355,7 @@ public static function is_active( $plugin_path ) { public static function activate( $plugin ) { $plugin_type = self::get_plugin_type( $plugin ); $plugin_path = self::get_plugin_path( $plugin, $plugin_type ); - if ( ! self::is_plugin_installed( $plugin_path ) ) { + if ( ! ( $plugin_path && self::is_plugin_installed( $plugin_path ) ) ) { return false; } @@ -376,7 +376,7 @@ public static function activate( $plugin ) { public static function deactivate( $plugin ) { $plugin_type = self::get_plugin_type( $plugin ); $plugin_path = self::get_plugin_path( $plugin, $plugin_type ); - if ( ! self::is_plugin_installed( $plugin_path ) ) { + if ( ! ( $plugin_path && self::is_plugin_installed( $plugin_path ) ) ) { return false; }