Replace disallowed operators in src/plugin/

This commit is contained in:
Dylan K. Taylor 2022-01-20 19:19:20 +00:00
parent 3f8f5cd200
commit 03f47d0a78
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
7 changed files with 16 additions and 16 deletions

View File

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

View File

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

View File

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

View File

@ -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");

View File

@ -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()));
}

View File

@ -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<Event>|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());

View File

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