mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-20 07:39:42 +00:00
Apply union types in some places (BC breaks)
This commit is contained in:
@@ -35,32 +35,26 @@ interface Permissible{
|
||||
*
|
||||
* @internal
|
||||
* @see Permissible::addAttachment() for normal permission assignments
|
||||
* @param Permission|string $name
|
||||
*/
|
||||
public function setBasePermission($name, bool $grant) : void;
|
||||
public function setBasePermission(Permission|string $name, bool $grant) : void;
|
||||
|
||||
/**
|
||||
* Unsets a baseline permission previously set. If it wasn't already set, this will have no effect.
|
||||
* Note that this might have different results than setting the permission to false.
|
||||
*
|
||||
* @internal
|
||||
* @param Permission|string $name
|
||||
*/
|
||||
public function unsetBasePermission($name) : void;
|
||||
public function unsetBasePermission(Permission|string $name) : void;
|
||||
|
||||
/**
|
||||
* Checks if this instance has a permission overridden
|
||||
*
|
||||
* @param string|Permission $name
|
||||
*/
|
||||
public function isPermissionSet($name) : bool;
|
||||
public function isPermissionSet(Permission|string $name) : bool;
|
||||
|
||||
/**
|
||||
* Returns the permission value if overridden, or the default value if not
|
||||
*
|
||||
* @param string|Permission $name
|
||||
*/
|
||||
public function hasPermission($name) : bool;
|
||||
public function hasPermission(Permission|string $name) : bool;
|
||||
|
||||
public function addAttachment(Plugin $plugin, ?string $name = null, ?bool $value = null) : PermissionAttachment;
|
||||
|
||||
|
@@ -31,31 +31,19 @@ trait PermissibleDelegateTrait{
|
||||
/** @var Permissible */
|
||||
private $perm;
|
||||
|
||||
/**
|
||||
* @param Permission|string $name
|
||||
*/
|
||||
public function setBasePermission($name, bool $value) : void{
|
||||
$this->perm->setBasePermission($name, $value);
|
||||
public function setBasePermission(Permission|string $name, bool $grant) : void{
|
||||
$this->perm->setBasePermission($name, $grant);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Permission|string $name
|
||||
*/
|
||||
public function unsetBasePermission($name) : void{
|
||||
public function unsetBasePermission(Permission|string $name) : void{
|
||||
$this->perm->unsetBasePermission($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Permission|string $name
|
||||
*/
|
||||
public function isPermissionSet($name) : bool{
|
||||
public function isPermissionSet(Permission|string $name) : bool{
|
||||
return $this->perm->isPermissionSet($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Permission|string $name
|
||||
*/
|
||||
public function hasPermission($name) : bool{
|
||||
public function hasPermission(Permission|string $name) : bool{
|
||||
return $this->perm->hasPermission($name);
|
||||
}
|
||||
|
||||
|
@@ -69,7 +69,7 @@ class PermissibleInternal implements Permissible{
|
||||
$this->recalculatePermissions();
|
||||
}
|
||||
|
||||
public function setBasePermission($name, bool $grant) : void{
|
||||
public function setBasePermission(Permission|string $name, bool $grant) : void{
|
||||
if($name instanceof Permission){
|
||||
$name = $name->getName();
|
||||
}
|
||||
@@ -77,22 +77,16 @@ class PermissibleInternal implements Permissible{
|
||||
$this->recalculatePermissions();
|
||||
}
|
||||
|
||||
public function unsetBasePermission($name) : void{
|
||||
public function unsetBasePermission(Permission|string $name) : void{
|
||||
unset($this->rootPermissions[$name instanceof Permission ? $name->getName() : $name]);
|
||||
$this->recalculatePermissions();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Permission|string $name
|
||||
*/
|
||||
public function isPermissionSet($name) : bool{
|
||||
public function isPermissionSet(Permission|string $name) : bool{
|
||||
return isset($this->permissions[$name instanceof Permission ? $name->getName() : $name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Permission|string $name
|
||||
*/
|
||||
public function hasPermission($name) : bool{
|
||||
public function hasPermission(Permission|string $name) : bool{
|
||||
if($name instanceof Permission){
|
||||
$name = $name->getName();
|
||||
}
|
||||
|
@@ -96,10 +96,7 @@ class PermissionAttachment{
|
||||
$this->recalculatePermissibles();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|Permission $name
|
||||
*/
|
||||
public function setPermission($name, bool $value) : void{
|
||||
public function setPermission(Permission|string $name, bool $value) : void{
|
||||
$name = $name instanceof Permission ? $name->getName() : $name;
|
||||
if(isset($this->permissions[$name])){
|
||||
if($this->permissions[$name] === $value){
|
||||
@@ -120,10 +117,7 @@ class PermissionAttachment{
|
||||
$this->recalculatePermissibles();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|Permission $name
|
||||
*/
|
||||
public function unsetPermission($name) : void{
|
||||
public function unsetPermission(Permission|string $name) : void{
|
||||
$name = $name instanceof Permission ? $name->getName() : $name;
|
||||
if(isset($this->permissions[$name])){
|
||||
unset($this->permissions[$name]);
|
||||
|
@@ -56,10 +56,7 @@ class PermissionManager{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|Permission $permission
|
||||
*/
|
||||
public function removePermission($permission) : void{
|
||||
public function removePermission(Permission|string $permission) : void{
|
||||
if($permission instanceof Permission){
|
||||
unset($this->permissions[$permission->getName()]);
|
||||
}else{
|
||||
|
@@ -54,11 +54,9 @@ class PermissionParser{
|
||||
];
|
||||
|
||||
/**
|
||||
* @param bool|string $value
|
||||
*
|
||||
* @throws PermissionParserException
|
||||
*/
|
||||
public static function defaultFromString($value) : string{
|
||||
public static function defaultFromString(bool|string $value) : string{
|
||||
if(is_bool($value)){
|
||||
if($value){
|
||||
return "true";
|
||||
|
Reference in New Issue
Block a user