mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-11 08:19:45 +00:00
Make some forced-optional nullable parameters non-optional, PHP 7.1 style
these parameters did not make any sense to be optional, but were forced to be this way because of the way nullable types worked before 7.1.
This commit is contained in:
parent
a5c260352d
commit
73a565355b
@ -477,7 +477,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
|
||||
return $this->lineHeight ?? 7;
|
||||
}
|
||||
|
||||
public function setScreenLineHeight(int $height = null){
|
||||
public function setScreenLineHeight(?int $height){
|
||||
if($height !== null and $height < 1){
|
||||
throw new \InvalidArgumentException("Line height must be at least 1");
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ abstract class Command{
|
||||
/**
|
||||
* @param string|null $permission
|
||||
*/
|
||||
public function setPermission(string $permission = null){
|
||||
public function setPermission(?string $permission){
|
||||
$this->permission = $permission;
|
||||
}
|
||||
|
||||
|
@ -57,5 +57,5 @@ interface CommandSender extends Permissible{
|
||||
*
|
||||
* @param int|null $height
|
||||
*/
|
||||
public function setScreenLineHeight(int $height = null);
|
||||
public function setScreenLineHeight(?int $height);
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ class ConsoleCommandSender implements CommandSender{
|
||||
return $this->lineHeight ?? PHP_INT_MAX;
|
||||
}
|
||||
|
||||
public function setScreenLineHeight(int $height = null){
|
||||
public function setScreenLineHeight(?int $height){
|
||||
if($height !== null and $height < 1){
|
||||
throw new \InvalidArgumentException("Line height must be at least 1");
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ interface ChunkManager{
|
||||
* @param int $chunkZ
|
||||
* @param Chunk|null $chunk
|
||||
*/
|
||||
public function setChunk(int $chunkX, int $chunkZ, Chunk $chunk = null);
|
||||
public function setChunk(int $chunkX, int $chunkZ, ?Chunk $chunk);
|
||||
|
||||
/**
|
||||
* Returns the height of the world
|
||||
|
@ -2303,7 +2303,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
* @param Chunk|null $chunk
|
||||
* @param bool $deleteEntitiesAndTiles Whether to delete entities and tiles on the old chunk, or transfer them to the new one
|
||||
*/
|
||||
public function setChunk(int $chunkX, int $chunkZ, Chunk $chunk = null, bool $deleteEntitiesAndTiles = true){
|
||||
public function setChunk(int $chunkX, int $chunkZ, ?Chunk $chunk, bool $deleteEntitiesAndTiles = true){
|
||||
if($chunk === null){
|
||||
return;
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ class Position extends Vector3{
|
||||
*
|
||||
* @throws \InvalidArgumentException if the specified Level has been closed
|
||||
*/
|
||||
public function setLevel(Level $level = null){
|
||||
public function setLevel(?Level $level){
|
||||
if($level !== null and $level->isClosed()){
|
||||
throw new \InvalidArgumentException("Specified world has been unloaded and cannot be used");
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ class SimpleChunkManager implements ChunkManager{
|
||||
* @param int $chunkZ
|
||||
* @param Chunk|null $chunk
|
||||
*/
|
||||
public function setChunk(int $chunkX, int $chunkZ, Chunk $chunk = null){
|
||||
public function setChunk(int $chunkX, int $chunkZ, ?Chunk $chunk){
|
||||
if($chunk === null){
|
||||
unset($this->chunks[Level::chunkHash($chunkX, $chunkZ)]);
|
||||
return;
|
||||
|
@ -696,7 +696,7 @@ class Chunk{
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function setSubChunk(int $y, SubChunkInterface $subChunk = null, bool $allowEmpty = false) : bool{
|
||||
public function setSubChunk(int $y, ?SubChunkInterface $subChunk, bool $allowEmpty = false) : bool{
|
||||
if($y < 0 or $y >= $this->height){
|
||||
return false;
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ class BanEntry{
|
||||
* @param \DateTime|null $date
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function setExpires(\DateTime $date = null){
|
||||
public function setExpires(?\DateTime $date){
|
||||
if($date !== null){
|
||||
self::validateDate($date);
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ class PermissionAttachmentInfo{
|
||||
*
|
||||
* @throws \InvalidStateException
|
||||
*/
|
||||
public function __construct(Permissible $permissible, string $permission, PermissionAttachment $attachment = null, bool $value){
|
||||
public function __construct(Permissible $permissible, string $permission, ?PermissionAttachment $attachment, bool $value){
|
||||
$this->permissible = $permissible;
|
||||
$this->permission = $permission;
|
||||
$this->attachment = $attachment;
|
||||
|
@ -55,7 +55,7 @@ abstract class Task{
|
||||
/**
|
||||
* @param TaskHandler|null $taskHandler
|
||||
*/
|
||||
final public function setHandler(TaskHandler $taskHandler = null){
|
||||
final public function setHandler(?TaskHandler $taskHandler){
|
||||
if($this->taskHandler === null or $taskHandler === null){
|
||||
$this->taskHandler = $taskHandler;
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ class ItemFrame extends Spawnable{
|
||||
return clone $this->item;
|
||||
}
|
||||
|
||||
public function setItem(Item $item = null){
|
||||
public function setItem(?Item $item){
|
||||
if($item !== null and !$item->isNull()){
|
||||
$this->item = clone $item;
|
||||
}else{
|
||||
|
Loading…
x
Reference in New Issue
Block a user