Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PHP warnings #18

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions includes/Models/PriorityQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
10 changes: 5 additions & 5 deletions includes/Services/PluginInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down
Loading