avoid type juggling in conditions, always use explicit boolean conditions

This commit is contained in:
Dylan K. Taylor
2020-02-05 15:44:06 +00:00
parent b96bb7d824
commit e5a2cfb65f
17 changed files with 43 additions and 43 deletions

View File

@ -78,7 +78,7 @@ class Anvil extends Fallable{
public function recalculateBoundingBox() : ?AxisAlignedBB{
$inset = 0.125;
if($this->meta & 0x01){ //east/west
if(($this->meta & 0x01) !== 0){ //east/west
return new AxisAlignedBB(
$this->x,
$this->y,

View File

@ -563,7 +563,7 @@ class Block extends Position implements BlockIds, Metadatable{
* @return AxisAlignedBB[]
*/
protected function recalculateCollisionBoxes() : array{
if($bb = $this->recalculateBoundingBox()){
if(($bb = $this->recalculateBoundingBox()) !== null){
return [$bb];
}

View File

@ -70,7 +70,7 @@ class DoublePlant extends Flowable{
* Returns whether this double-plant has a corresponding other half.
*/
public function isValidHalfPlant() : bool{
if($this->meta & self::BITFLAG_TOP){
if(($this->meta & self::BITFLAG_TOP) !== 0){
$other = $this->getSide(Vector3::SIDE_DOWN);
}else{
$other = $this->getSide(Vector3::SIDE_UP);
@ -102,7 +102,7 @@ class DoublePlant extends Flowable{
}
public function getDrops(Item $item) : array{
if($this->meta & self::BITFLAG_TOP){
if(($this->meta & self::BITFLAG_TOP) !== 0){
if($this->isCompatibleWithTool($item)){
return parent::getDrops($item);
}

View File

@ -172,7 +172,7 @@ class Leaves extends Transparent{
}
public function getDrops(Item $item) : array{
if($item->getBlockToolType() & BlockToolType::TYPE_SHEARS){
if(($item->getBlockToolType() & BlockToolType::TYPE_SHEARS) !== 0){
return $this->getDropsForCompatibleTool($item);
}

View File

@ -197,7 +197,7 @@ class Vine extends Flowable{
}
public function getDrops(Item $item) : array{
if($item->getBlockToolType() & BlockToolType::TYPE_SHEARS){
if(($item->getBlockToolType() & BlockToolType::TYPE_SHEARS) !== 0){
return $this->getDropsForCompatibleTool($item);
}