From d60254794156e51bc387d1980060bdd0441aefb3 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 1 Dec 2020 17:38:30 +0000 Subject: [PATCH] PermissionAttachmentInfo no longer references Permissible since the only way to obtain PermissionAttachmentInfo via the API is from the Permissible API, it makes zero sense to ask the attachmentinfo for its permissible, since we obviously already had it to be able to get the info in the first place. Therefore, this is just another useless reference stopping Permissibles from being garbage-collected. --- src/permission/PermissibleBase.php | 4 ++-- src/permission/PermissionAttachmentInfo.php | 10 +--------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/permission/PermissibleBase.php b/src/permission/PermissibleBase.php index b7613006f5..249b12436f 100644 --- a/src/permission/PermissibleBase.php +++ b/src/permission/PermissibleBase.php @@ -140,7 +140,7 @@ class PermissibleBase implements Permissible{ if($perm === null){ throw new \InvalidStateException("Unregistered root permission $name"); } - $this->permissions[$name] = new PermissionAttachmentInfo($this->getRootPermissible(), $name, null, $isGranted); + $this->permissions[$name] = new PermissionAttachmentInfo($name, null, $isGranted); $permManager->subscribeToPermission($name, $this->getRootPermissible()); $this->calculateChildPermissions($perm->getChildren(), false, null); } @@ -166,7 +166,7 @@ class PermissibleBase implements Permissible{ foreach($children as $name => $v){ $perm = $permManager->getPermission($name); $value = ($v xor $invert); - $this->permissions[$name] = new PermissionAttachmentInfo($this->getRootPermissible(), $name, $attachment, $value); + $this->permissions[$name] = new PermissionAttachmentInfo($name, $attachment, $value); $permManager->subscribeToPermission($name, $this->getRootPermissible()); if($perm instanceof Permission){ diff --git a/src/permission/PermissionAttachmentInfo.php b/src/permission/PermissionAttachmentInfo.php index 0ed5e003a6..3bb4f0c5b3 100644 --- a/src/permission/PermissionAttachmentInfo.php +++ b/src/permission/PermissionAttachmentInfo.php @@ -24,9 +24,6 @@ declare(strict_types=1); namespace pocketmine\permission; class PermissionAttachmentInfo{ - /** @var Permissible */ - private $permissible; - /** @var string */ private $permission; @@ -36,17 +33,12 @@ class PermissionAttachmentInfo{ /** @var bool */ private $value; - public function __construct(Permissible $permissible, string $permission, ?PermissionAttachment $attachment, bool $value){ - $this->permissible = $permissible; + public function __construct(string $permission, ?PermissionAttachment $attachment, bool $value){ $this->permission = $permission; $this->attachment = $attachment; $this->value = $value; } - public function getPermissible() : Permissible{ - return $this->permissible; - } - public function getPermission() : string{ return $this->permission; }