mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-14 09:49:50 +00:00
Fixed broken logic for recursive counts of ListTag
This commit is contained in:
parent
d4cc7d13cd
commit
2e480b5ea1
@ -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(){
|
||||
|
Loading…
x
Reference in New Issue
Block a user