1--TEST-- 2SPL: SimpleXMLIterator and overridden count() 3--EXTENSIONS-- 4simplexml 5libxml 6--FILE-- 7<?php 8 9$xml =<<<EOF 10<?xml version='1.0'?> 11<sxe> 12 <elem1/> 13 <elem2/> 14 <elem2/> 15</sxe> 16EOF; 17 18class SXETest extends SimpleXMLIterator 19{ 20 function count(): int 21 { 22 echo __METHOD__ . "\n"; 23 return parent::count(); 24 } 25} 26 27$sxe = new SXETest($xml); 28 29var_dump(count($sxe)); 30var_dump(count($sxe->elem1)); 31var_dump(count($sxe->elem2)); 32 33?> 34--EXPECT-- 35SXETest::count 36int(3) 37SXETest::count 38int(1) 39SXETest::count 40int(2) 41