mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-14 09:49:50 +00:00
permission: populate missing return type information
PermissibleBase has some redundant phpdoc removed so that the Permissible interface can provide return types.
This commit is contained in:
parent
fffeeddca6
commit
facca13139
@ -61,6 +61,11 @@ class BanEntry{
|
|||||||
return $this->creationDate;
|
return $this->creationDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \DateTime $date
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function setCreated(\DateTime $date){
|
public function setCreated(\DateTime $date){
|
||||||
self::validateDate($date);
|
self::validateDate($date);
|
||||||
$this->creationDate = $date;
|
$this->creationDate = $date;
|
||||||
@ -70,6 +75,11 @@ class BanEntry{
|
|||||||
return $this->source;
|
return $this->source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $source
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function setSource(string $source){
|
public function setSource(string $source){
|
||||||
$this->source = $source;
|
$this->source = $source;
|
||||||
}
|
}
|
||||||
@ -83,6 +93,8 @@ class BanEntry{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \DateTime|null $date
|
* @param \DateTime|null $date
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setExpires(\DateTime $date = null){
|
public function setExpires(\DateTime $date = null){
|
||||||
if($date !== null){
|
if($date !== null){
|
||||||
@ -101,6 +113,11 @@ class BanEntry{
|
|||||||
return $this->reason;
|
return $this->reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $reason
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function setReason(string $reason){
|
public function setReason(string $reason){
|
||||||
$this->reason = $reason;
|
$this->reason = $reason;
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,8 @@ class BanList{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param bool $flag
|
* @param bool $flag
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setEnabled(bool $flag){
|
public function setEnabled(bool $flag){
|
||||||
$this->enabled = $flag;
|
$this->enabled = $flag;
|
||||||
@ -104,6 +106,8 @@ class BanList{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param BanEntry $entry
|
* @param BanEntry $entry
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function add(BanEntry $entry){
|
public function add(BanEntry $entry){
|
||||||
$this->list[$entry->getName()] = $entry;
|
$this->list[$entry->getName()] = $entry;
|
||||||
@ -132,6 +136,8 @@ class BanList{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $name
|
* @param string $name
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function remove(string $name){
|
public function remove(string $name){
|
||||||
$name = strtolower($name);
|
$name = strtolower($name);
|
||||||
@ -141,6 +147,9 @@ class BanList{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function removeExpired(){
|
public function removeExpired(){
|
||||||
foreach($this->list as $name => $entry){
|
foreach($this->list as $name => $entry){
|
||||||
if($entry->hasExpired()){
|
if($entry->hasExpired()){
|
||||||
@ -149,6 +158,9 @@ class BanList{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function load(){
|
public function load(){
|
||||||
$this->list = [];
|
$this->list = [];
|
||||||
$fp = @fopen($this->file, "r");
|
$fp = @fopen($this->file, "r");
|
||||||
@ -175,6 +187,8 @@ class BanList{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param bool $writeHeader
|
* @param bool $writeHeader
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function save(bool $writeHeader = true){
|
public function save(bool $writeHeader = true){
|
||||||
$this->removeExpired();
|
$this->removeExpired();
|
||||||
|
@ -43,6 +43,9 @@ abstract class DefaultPermissions{
|
|||||||
return PermissionManager::getInstance()->getPermission($perm->getName());
|
return PermissionManager::getInstance()->getPermission($perm->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public static function registerCorePermissions(){
|
public static function registerCorePermissions(){
|
||||||
$parent = self::registerPermission(new Permission(self::ROOT, "Allows using all PocketMine commands and utilities"));
|
$parent = self::registerPermission(new Permission(self::ROOT, "Allows using all PocketMine commands and utilities"));
|
||||||
|
|
||||||
|
@ -55,34 +55,18 @@ class PermissibleBase implements Permissible{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function isOp() : bool{
|
public function isOp() : bool{
|
||||||
return $this->opable->isOp();
|
return $this->opable->isOp();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param bool $value
|
|
||||||
*/
|
|
||||||
public function setOp(bool $value){
|
public function setOp(bool $value){
|
||||||
$this->opable->setOp($value);
|
$this->opable->setOp($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Permission|string $name
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function isPermissionSet($name) : bool{
|
public function isPermissionSet($name) : bool{
|
||||||
return isset($this->permissions[$name instanceof Permission ? $name->getName() : $name]);
|
return isset($this->permissions[$name instanceof Permission ? $name->getName() : $name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Permission|string $name
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function hasPermission($name) : bool{
|
public function hasPermission($name) : bool{
|
||||||
if($name instanceof Permission){
|
if($name instanceof Permission){
|
||||||
$name = $name->getName();
|
$name = $name->getName();
|
||||||
@ -127,9 +111,6 @@ class PermissibleBase implements Permissible{
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param PermissionAttachment $attachment
|
|
||||||
*/
|
|
||||||
public function removeAttachment(PermissionAttachment $attachment){
|
public function removeAttachment(PermissionAttachment $attachment){
|
||||||
if(isset($this->attachments[spl_object_hash($attachment)])){
|
if(isset($this->attachments[spl_object_hash($attachment)])){
|
||||||
unset($this->attachments[spl_object_hash($attachment)]);
|
unset($this->attachments[spl_object_hash($attachment)]);
|
||||||
@ -165,6 +146,9 @@ class PermissibleBase implements Permissible{
|
|||||||
Timings::$permissibleCalculationTimer->stopTiming();
|
Timings::$permissibleCalculationTimer->stopTiming();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function clearPermissions(){
|
public function clearPermissions(){
|
||||||
$permManager = PermissionManager::getInstance();
|
$permManager = PermissionManager::getInstance();
|
||||||
$permManager->unsubscribeFromAllPermissions($this->parent ?? $this);
|
$permManager->unsubscribeFromAllPermissions($this->parent ?? $this);
|
||||||
|
@ -192,6 +192,8 @@ class Permission{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $value
|
* @param string $value
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setDefault(string $value){
|
public function setDefault(string $value){
|
||||||
if($value !== $this->defaultValue){
|
if($value !== $this->defaultValue){
|
||||||
@ -209,6 +211,8 @@ class Permission{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $value
|
* @param string $value
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setDescription(string $value){
|
public function setDescription(string $value){
|
||||||
$this->description = $value;
|
$this->description = $value;
|
||||||
@ -221,6 +225,9 @@ class Permission{
|
|||||||
return PermissionManager::getInstance()->getPermissionSubscriptions($this->name);
|
return PermissionManager::getInstance()->getPermissionSubscriptions($this->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function recalculatePermissibles(){
|
public function recalculatePermissibles(){
|
||||||
$perms = $this->getPermissibles();
|
$perms = $this->getPermissibles();
|
||||||
|
|
||||||
|
@ -65,6 +65,8 @@ class PermissionAttachment{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param PermissionRemovedExecutor $ex
|
* @param PermissionRemovedExecutor $ex
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setRemovalCallback(PermissionRemovedExecutor $ex){
|
public function setRemovalCallback(PermissionRemovedExecutor $ex){
|
||||||
$this->removed = $ex;
|
$this->removed = $ex;
|
||||||
@ -91,6 +93,9 @@ class PermissionAttachment{
|
|||||||
return $this->permissions;
|
return $this->permissions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function clearPermissions(){
|
public function clearPermissions(){
|
||||||
$this->permissions = [];
|
$this->permissions = [];
|
||||||
$this->permissible->recalculatePermissions();
|
$this->permissible->recalculatePermissions();
|
||||||
@ -98,6 +103,8 @@ class PermissionAttachment{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param bool[] $permissions
|
* @param bool[] $permissions
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setPermissions(array $permissions){
|
public function setPermissions(array $permissions){
|
||||||
foreach($permissions as $key => $value){
|
foreach($permissions as $key => $value){
|
||||||
@ -108,6 +115,8 @@ class PermissionAttachment{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string[] $permissions
|
* @param string[] $permissions
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function unsetPermissions(array $permissions){
|
public function unsetPermissions(array $permissions){
|
||||||
foreach($permissions as $node){
|
foreach($permissions as $node){
|
||||||
@ -119,6 +128,8 @@ class PermissionAttachment{
|
|||||||
/**
|
/**
|
||||||
* @param string|Permission $name
|
* @param string|Permission $name
|
||||||
* @param bool $value
|
* @param bool $value
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setPermission($name, bool $value){
|
public function setPermission($name, bool $value){
|
||||||
$name = $name instanceof Permission ? $name->getName() : $name;
|
$name = $name instanceof Permission ? $name->getName() : $name;
|
||||||
@ -134,6 +145,8 @@ class PermissionAttachment{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string|Permission $name
|
* @param string|Permission $name
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function unsetPermission($name){
|
public function unsetPermission($name){
|
||||||
$name = $name instanceof Permission ? $name->getName() : $name;
|
$name = $name instanceof Permission ? $name->getName() : $name;
|
||||||
|
@ -79,6 +79,8 @@ class PermissionManager{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string|Permission $permission
|
* @param string|Permission $permission
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function removePermission($permission){
|
public function removePermission($permission){
|
||||||
if($permission instanceof Permission){
|
if($permission instanceof Permission){
|
||||||
@ -103,6 +105,8 @@ class PermissionManager{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Permission $permission
|
* @param Permission $permission
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function recalculatePermissionDefaults(Permission $permission){
|
public function recalculatePermissionDefaults(Permission $permission){
|
||||||
if(isset($this->permissions[$permission->getName()])){
|
if(isset($this->permissions[$permission->getName()])){
|
||||||
@ -141,6 +145,8 @@ class PermissionManager{
|
|||||||
/**
|
/**
|
||||||
* @param string $permission
|
* @param string $permission
|
||||||
* @param Permissible $permissible
|
* @param Permissible $permissible
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function subscribeToPermission(string $permission, Permissible $permissible){
|
public function subscribeToPermission(string $permission, Permissible $permissible){
|
||||||
if(!isset($this->permSubs[$permission])){
|
if(!isset($this->permSubs[$permission])){
|
||||||
@ -152,6 +158,8 @@ class PermissionManager{
|
|||||||
/**
|
/**
|
||||||
* @param string $permission
|
* @param string $permission
|
||||||
* @param Permissible $permissible
|
* @param Permissible $permissible
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function unsubscribeFromPermission(string $permission, Permissible $permissible){
|
public function unsubscribeFromPermission(string $permission, Permissible $permissible){
|
||||||
if(isset($this->permSubs[$permission])){
|
if(isset($this->permSubs[$permission])){
|
||||||
@ -186,6 +194,8 @@ class PermissionManager{
|
|||||||
/**
|
/**
|
||||||
* @param bool $op
|
* @param bool $op
|
||||||
* @param Permissible $permissible
|
* @param Permissible $permissible
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function subscribeToDefaultPerms(bool $op, Permissible $permissible){
|
public function subscribeToDefaultPerms(bool $op, Permissible $permissible){
|
||||||
if($op){
|
if($op){
|
||||||
@ -198,6 +208,8 @@ class PermissionManager{
|
|||||||
/**
|
/**
|
||||||
* @param bool $op
|
* @param bool $op
|
||||||
* @param Permissible $permissible
|
* @param Permissible $permissible
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function unsubscribeFromDefaultPerms(bool $op, Permissible $permissible){
|
public function unsubscribeFromDefaultPerms(bool $op, Permissible $permissible){
|
||||||
if($op){
|
if($op){
|
||||||
|
@ -36,6 +36,8 @@ interface ServerOperator{
|
|||||||
* Sets the operator permission for the current object
|
* Sets the operator permission for the current object
|
||||||
*
|
*
|
||||||
* @param bool $value
|
* @param bool $value
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setOp(bool $value);
|
public function setOp(bool $value);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user