FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add files via upload · ExplodingPE/ExplodingPE@548e7d6 · GitHub

Commit 548e7d6

Browse files
Add files via upload
1 parent d9e9499 commit 548e7d6

16 files changed

Lines changed: 178 additions & 157 deletions

‎src/pocketmine/permission/BanEntry.php‎

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,65 +28,68 @@
2828
class BanEntry{
2929
public static $format = "Y-m-d H:i:s O";
3030

31+
/** @var string */
3132
private $name;
3233
/** @var \DateTime */
3334
private $creationDate = null;
35+
/** @var string */
3436
private $source = "(Unknown)";
3537
/** @var \DateTime */
3638
private $expirationDate = null;
39+
/** @var string */
3740
private $reason = "Banned by an operator.";
3841

39-
public function __construct($name){
42+
public function __construct(string $name){
4043
$this->name = strtolower($name);
4144
$this->creationDate = new \DateTime();
4245
}
4346

44-
public function getName(){
47+
public function getName() : string{
4548
return $this->name;
4649
}
4750

48-
public function getCreated(){
51+
public function getCreated() : \DateTime{
4952
return $this->creationDate;
5053
}
5154

5255
public function setCreated(\DateTime $date){
5356
$this->creationDate = $date;
5457
}
5558

56-
public function getSource(){
59+
public function getSource() : string{
5760
return $this->source;
5861
}
5962

60-
public function setSource($source){
63+
public function setSource(string $source){
6164
$this->source = $source;
6265
}
6366

64-
public function getExpires(){
67+
public function getExpires() : \DateTime{
6568
return $this->expirationDate;
6669
}
6770

6871
/**
6972
* @param \DateTime $date
7073
*/
71-
public function setExpires($date){
74+
public function setExpires(\DateTime $date){
7275
$this->expirationDate = $date;
7376
}
7477

75-
public function hasExpired(){
78+
public function hasExpired() : bool{
7679
$now = new \DateTime();
7780

7881
return $this->expirationDate === null ? false : $this->expirationDate < $now;
7982
}
8083

81-
public function getReason(){
84+
public function getReason() : string{
8285
return $this->reason;
8386
}
8487

85-
public function setReason($reason){
88+
public function setReason(string $reason){
8689
$this->reason = $reason;
8790
}
8891

89-
public function getString(){
92+
public function getString() : string{
9093
$str = "";
9194
$str .= $this->getName();
9295
$str .= "|";

‎src/pocketmine/permission/BanList.php‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,28 +40,28 @@ class BanList{
4040
/**
4141
* @param string $file
4242
*/
43-
public function __construct($file){
43+
public function __construct(string $file){
4444
$this->file = $file;
4545
}
4646

4747
/**
4848
* @return bool
4949
*/
50-
public function isEnabled(){
50+
public function isEnabled() : bool{
5151
return $this->enabled === true;
5252
}
5353

5454
/**
5555
* @param bool $flag
5656
*/
57-
public function setEnabled($flag){
58-
$this->enabled = (bool) $flag;
57+
public function setEnabled(bool $flag){
58+
$this->enabled = $flag;
5959
}
6060

6161
/**
6262
* @return BanEntry[]
6363
*/
64-
public function getEntries(){
64+
public function getEntries() : array{
6565
$this->removeExpired();
6666

6767
return $this->list;
@@ -72,7 +72,7 @@ public function getEntries(){
7272
*
7373
* @return bool
7474
*/
75-
public function isBanned($name){
75+
public function isBanned(string $name) : bool{
7676
$name = strtolower($name);
7777
if(!$this->isEnabled()){
7878
return false;
@@ -99,7 +99,7 @@ public function add(BanEntry $entry){
9999
*
100100
* @return BanEntry
101101
*/
102-
public function addBan($target, $reason = null, $expires = null, $source = null){
102+
public function addBan(string $target, string $reason = null, \DateTime $expires = null, string $source = null) : BanEntry{
103103
$entry = new BanEntry($target);
104104
$entry->setSource($source != null ? $source : $entry->getSource());
105105
$entry->setExpires($expires);
@@ -114,7 +114,7 @@ public function addBan($target, $reason = null, $expires = null, $source = null)
114114
/**
115115
* @param string $name
116116
*/
117-
public function remove($name){
117+
public function remove(string $name){
118118
$name = strtolower($name);
119119
if(isset($this->list[$name])){
120120
unset($this->list[$name]);
@@ -148,7 +148,10 @@ public function load(){
148148
}
149149
}
150150

151-
public function save($flag = true){
151+
/**
152+
* @param bool $flag
153+
*/
154+
public function save(bool $flag = true){
152155
$this->removeExpired();
153156
$fp = @fopen($this->file, "w");
154157
if(is_resource($fp)){

‎src/pocketmine/permission/DefaultPermissions.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ abstract class DefaultPermissions{
3434
*
3535
* @return Permission
3636
*/
37-
public static function registerPermission(Permission $perm, Permission $parent = null){
37+
public static function registerPermission(Permission $perm, Permission $parent = null) : Permission{
3838
if($parent instanceof Permission){
3939
$parent->getChildren()[$perm->getName()] = true;
4040

‎src/pocketmine/permission/Permissible.php‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,16 @@ interface Permissible extends ServerOperator{
3434
*
3535
* @return bool
3636
*/
37-
public function isPermissionSet($name);
37+
public function isPermissionSet($name) : bool;
3838

3939
/**
4040
* Returns the permission value if overridden, or the default value if not
4141
*
4242
* @param string|Permission $name
4343
*
44-
* @return mixed
44+
* @return bool
4545
*/
46-
public function hasPermission($name);
46+
public function hasPermission($name) : bool;
4747

4848
/**
4949
* @param Plugin $plugin
@@ -52,7 +52,7 @@ public function hasPermission($name);
5252
*
5353
* @return PermissionAttachment
5454
*/
55-
public function addAttachment(Plugin $plugin, $name = null, $value = null);
55+
public function addAttachment(Plugin $plugin, string $name = null, bool $value = null) : PermissionAttachment;
5656

5757
/**
5858
* @param PermissionAttachment $attachment
@@ -68,8 +68,8 @@ public function removeAttachment(PermissionAttachment $attachment);
6868
public function recalculatePermissions();
6969

7070
/**
71-
* @return Permission[]
71+
* @return PermissionAttachmentInfo[]
7272
*/
73-
public function getEffectivePermissions();
73+
public function getEffectivePermissions() : array;
7474

7575
}

‎src/pocketmine/permission/PermissibleBase.php‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function __destruct(){
6363
/**
6464
* @return bool
6565
*/
66-
public function isOp(){
66+
public function isOp() : bool{
6767
if($this->opable === null){
6868
return false;
6969
}else{
@@ -76,7 +76,7 @@ public function isOp(){
7676
*
7777
* @throws \Exception
7878
*/
79-
public function setOp($value){
79+
public function setOp(bool $value){
8080
if($this->opable === null){
8181
throw new \LogicException("Cannot change op value as no ServerOperator is set");
8282
}else{
@@ -89,7 +89,7 @@ public function setOp($value){
8989
*
9090
* @return bool
9191
*/
92-
public function isPermissionSet($name){
92+
public function isPermissionSet($name) : bool{
9393
return isset($this->permissions[$name instanceof Permission ? $name->getName() : $name]);
9494
}
9595

@@ -98,7 +98,7 @@ public function isPermissionSet($name){
9898
*
9999
* @return bool
100100
*/
101-
public function hasPermission($name){
101+
public function hasPermission($name) : bool{
102102
if($name instanceof Permission){
103103
$name = $name->getName();
104104
}
@@ -122,13 +122,11 @@ public function hasPermission($name){
122122
*
123123
* @param Plugin $plugin
124124
* @param string $name
125-
* @param bool $value
125+
* @param bool $value
126126
*
127127
* @return PermissionAttachment
128-
*
129-
* @throws PluginException
130128
*/
131-
public function addAttachment(Plugin $plugin, $name = null, $value = null){
129+
public function addAttachment(Plugin $plugin, string $name = null, bool $value = null) : PermissionAttachment{
132130
if(!$plugin->isEnabled()){
133131
throw new PluginException("Plugin " . $plugin->getDescription()->getName() . " is disabled");
134132
}
@@ -214,7 +212,7 @@ private function calculateChildPermissions(array $children, $invert, $attachment
214212
/**
215213
* @return PermissionAttachmentInfo[]
216214
*/
217-
public function getEffectivePermissions(){
215+
public function getEffectivePermissions() : array{
218216
return $this->permissions;
219217
}
220218
}

‎src/pocketmine/permission/Permission.php‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ class Permission{
4040
public static $DEFAULT_PERMISSION = self::DEFAULT_OP;
4141

4242
/**
43-
* @param $value
43+
* @param bool|string $value
4444
*
4545
* @return string
4646
*/
47-
public static function getByName($value){
47+
public static function getByName($value) : string{
4848
if(is_bool($value)){
4949
if($value === true){
5050
return "true";
@@ -86,7 +86,7 @@ public static function getByName($value){
8686
/**
8787
* @var string[]
8888
*/
89-
private $children = [];
89+
private $children;
9090

9191
/** @var string */
9292
private $defaultValue;
@@ -99,7 +99,7 @@ public static function getByName($value){
9999
* @param string $defaultValue
100100
* @param Permission[] $children
101101
*/
102-
public function __construct($name, $description = null, $defaultValue = null, array $children = []){
102+
public function __construct(string $name, string $description = null, string $defaultValue = null, array $children = []){
103103
$this->name = $name;
104104
$this->description = $description ?? "";
105105
$this->defaultValue = $defaultValue ?? self::$DEFAULT_PERMISSION;
@@ -111,28 +111,28 @@ public function __construct($name, $description = null, $defaultValue = null, ar
111111
/**
112112
* @return string
113113
*/
114-
public function getName(){
114+
public function getName() : string{
115115
return $this->name;
116116
}
117117

118118
/**
119119
* @return string[]
120120
*/
121-
public function &getChildren(){
121+
public function &getChildren() : array{
122122
return $this->children;
123123
}
124124

125125
/**
126126
* @return string
127127
*/
128-
public function getDefault(){
128+
public function getDefault() : string{
129129
return $this->defaultValue;
130130
}
131131

132132
/**
133133
* @param string $value
134134
*/
135-
public function setDefault($value){
135+
public function setDefault(string $value){
136136
if($value !== $this->defaultValue){
137137
$this->defaultValue = $value;
138138
$this->recalculatePermissibles();
@@ -142,21 +142,21 @@ public function setDefault($value){
142142
/**
143143
* @return string
144144
*/
145-
public function getDescription(){
145+
public function getDescription() : string{
146146
return $this->description;
147147
}
148148

149149
/**
150150
* @param string $value
151151
*/
152-
public function setDescription($value){
152+
public function setDescription(string $value){
153153
$this->description = $value;
154154
}
155155

156156
/**
157157
* @return Permissible[]
158158
*/
159-
public function getPermissibles(){
159+
public function getPermissibles() : array{
160160
return Server::getInstance()->getPluginManager()->getPermissionSubscriptions($this->name);
161161
}
162162

@@ -196,12 +196,12 @@ public function addParent($name, $value){
196196
}
197197

198198
/**
199-
* @param array $data
200-
* @param $default
199+
* @param array $data
200+
* @param string $default
201201
*
202202
* @return Permission[]
203203
*/
204-
public static function loadPermissions(array $data, $default = self::DEFAULT_OP){
204+
public static function loadPermissions(array $data, string $default = self::DEFAULT_OP) : array{
205205
$result = [];
206206
foreach($data as $key => $entry){
207207
$result[] = self::loadPermission($key, $entry, $default, $result);
@@ -220,7 +220,7 @@ public static function loadPermissions(array $data, $default = self::DEFAULT_OP)
220220
*
221221
* @throws \Exception
222222
*/
223-
public static function loadPermission($name, array $data, $default = self::DEFAULT_OP, &$output = []){
223+
public static function loadPermission(string $name, array $data, string $default = self::DEFAULT_OP, array &$output = []) : Permission{
224224
$desc = null;
225225
$children = [];
226226
if(isset($data["default"])){

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL