* More ??

* fix undefined variable
This commit is contained in:
Dylan K. Taylor 2016-11-30 10:07:37 +00:00 committed by GitHub
parent 43a36dba40
commit d6629d6843
15 changed files with 23 additions and 24 deletions

View File

@ -160,7 +160,7 @@ class CrashDump{
]; ];
$error["fullFile"] = $error["file"]; $error["fullFile"] = $error["file"];
$error["file"] = cleanPath($error["file"]); $error["file"] = cleanPath($error["file"]);
$error["type"] = isset($errorConversion[$error["type"]]) ? $errorConversion[$error["type"]] : $error["type"]; $error["type"] = $errorConversion[$error["type"]] ?? $error["type"];
if(($pos = strpos($error["message"], "\n")) !== false){ if(($pos = strpos($error["message"], "\n")) !== false){
$error["message"] = substr($error["message"], 0, $pos); $error["message"] = substr($error["message"], 0, $pos);
} }

View File

@ -2381,7 +2381,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
]; ];
$damage = [ $damage = [
EntityDamageEvent::MODIFIER_BASE => isset($damageTable[$item->getId()]) ? $damageTable[$item->getId()] : 1, EntityDamageEvent::MODIFIER_BASE => $damageTable[$item->getId()] ?? 1,
]; ];
if(!$this->canInteract($target, 8)){ if(!$this->canInteract($target, 8)){

View File

@ -272,7 +272,7 @@ class Item implements ItemIds, \JsonSerializable{
* @return Item * @return Item
*/ */
public static function getCreativeItem(int $index){ public static function getCreativeItem(int $index){
return isset(Item::$creative[$index]) ? Item::$creative[$index] : null; return Item::$creative[$index] ?? null;
} }
public static function getCreativeItemIndex(Item $item) : int{ public static function getCreativeItemIndex(Item $item) : int{
@ -597,7 +597,7 @@ class Item implements ItemIds, \JsonSerializable{
public function getNamedTagEntry($name){ public function getNamedTagEntry($name){
$tag = $this->getNamedTag(); $tag = $this->getNamedTag();
if($tag !== null){ if($tag !== null){
return isset($tag->{$name}) ? $tag->{$name} : null; return $tag->{$name} ?? null;
} }
return null; return null;

View File

@ -532,7 +532,7 @@ class Level implements ChunkManager, Metadatable{
* @return Player[] * @return Player[]
*/ */
public function getChunkPlayers(int $chunkX, int $chunkZ) : array{ public function getChunkPlayers(int $chunkX, int $chunkZ) : array{
return isset($this->playerLoaders[$index = Level::chunkHash($chunkX, $chunkZ)]) ? $this->playerLoaders[$index] : []; return $this->playerLoaders[Level::chunkHash($chunkX, $chunkZ)] ?? [];
} }
/** /**
@ -544,7 +544,7 @@ class Level implements ChunkManager, Metadatable{
* @return ChunkLoader[] * @return ChunkLoader[]
*/ */
public function getChunkLoaders(int $chunkX, int $chunkZ) : array{ public function getChunkLoaders(int $chunkX, int $chunkZ) : array{
return isset($this->chunkLoaders[$index = Level::chunkHash($chunkX, $chunkZ)]) ? $this->chunkLoaders[$index] : []; return $this->chunkLoaders[Level::chunkHash($chunkX, $chunkZ)] ?? [];
} }
public function addChunkPacket(int $chunkX, int $chunkZ, DataPacket $packet){ public function addChunkPacket(int $chunkX, int $chunkZ, DataPacket $packet){
@ -888,7 +888,7 @@ class Level implements ChunkManager, Metadatable{
$chunkZ = $loader->getZ() >> 4; $chunkZ = $loader->getZ() >> 4;
$index = Level::chunkHash($chunkX, $chunkZ); $index = Level::chunkHash($chunkX, $chunkZ);
$existingLoaders = max(0, isset($this->chunkTickList[$index]) ? $this->chunkTickList[$index] : 0); $existingLoaders = max(0, $this->chunkTickList[$index] ?? 0);
$this->chunkTickList[$index] = $existingLoaders + 1; $this->chunkTickList[$index] = $existingLoaders + 1;
for($chunk = 0; $chunk < $chunksPerLoader; ++$chunk){ for($chunk = 0; $chunk < $chunksPerLoader; ++$chunk){
$dx = mt_rand(-$randRange, $randRange); $dx = mt_rand(-$randRange, $randRange);
@ -1769,7 +1769,7 @@ class Level implements ChunkManager, Metadatable{
* @return Entity * @return Entity
*/ */
public function getEntity(int $entityId){ public function getEntity(int $entityId){
return isset($this->entities[$entityId]) ? $this->entities[$entityId] : null; return $this->entities[$entityId] ?? null;
} }
/** /**
@ -1856,7 +1856,7 @@ class Level implements ChunkManager, Metadatable{
* @return Tile * @return Tile
*/ */
public function getTileById(int $tileId){ public function getTileById(int $tileId){
return isset($this->tiles[$tileId]) ? $this->tiles[$tileId] : null; return $this->tiles[$tileId] ?? null;
} }
/** /**

View File

@ -103,7 +103,7 @@ class SimpleChunkManager implements ChunkManager{
* @return FullChunk|null * @return FullChunk|null
*/ */
public function getChunk(int $chunkX, int $chunkZ){ public function getChunk(int $chunkX, int $chunkZ){
return isset($this->chunks[$index = Level::chunkHash($chunkX, $chunkZ)]) ? $this->chunks[$index] : null; return $this->chunks[Level::chunkHash($chunkX, $chunkZ)] ?? null;
} }
/** /**

View File

@ -62,6 +62,6 @@ abstract class LevelProviderManager{
public static function getProviderByName($name){ public static function getProviderByName($name){
$name = trim(strtolower($name)); $name = trim(strtolower($name));
return isset(self::$providers[$name]) ? self::$providers[$name] : null; return self::$providers[$name] ?? null;
} }
} }

View File

@ -117,7 +117,7 @@ class Anvil extends McRegion{
* @return RegionLoader * @return RegionLoader
*/ */
protected function getRegion($x, $z){ protected function getRegion($x, $z){
return isset($this->regions[$index = Level::chunkHash($x, $z)]) ? $this->regions[$index] : null; return $this->regions[Level::chunkHash($x, $z)] ?? null;
} }
/** /**

View File

@ -355,8 +355,7 @@ abstract class BaseFullChunk implements FullChunk{
} }
public function getTile($x, $y, $z){ public function getTile($x, $y, $z){
$index = ($z << 12) | ($x << 8) | $y; return $this->tileList[($z << 12) | ($x << 8) | $y] ?? null;
return isset($this->tileList[$index]) ? $this->tileList[$index] : null;
} }
public function isLoaded(){ public function isLoaded(){

View File

@ -220,7 +220,7 @@ class McRegion extends BaseLevelProvider{
} }
public function unloadChunk($x, $z, $safe = true){ public function unloadChunk($x, $z, $safe = true){
$chunk = isset($this->chunks[$index = Level::chunkHash($x, $z)]) ? $this->chunks[$index] : null; $chunk = $this->chunks[$index = Level::chunkHash($x, $z)] ?? null;
if($chunk instanceof FullChunk and $chunk->unload(false, $safe)){ if($chunk instanceof FullChunk and $chunk->unload(false, $safe)){
unset($this->chunks[$index]); unset($this->chunks[$index]);
return true; return true;
@ -246,7 +246,7 @@ class McRegion extends BaseLevelProvider{
* @return RegionLoader * @return RegionLoader
*/ */
protected function getRegion($x, $z){ protected function getRegion($x, $z){
return isset($this->regions[$index = Level::chunkHash($x, $z)]) ? $this->regions[$index] : null; return $this->regions[Level::chunkHash($x, $z)] ?? null;
} }
/** /**

View File

@ -87,9 +87,9 @@ class Flat extends Generator{
$this->preset = $preset; $this->preset = $preset;
$preset = explode(";", $preset); $preset = explode(";", $preset);
$version = (int) $preset[0]; $version = (int) $preset[0];
$blocks = isset($preset[1]) ? $preset[1] : ""; $blocks = $preset[1] ?? "";
$biome = isset($preset[2]) ? $preset[2] : 1; $biome = $preset[2] ?? 1;
$options = isset($preset[3]) ? $preset[3] : ""; $options = $preset[3] ?? "";
preg_match_all('#^(([0-9]*x|)([0-9]{1,3})(|:[0-9]{0,2}))$#m', str_replace(",", "\n", $blocks), $matches); preg_match_all('#^(([0-9]*x|)([0-9]{1,3})(|:[0-9]{0,2}))$#m', str_replace(",", "\n", $blocks), $matches);
$y = 0; $y = 0;
$this->structure = []; $this->structure = [];

View File

@ -107,7 +107,7 @@ abstract class Biome{
* @return Biome * @return Biome
*/ */
public static function getBiome($id){ public static function getBiome($id){
return isset(self::$biomes[$id]) ? self::$biomes[$id] : self::$biomes[self::OCEAN]; return self::$biomes[$id] ?? self::$biomes[self::OCEAN];
} }
public function clearPopulators(){ public function clearPopulators(){

View File

@ -81,6 +81,6 @@ class BiomeSelector{
$rainfall = (int) ($this->getRainfall($x, $z) * 63); $rainfall = (int) ($this->getRainfall($x, $z) * 63);
$biomeId = $this->map[$temperature + ($rainfall << 6)]; $biomeId = $this->map[$temperature + ($rainfall << 6)];
return isset($this->biomes[$biomeId]) ? $this->biomes[$biomeId] : $this->fallback; return $this->biomes[$biomeId] ?? $this->fallback;
} }
} }

View File

@ -290,7 +290,7 @@ class NBT{
throw new \Exception("Syntax error: invalid quote at offset $offset"); throw new \Exception("Syntax error: invalid quote at offset $offset");
} }
}elseif($c === "\\"){ }elseif($c === "\\"){
$value .= isset($data{$offset + 1}) ? $data{$offset + 1} : ""; $value .= $data{$offset + 1} ?? "";
++$offset; ++$offset;
}elseif($c === "{" and !$inQuotes){ }elseif($c === "{" and !$inQuotes){
if($value !== ""){ if($value !== ""){

View File

@ -68,7 +68,7 @@ class AutoUpdater{
"api_version" => $response["api_version"], "api_version" => $response["api_version"],
"build" => $response["build"], "build" => $response["build"],
"date" => $response["date"], "date" => $response["date"],
"details_url" => isset($response["details_url"]) ? $response["details_url"] : null, "details_url" => $response["details_url"] ?? null,
"download_url" => $response["download_url"] "download_url" => $response["download_url"]
]; ];

View File

@ -133,7 +133,7 @@ class MainLogger extends \AttachableThreadedLogger{
}else{ }else{
$type = ($errno === E_ERROR or $errno === E_USER_ERROR) ? LogLevel::ERROR : (($errno === E_USER_WARNING or $errno === E_WARNING) ? LogLevel::WARNING : LogLevel::NOTICE); $type = ($errno === E_ERROR or $errno === E_USER_ERROR) ? LogLevel::ERROR : (($errno === E_USER_WARNING or $errno === E_WARNING) ? LogLevel::WARNING : LogLevel::NOTICE);
} }
$errno = isset($errorConversion[$errno]) ? $errorConversion[$errno] : $errno; $errno = $errorConversion[$errno] ?? $errno;
if(($pos = strpos($errstr, "\n")) !== false){ if(($pos = strpos($errstr, "\n")) !== false){
$errstr = substr($errstr, 0, $pos); $errstr = substr($errstr, 0, $pos);
} }