From 03f47d0a782478a9706f3429b71b201b5ef6d0df Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 20 Jan 2022 19:19:20 +0000 Subject: [PATCH] Replace disallowed operators in src/plugin/ --- src/plugin/ApiVersion.php | 2 +- src/plugin/PharPluginLoader.php | 2 +- src/plugin/PluginBase.php | 6 +++--- src/plugin/PluginDescription.php | 2 +- src/plugin/PluginLoadabilityChecker.php | 4 ++-- src/plugin/PluginManager.php | 14 +++++++------- src/plugin/ScriptPluginLoader.php | 2 +- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/plugin/ApiVersion.php b/src/plugin/ApiVersion.php index 5a2bb035b..3842c1af5 100644 --- a/src/plugin/ApiVersion.php +++ b/src/plugin/ApiVersion.php @@ -53,7 +53,7 @@ final class ApiVersion{ continue; } - if($version->getMinor() === $myVersion->getMinor() and $version->getPatch() > $myVersion->getPatch()){ //If the plugin requires bug fixes in patches, being backwards compatible + if($version->getMinor() === $myVersion->getMinor() && $version->getPatch() > $myVersion->getPatch()){ //If the plugin requires bug fixes in patches, being backwards compatible continue; } } diff --git a/src/plugin/PharPluginLoader.php b/src/plugin/PharPluginLoader.php index d42fa0b5e..e036099e8 100644 --- a/src/plugin/PharPluginLoader.php +++ b/src/plugin/PharPluginLoader.php @@ -41,7 +41,7 @@ class PharPluginLoader implements PluginLoader{ public function canLoadPlugin(string $path) : bool{ $ext = ".phar"; - return is_file($path) and substr($path, -strlen($ext)) === $ext; + return is_file($path) && substr($path, -strlen($ext)) === $ext; } /** diff --git a/src/plugin/PluginBase.php b/src/plugin/PluginBase.php index 32b30794e..fdf47d39c 100644 --- a/src/plugin/PluginBase.php +++ b/src/plugin/PluginBase.php @@ -209,11 +209,11 @@ abstract class PluginBase implements Plugin, CommandExecutor{ */ public function getCommand(string $name){ $command = $this->getServer()->getPluginCommand($name); - if($command === null or $command->getOwningPlugin() !== $this){ + if($command === null || $command->getOwningPlugin() !== $this){ $command = $this->getServer()->getPluginCommand(strtolower($this->description->getName()) . ":" . $name); } - if($command instanceof PluginOwned and $command->getOwningPlugin() === $this){ + if($command instanceof PluginOwned && $command->getOwningPlugin() === $this){ return $command; }else{ return null; @@ -254,7 +254,7 @@ abstract class PluginBase implements Plugin, CommandExecutor{ mkdir(dirname($out), 0755, true); } - if(file_exists($out) and !$replace){ + if(file_exists($out) && !$replace){ return false; } diff --git a/src/plugin/PluginDescription.php b/src/plugin/PluginDescription.php index 22949e673..0bd7587bb 100644 --- a/src/plugin/PluginDescription.php +++ b/src/plugin/PluginDescription.php @@ -124,7 +124,7 @@ class PluginDescription{ $this->compatibleMcpeProtocols = array_map("\intval", (array) ($plugin["mcpe-protocol"] ?? [])); $this->compatibleOperatingSystems = array_map("\strval", (array) ($plugin["os"] ?? [])); - if(isset($plugin["commands"]) and is_array($plugin["commands"])){ + if(isset($plugin["commands"]) && is_array($plugin["commands"])){ foreach($plugin["commands"] as $commandName => $commandData){ if(!is_string($commandName)){ throw new PluginDescriptionParseException("Invalid Plugin commands, key must be the name of the command"); diff --git a/src/plugin/PluginLoadabilityChecker.php b/src/plugin/PluginLoadabilityChecker.php index 4451cc6f1..216f70129 100644 --- a/src/plugin/PluginLoadabilityChecker.php +++ b/src/plugin/PluginLoadabilityChecker.php @@ -47,7 +47,7 @@ final class PluginLoadabilityChecker{ public function check(PluginDescription $description) : Translatable|null{ $name = $description->getName(); - if(stripos($name, "pocketmine") !== false or stripos($name, "minecraft") !== false or stripos($name, "mojang") !== false){ + if(stripos($name, "pocketmine") !== false || stripos($name, "minecraft") !== false || stripos($name, "mojang") !== false){ return KnownTranslationFactory::pocketmine_plugin_restrictedName(); } @@ -66,7 +66,7 @@ final class PluginLoadabilityChecker{ return KnownTranslationFactory::pocketmine_plugin_ambiguousMinAPI(implode(", ", $ambiguousVersions)); } - if(count($description->getCompatibleOperatingSystems()) > 0 and !in_array(Utils::getOS(), $description->getCompatibleOperatingSystems(), true)) { + if(count($description->getCompatibleOperatingSystems()) > 0 && !in_array(Utils::getOS(), $description->getCompatibleOperatingSystems(), true)) { return KnownTranslationFactory::pocketmine_plugin_incompatibleOS(implode(", ", $description->getCompatibleOperatingSystems())); } diff --git a/src/plugin/PluginManager.php b/src/plugin/PluginManager.php index 49f8ed06b..529fe5bbe 100644 --- a/src/plugin/PluginManager.php +++ b/src/plugin/PluginManager.php @@ -137,7 +137,7 @@ class PluginManager{ $this->server->getLogger()->info($this->server->getLanguage()->translate(KnownTranslationFactory::pocketmine_plugin_load($description->getFullName()))); $dataFolder = $this->getDataDirectory($path, $description->getName()); - if(file_exists($dataFolder) and !is_dir($dataFolder)){ + if(file_exists($dataFolder) && !is_dir($dataFolder)){ $this->server->getLogger()->error($language->translate(KnownTranslationFactory::pocketmine_plugin_loadError( $description->getName(), KnownTranslationFactory::pocketmine_plugin_badDataFolder($dataFolder) @@ -274,7 +274,7 @@ class PluginManager{ continue; } - if(isset($triage->plugins[$name]) or $this->getPlugin($name) instanceof Plugin){ + if(isset($triage->plugins[$name]) || $this->getPlugin($name) instanceof Plugin){ $this->server->getLogger()->error($this->server->getLanguage()->translate(KnownTranslationFactory::pocketmine_plugin_duplicateError($name))); continue; } @@ -283,7 +283,7 @@ class PluginManager{ $this->server->getLogger()->warning($this->server->getLanguage()->translate(KnownTranslationFactory::pocketmine_plugin_spacesDiscouraged($name))); } - if($this->graylist !== null and !$this->graylist->isAllowed($name)){ + if($this->graylist !== null && !$this->graylist->isAllowed($name)){ $this->server->getLogger()->notice($this->server->getLanguage()->translate(KnownTranslationFactory::pocketmine_plugin_loadError( $name, $this->graylist->isWhitelist() ? KnownTranslationFactory::pocketmine_plugin_disallowedByWhitelist() : KnownTranslationFactory::pocketmine_plugin_disallowedByBlacklist() @@ -314,7 +314,7 @@ class PluginManager{ private function checkDepsForTriage(string $pluginName, string $dependencyType, array &$dependencyLists, array $loadedPlugins, PluginLoadTriage $triage) : void{ if(isset($dependencyLists[$pluginName])){ foreach($dependencyLists[$pluginName] as $key => $dependency){ - if(isset($loadedPlugins[$dependency]) or $this->getPlugin($dependency) instanceof Plugin){ + if(isset($loadedPlugins[$dependency]) || $this->getPlugin($dependency) instanceof Plugin){ $this->server->getLogger()->debug("Successfully resolved $dependencyType dependency \"$dependency\" for plugin \"$pluginName\""); unset($dependencyLists[$pluginName][$key]); }elseif(array_key_exists($dependency, $triage->plugins)){ @@ -348,7 +348,7 @@ class PluginManager{ $this->checkDepsForTriage($name, "hard", $triage->dependencies, $loadedPlugins, $triage); $this->checkDepsForTriage($name, "soft", $triage->softDependencies, $loadedPlugins, $triage); - if(!isset($triage->dependencies[$name]) and !isset($triage->softDependencies[$name])){ + if(!isset($triage->dependencies[$name]) && !isset($triage->softDependencies[$name])){ unset($triage->plugins[$name]); $loadedThisLoop++; @@ -426,7 +426,7 @@ class PluginManager{ } public function isPluginEnabled(Plugin $plugin) : bool{ - return isset($this->plugins[$plugin->getDescription()->getName()]) and $plugin->isEnabled(); + return isset($this->plugins[$plugin->getDescription()->getName()]) && $plugin->isEnabled(); } public function enablePlugin(Plugin $plugin) : void{ @@ -485,7 +485,7 @@ class PluginManager{ * @phpstan-return class-string|null */ private function getEventsHandledBy(\ReflectionMethod $method) : ?string{ - if($method->isStatic() or !$method->getDeclaringClass()->implementsInterface(Listener::class)){ + if($method->isStatic() || !$method->getDeclaringClass()->implementsInterface(Listener::class)){ return null; } $tags = Utils::parseDocComment((string) $method->getDocComment()); diff --git a/src/plugin/ScriptPluginLoader.php b/src/plugin/ScriptPluginLoader.php index f446be72c..ccf4c8a01 100644 --- a/src/plugin/ScriptPluginLoader.php +++ b/src/plugin/ScriptPluginLoader.php @@ -42,7 +42,7 @@ class ScriptPluginLoader implements PluginLoader{ public function canLoadPlugin(string $path) : bool{ $ext = ".php"; - return is_file($path) and substr($path, -strlen($ext)) === $ext; + return is_file($path) && substr($path, -strlen($ext)) === $ext; } /**