xref: /PHP-7.4/ext/simplexml/tests/sxe_005.phpt (revision 782352c5)
1--TEST--
2SPL: SimpleXMLIterator and overriden count()
3--SKIPIF--
4<?php
5if (!extension_loaded('simplexml')) print 'skip';
6if (!extension_loaded("libxml")) print "skip LibXML not present";
7?>
8--FILE--
9<?php
10
11$xml =<<<EOF
12<?xml version='1.0'?>
13<sxe>
14 <elem1/>
15 <elem2/>
16 <elem2/>
17</sxe>
18EOF;
19
20class SXETest extends SimpleXMLIterator
21{
22	function count()
23	{
24		echo __METHOD__ . "\n";
25		return parent::count();
26	}
27}
28
29$sxe = new SXETest($xml);
30
31var_dump(count($sxe));
32var_dump(count($sxe->elem1));
33var_dump(count($sxe->elem2));
34
35?>
36===DONE===
37--EXPECT--
38SXETest::count
39int(3)
40SXETest::count
41int(1)
42SXETest::count
43int(2)
44===DONE===
45