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.
This commit is contained in:
Dylan K. Taylor 2020-12-01 17:38:30 +00:00
parent d48af3f4ca
commit d602547941
2 changed files with 3 additions and 11 deletions

View File

@ -140,7 +140,7 @@ class PermissibleBase implements Permissible{
if($perm === null){ if($perm === null){
throw new \InvalidStateException("Unregistered root permission $name"); 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()); $permManager->subscribeToPermission($name, $this->getRootPermissible());
$this->calculateChildPermissions($perm->getChildren(), false, null); $this->calculateChildPermissions($perm->getChildren(), false, null);
} }
@ -166,7 +166,7 @@ class PermissibleBase implements Permissible{
foreach($children as $name => $v){ foreach($children as $name => $v){
$perm = $permManager->getPermission($name); $perm = $permManager->getPermission($name);
$value = ($v xor $invert); $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()); $permManager->subscribeToPermission($name, $this->getRootPermissible());
if($perm instanceof Permission){ if($perm instanceof Permission){

View File

@ -24,9 +24,6 @@ declare(strict_types=1);
namespace pocketmine\permission; namespace pocketmine\permission;
class PermissionAttachmentInfo{ class PermissionAttachmentInfo{
/** @var Permissible */
private $permissible;
/** @var string */ /** @var string */
private $permission; private $permission;
@ -36,17 +33,12 @@ class PermissionAttachmentInfo{
/** @var bool */ /** @var bool */
private $value; private $value;
public function __construct(Permissible $permissible, string $permission, ?PermissionAttachment $attachment, bool $value){ public function __construct(string $permission, ?PermissionAttachment $attachment, bool $value){
$this->permissible = $permissible;
$this->permission = $permission; $this->permission = $permission;
$this->attachment = $attachment; $this->attachment = $attachment;
$this->value = $value; $this->value = $value;
} }
public function getPermissible() : Permissible{
return $this->permissible;
}
public function getPermission() : string{ public function getPermission() : string{
return $this->permission; return $this->permission;
} }