Fixed broken logic for recursive counts of ListTag

This commit is contained in:
Dylan K. Taylor 2017-05-19 19:15:08 +01:00
parent d4cc7d13cd
commit 2e480b5ea1

View File

@ -98,18 +98,16 @@ class ListTag extends NamedTag implements \ArrayAccess, \Countable{
} }
public function count($mode = COUNT_NORMAL){ public function count($mode = COUNT_NORMAL){
for($i = 0; true; $i++){ $count = 0;
if(!isset($this->{$i})){ for($i = 0; isset($this->{$i}); $i++){
return $i; if($mode === COUNT_RECURSIVE and $this->{$i} instanceof \Countable){
} $count += count($this->{$i});
if($mode === COUNT_RECURSIVE){ }else{
if($this->{$i} instanceof \Countable){ $count++;
$i += count($this->{$i});
}
} }
} }
return $i; return $count;
} }
public function getType(){ public function getType(){