BaseBanner: remove unnecessary array_filter() usage

This commit is contained in:
Dylan K. Taylor 2023-12-15 15:19:44 +00:00
parent a03013d582
commit 944dd7d3e4
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -34,7 +34,6 @@ use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;
use pocketmine\player\Player;
use pocketmine\world\BlockTransaction;
use function array_filter;
use function assert;
use function count;
@ -89,11 +88,12 @@ abstract class BaseBanner extends Transparent{
* @return $this
*/
public function setPatterns(array $patterns) : self{
$checked = array_filter($patterns, fn($v) => $v instanceof BannerPatternLayer);
if(count($checked) !== count($patterns)){
throw new \TypeError("Deque must only contain " . BannerPatternLayer::class . " objects");
foreach($patterns as $pattern){
if(!$pattern instanceof BannerPatternLayer){
throw new \TypeError("Array must only contain " . BannerPatternLayer::class . " objects");
}
}
$this->patterns = $checked;
$this->patterns = $patterns;
return $this;
}