Fixed a bunch of things PHPStan finds unpalatable

close #2614, fix a bunch of docs bugs, fix sendCreativeContents() crash on Human holders, move some inline variable declarations
This commit is contained in:
Dylan K. Taylor
2019-01-04 00:23:09 +00:00
parent 5e0c3333cf
commit d71a543d10
11 changed files with 62 additions and 39 deletions

View File

@ -686,7 +686,9 @@ class Level implements ChunkManager, Metadatable{
}
public function unregisterChunkLoader(ChunkLoader $loader, int $chunkX, int $chunkZ){
if(isset($this->chunkLoaders[$index = Level::chunkHash($chunkX, $chunkZ)][$hash = $loader->getLoaderId()])){
$index = Level::chunkHash($chunkX, $chunkZ);
$hash = $loader->getLoaderId();
if(isset($this->chunkLoaders[$index][$hash])){
unset($this->chunkLoaders[$index][$hash]);
unset($this->playerLoaders[$index][$hash]);
if(count($this->chunkLoaders[$index]) === 0){
@ -1346,9 +1348,9 @@ class Level implements ChunkManager, Metadatable{
}
/**
* @param $x
* @param $y
* @param $z
* @param int $x
* @param int $y
* @param int $z
*
* @return int bitmap, (id << 4) | data
*/
@ -2079,7 +2081,7 @@ class Level implements ChunkManager, Metadatable{
}
/**
* @param $tileId
* @param int $tileId
*
* @return Tile|null
*/
@ -2185,7 +2187,9 @@ class Level implements ChunkManager, Metadatable{
if(!$this->isInWorld($x, $y, $z)){ //TODO: bad hack but fixing this requires BC breaks to do properly :(
return;
}
unset($this->blockCache[$chunkHash = Level::chunkHash($x >> 4, $z >> 4)][$blockHash = Level::blockHash($x, $y, $z)]);
$chunkHash = Level::chunkHash($x >> 4, $z >> 4);
$blockHash = Level::blockHash($x, $y, $z);
unset($this->blockCache[$chunkHash][$blockHash]);
$this->getChunk($x >> 4, $z >> 4, true)->setBlockId($x & 0x0f, $y, $z & 0x0f, $id & 0xff);
if(!isset($this->changedBlocks[$chunkHash])){
@ -2222,7 +2226,9 @@ class Level implements ChunkManager, Metadatable{
if(!$this->isInWorld($x, $y, $z)){ //TODO: bad hack but fixing this requires BC breaks to do properly :(
return;
}
unset($this->blockCache[$chunkHash = Level::chunkHash($x >> 4, $z >> 4)][$blockHash = Level::blockHash($x, $y, $z)]);
$chunkHash = Level::chunkHash($x >> 4, $z >> 4);
$blockHash = Level::blockHash($x, $y, $z);
unset($this->blockCache[$chunkHash][$blockHash]);
$this->getChunk($x >> 4, $z >> 4, true)->setBlockData($x & 0x0f, $y, $z & 0x0f, $data & 0x0f);