Modernize private property declarations in src/permission

This commit is contained in:
Dylan K. Taylor 2022-05-17 21:28:42 +01:00
parent 6eac2ea7a5
commit 22edca610c
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
6 changed files with 32 additions and 65 deletions

View File

@ -36,16 +36,11 @@ class BanEntry{
/** @var string */
public static $format = "Y-m-d H:i:s O";
/** @var string */
private $name;
/** @var \DateTime */
private $creationDate;
/** @var string */
private $source = "(Unknown)";
/** @var \DateTime|null */
private $expirationDate = null;
/** @var string */
private $reason = "Banned by an operator.";
private string $name;
private \DateTime $creationDate;
private string $source = "(Unknown)";
private ?\DateTime $expirationDate = null;
private string $reason = "Banned by an operator.";
public function __construct(string $name){
$this->name = strtolower($name);

View File

@ -32,19 +32,14 @@ use function strtolower;
use function trim;
class BanList{
/** @var BanEntry[] */
private $list = [];
private array $list = [];
/** @var string */
private $file;
private bool $enabled = true;
/** @var bool */
private $enabled = true;
public function __construct(string $file){
$this->file = $file;
}
public function __construct(
private string $file
){}
public function isEnabled() : bool{
return $this->enabled;

View File

@ -44,19 +44,19 @@ class PermissibleInternal implements Permissible{
* @var bool[]
* @phpstan-var array<string, bool>
*/
private $rootPermissions;
private array $rootPermissions;
/** @var PermissionAttachment[] */
private $attachments = [];
private array $attachments = [];
/** @var PermissionAttachmentInfo[] */
private $permissions = [];
private array $permissions = [];
/**
* @var ObjectSet|\Closure[]
* @phpstan-var ObjectSet<\Closure(array<string, bool> $changedPermissionsOldValues) : void>
*/
private $permissionRecalculationCallbacks;
private ObjectSet $permissionRecalculationCallbacks;
/**
* @param bool[] $basePermissions

View File

@ -31,17 +31,7 @@ namespace pocketmine\permission;
* Represents a permission
*/
class Permission{
/** @var string */
private $name;
/** @var string */
private $description;
/**
* @var bool[]
* @phpstan-var array<string, bool>
*/
private $children;
private string $description;
/**
* Creates a new Permission object to be attached to Permissible objects
@ -49,10 +39,12 @@ class Permission{
* @param bool[] $children
* @phpstan-param array<string, bool> $children
*/
public function __construct(string $name, ?string $description = null, array $children = []){
$this->name = $name;
$this->description = $description ?? "";
$this->children = $children;
public function __construct(
private string $name,
?string $description = null,
private array $children = []
){
$this->description = $description ?? ""; //TODO: wtf ????
$this->recalculatePermissibles();
}

View File

@ -29,26 +29,23 @@ use function spl_object_id;
class PermissionAttachment{
/** @var bool[] */
private $permissions = [];
private array $permissions = [];
/**
* @var PermissibleInternal[]
* @phpstan-var array<int, PermissibleInternal>
*/
private $subscribers = [];
/** @var Plugin */
private $plugin;
private array $subscribers = [];
/**
* @throws PluginException
*/
public function __construct(Plugin $plugin){
public function __construct(
private Plugin $plugin
){
if(!$plugin->isEnabled()){
throw new PluginException("Plugin " . $plugin->getDescription()->getName() . " is disabled");
}
$this->plugin = $plugin;
}
public function getPlugin() : Plugin{

View File

@ -24,24 +24,12 @@ declare(strict_types=1);
namespace pocketmine\permission;
class PermissionAttachmentInfo{
/** @var string */
private $permission;
/** @var PermissionAttachment|null */
private $attachment;
/** @var bool */
private $value;
/** @var PermissionAttachmentInfo|null */
private $groupPermission;
public function __construct(string $permission, ?PermissionAttachment $attachment, bool $value, ?PermissionAttachmentInfo $groupPermission){
$this->permission = $permission;
$this->attachment = $attachment;
$this->value = $value;
$this->groupPermission = $groupPermission;
}
public function __construct(
private string $permission,
private ?PermissionAttachment $attachment,
private bool $value,
private ?PermissionAttachmentInfo $groupPermission
){}
public function getPermission() : string{
return $this->permission;