Merge branch 'major-next' into command-alias-handling

This commit is contained in:
Dylan K. Taylor 2025-05-04 17:10:12 +01:00
commit 91dad0a5b5
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
7 changed files with 8 additions and 17 deletions

View File

@ -13,7 +13,7 @@ rules:
- pocketmine\phpstan\rules\DisallowDynamicNewRule
- pocketmine\phpstan\rules\DisallowForeachByReferenceRule
- pocketmine\phpstan\rules\ExplodeLimitRule
- pocketmine\phpstan\rules\UnsafeForeachArrayOfStringRule
- pocketmine\phpstan\rules\UnsafeForeachArrayWithStringKeysRule
# - pocketmine\phpstan\rules\ThreadedSupportedTypesRule
parameters:

View File

@ -26,7 +26,6 @@ namespace pocketmine\crash;
use Composer\InstalledVersions;
use pocketmine\errorhandler\ErrorTypeToStringMap;
use pocketmine\network\mcpe\protocol\ProtocolInfo;
use pocketmine\plugin\PluginBase;
use pocketmine\plugin\PluginManager;
use pocketmine\Server;
use pocketmine\thread\ThreadCrashInfoFrame;
@ -259,10 +258,8 @@ class CrashDump{
}
if(file_exists($filePath)){
$reflection = new \ReflectionClass(PluginBase::class);
$file = $reflection->getProperty("file");
foreach($this->server->getPluginManager()->getPlugins() as $plugin){
$filePath = Filesystem::cleanPath($file->getValue($plugin));
$filePath = Filesystem::cleanPath($plugin->getFile());
if(str_starts_with($frameCleanPath, $filePath)){
$this->data->plugin = $plugin->getName();
break;

View File

@ -34,7 +34,7 @@ use pocketmine\Server;
*/
interface Plugin{
public function __construct(PluginLoader $loader, Server $server, PluginDescription $description, string $dataFolder, string $file, string $resourceFolder);
public function __construct(Server $server, PluginDescription $description, string $dataFolder, string $file, string $resourceFolder);
public function isEnabled() : bool;
@ -59,7 +59,7 @@ interface Plugin{
public function getLogger() : \AttachableLogger;
public function getPluginLoader() : PluginLoader;
public function getFile() : string;
public function getScheduler() : TaskScheduler;

View File

@ -58,7 +58,6 @@ abstract class PluginBase implements Plugin, CommandExecutor{
private TaskScheduler $scheduler;
public function __construct(
private PluginLoader $loader,
private Server $server,
private PluginDescription $description,
private string $dataFolder,
@ -66,7 +65,6 @@ abstract class PluginBase implements Plugin, CommandExecutor{
private string $resourceFolder,
){
$this->dataFolder = rtrim($dataFolder, "/" . DIRECTORY_SEPARATOR) . "/";
//TODO: this is accessed externally via reflection, not unused
$this->file = rtrim($file, "/" . DIRECTORY_SEPARATOR) . "/";
$this->resourceFolder = rtrim(str_replace(DIRECTORY_SEPARATOR, "/", $resourceFolder), "/") . "/";
@ -301,14 +299,10 @@ abstract class PluginBase implements Plugin, CommandExecutor{
return $this->description->getFullName();
}
protected function getFile() : string{
public function getFile() : string{
return $this->file;
}
public function getPluginLoader() : PluginLoader{
return $this->loader;
}
public function getScheduler() : TaskScheduler{
return $this->scheduler;
}

View File

@ -220,7 +220,7 @@ class PluginManager{
* @var Plugin $plugin
* @see Plugin::__construct()
*/
$plugin = new $mainClass($loader, $this->server, $description, $dataFolder, $prefixed, $prefixed . "/resources/");
$plugin = new $mainClass($this->server, $description, $dataFolder, $prefixed, $prefixed . "/resources/");
$this->plugins[$plugin->getDescription()->getName()] = $plugin;
return $plugin;

View File

@ -256,5 +256,5 @@ parameters:
message: '#^Strict comparison using \=\=\= between 0 and 0 will always evaluate to true\.$#'
identifier: identical.alwaysTrue
count: 1
path: ../rules/UnsafeForeachArrayOfStringRule.php
path: ../rules/UnsafeForeachArrayWithStringKeysRule.php

View File

@ -41,7 +41,7 @@ use function sprintf;
/**
* @implements Rule<Foreach_>
*/
final class UnsafeForeachArrayOfStringRule implements Rule{
final class UnsafeForeachArrayWithStringKeysRule implements Rule{
public function getNodeType() : string{
return Foreach_::class;