It returns and integer, not a "Tier". But PHP-wise, it does return a boolean value. By default, the return value of isShovel() is Tool::TIER_NONE which corresponds to 0. if(0) is the equivalent of if(false). The boolean value of 0 is false. The boolean value of any natural number is true. So all natural numbers would output true. You can test it by running this script. PHP: echo "Boolean value of 0 is:";var_dump((bool) 0);//falseecho "Boolean value of 1 is:"var_dump((bool) 1);//true$n = mt_rand(1, PHP_INT_MAX);echo "Boolean value of natural number $n is:"var_dump((bool) $n);//true Why doesn't it directly return a boolean value? Simplicity. That one function can be used to check whether the tool isShovel and also to determine what kind of shovel it is.
To avoid that, the value of is{itemtype} functions are hardcoded than being stored as a class property. If it were a class property then isShovel(), isHoe(), isShears()... etc would have returned the same value. IronShovel->isShovel() returns true while IronShovel->isHoe() returns false. So I guess the essence is not lost... ? Take it this way: Item::isShovel() returns false if the item is not a shovel, but returns the tier type if it's a shovel. PHP: if($shovelTier = Item::isShovel()){ var_dump($shovelTier);}
By coding conventions [citation needed], is*** functions always return boolean values. It is abnormal or hacky if you return something non-boolean and expect people to use it as a boolean value.
In your case, it is more sensible to use pass-by-reference parameters, e.g.: PHP: public function isShovel(&$shovelTier = null){ $shovelTier = TIER_IRON; return true;}if($item->isShovel($shovelTier)){ $player->sendMessage("Your shovel tier is $shovelTier");}