xref: /PHP-8.0/ext/simplexml/tests/sxe_005.phpt (revision f8d79582)
1--TEST--
2SPL: SimpleXMLIterator and overridden 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--EXPECT--
37SXETest::count
38int(3)
39SXETest::count
40int(1)
41SXETest::count
42int(2)
43