mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
Fixed broken logic for recursive counts of ListTag
This commit is contained in:
@ -98,18 +98,16 @@ class ListTag extends NamedTag implements \ArrayAccess, \Countable{
|
||||
}
|
||||
|
||||
public function count($mode = COUNT_NORMAL){
|
||||
for($i = 0; true; $i++){
|
||||
if(!isset($this->{$i})){
|
||||
return $i;
|
||||
}
|
||||
if($mode === COUNT_RECURSIVE){
|
||||
if($this->{$i} instanceof \Countable){
|
||||
$i += count($this->{$i});
|
||||
}
|
||||
$count = 0;
|
||||
for($i = 0; isset($this->{$i}); $i++){
|
||||
if($mode === COUNT_RECURSIVE and $this->{$i} instanceof \Countable){
|
||||
$count += count($this->{$i});
|
||||
}else{
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
|
||||
return $i;
|
||||
return $count;
|
||||
}
|
||||
|
||||
public function getType(){
|
||||
|
Reference in New Issue
Block a user