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:
Dylan K. Taylor 2019-02-22 12:53:07 +00:00
parent a5c260352d
commit 73a565355b
13 changed files with 13 additions and 13 deletions

View File

@ -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");
}

View File

@ -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;
}

View File

@ -57,5 +57,5 @@ interface CommandSender extends Permissible{
*
* @param int|null $height
*/
public function setScreenLineHeight(int $height = null);
public function setScreenLineHeight(?int $height);
}

View File

@ -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");
}

View File

@ -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

View File

@ -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;
}

View File

@ -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");
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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{