mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-20 16:00:20 +00:00
Modernize private property declarations in src/plugin
This commit is contained in:
parent
7bc3dcdefd
commit
c60311617d
@ -38,9 +38,7 @@ use const DIRECTORY_SEPARATOR;
|
||||
* to enable special types of access.
|
||||
*/
|
||||
class DiskResourceProvider implements ResourceProvider{
|
||||
|
||||
/** @var string */
|
||||
private $file;
|
||||
private string $file;
|
||||
|
||||
public function __construct(string $path){
|
||||
$this->file = rtrim(str_replace(DIRECTORY_SEPARATOR, "/", $path), "/") . "/";
|
||||
|
@ -31,13 +31,9 @@ use function substr;
|
||||
* Handles different types of plugins
|
||||
*/
|
||||
class PharPluginLoader implements PluginLoader{
|
||||
|
||||
/** @var \DynamicClassLoader */
|
||||
private $loader;
|
||||
|
||||
public function __construct(\DynamicClassLoader $loader){
|
||||
$this->loader = $loader;
|
||||
}
|
||||
public function __construct(
|
||||
private \DynamicClassLoader $loader
|
||||
){}
|
||||
|
||||
public function canLoadPlugin(string $path) : bool{
|
||||
$ext = ".phar";
|
||||
|
@ -47,41 +47,22 @@ use function strtolower;
|
||||
use function trim;
|
||||
|
||||
abstract class PluginBase implements Plugin, CommandExecutor{
|
||||
private bool $isEnabled = false;
|
||||
|
||||
/** @var PluginLoader */
|
||||
private $loader;
|
||||
private ?Config $config = null;
|
||||
private string $configFile;
|
||||
|
||||
/** @var Server */
|
||||
private $server;
|
||||
private PluginLogger $logger;
|
||||
private TaskScheduler $scheduler;
|
||||
|
||||
/** @var bool */
|
||||
private $isEnabled = false;
|
||||
|
||||
/** @var PluginDescription */
|
||||
private $description;
|
||||
|
||||
/** @var string */
|
||||
private $dataFolder;
|
||||
/** @var Config|null */
|
||||
private $config = null;
|
||||
/** @var string */
|
||||
private $configFile;
|
||||
/** @var string */
|
||||
private $file;
|
||||
|
||||
/** @var PluginLogger */
|
||||
private $logger;
|
||||
|
||||
/** @var TaskScheduler */
|
||||
private $scheduler;
|
||||
|
||||
/** @var ResourceProvider */
|
||||
private $resourceProvider;
|
||||
|
||||
public function __construct(PluginLoader $loader, Server $server, PluginDescription $description, string $dataFolder, string $file, ResourceProvider $resourceProvider){
|
||||
$this->loader = $loader;
|
||||
$this->server = $server;
|
||||
$this->description = $description;
|
||||
public function __construct(
|
||||
private PluginLoader $loader,
|
||||
private Server $server,
|
||||
private PluginDescription $description,
|
||||
private string $dataFolder,
|
||||
private string $file,
|
||||
private ResourceProvider $resourceProvider
|
||||
){
|
||||
$this->dataFolder = rtrim($dataFolder, "/" . DIRECTORY_SEPARATOR) . "/";
|
||||
//TODO: this is accessed externally via reflection, not unused
|
||||
$this->file = rtrim($file, "/" . DIRECTORY_SEPARATOR) . "/";
|
||||
@ -90,7 +71,6 @@ abstract class PluginBase implements Plugin, CommandExecutor{
|
||||
$prefix = $this->getDescription()->getPrefix();
|
||||
$this->logger = new PluginLogger($server->getLogger(), $prefix !== "" ? $prefix : $this->getName());
|
||||
$this->scheduler = new TaskScheduler($this->getFullName());
|
||||
$this->resourceProvider = $resourceProvider;
|
||||
|
||||
$this->onLoad();
|
||||
|
||||
|
@ -32,9 +32,8 @@ use function is_string;
|
||||
class PluginGraylist{
|
||||
|
||||
/** @var string[] */
|
||||
private $plugins;
|
||||
/** @var bool */
|
||||
private $isWhitelist = false;
|
||||
private array $plugins;
|
||||
private bool $isWhitelist = false;
|
||||
|
||||
/**
|
||||
* @param string[] $plugins
|
||||
|
@ -34,7 +34,7 @@ class PluginLogger extends \PrefixedLogger implements \AttachableLogger{
|
||||
* @var \Closure[]
|
||||
* @phpstan-var LoggerAttachment[]
|
||||
*/
|
||||
private $attachments = [];
|
||||
private array $attachments = [];
|
||||
|
||||
/**
|
||||
* @phpstan-param LoggerAttachment $attachment
|
||||
|
@ -69,10 +69,6 @@ use function strtolower;
|
||||
* Manages all the plugins
|
||||
*/
|
||||
class PluginManager{
|
||||
|
||||
/** @var Server */
|
||||
private $server;
|
||||
|
||||
/** @var Plugin[] */
|
||||
protected $plugins = [];
|
||||
|
||||
@ -87,14 +83,11 @@ class PluginManager{
|
||||
*/
|
||||
protected $fileAssociations = [];
|
||||
|
||||
/** @var string|null */
|
||||
private $pluginDataDirectory;
|
||||
/** @var PluginGraylist|null */
|
||||
private $graylist;
|
||||
|
||||
public function __construct(Server $server, ?string $pluginDataDirectory, ?PluginGraylist $graylist = null){
|
||||
$this->server = $server;
|
||||
$this->pluginDataDirectory = $pluginDataDirectory;
|
||||
public function __construct(
|
||||
private Server $server,
|
||||
private ?string $pluginDataDirectory,
|
||||
private ?PluginGraylist $graylist = null
|
||||
){
|
||||
if($this->pluginDataDirectory !== null){
|
||||
if(!file_exists($this->pluginDataDirectory)){
|
||||
@mkdir($this->pluginDataDirectory, 0777, true);
|
||||
@ -102,8 +95,6 @@ class PluginManager{
|
||||
throw new \RuntimeException("Plugin data path $this->pluginDataDirectory exists and is not a directory");
|
||||
}
|
||||
}
|
||||
|
||||
$this->graylist = $graylist;
|
||||
}
|
||||
|
||||
public function getPlugin(string $name) : ?Plugin{
|
||||
|
Loading…
x
Reference in New Issue
Block a user