mirror of
https://github.com/php/php-src.git
synced 2026-03-27 01:32:22 +01:00
The implementation of `XMLReader::open()` and `XMLReader::XML()` still supports calling the methods statically and non-statically. However, as of PHP 8.0.0, calling these methods statically is not allowed, because they are not declared as static methods. Since we consider it to be cleaner to call these methods statically, but had deprecated to call them statically, we properly support both variants. We implement support for static and non-static calls by overloading, so that non-static calls have access to the `$this` pointer.
34 lines
606 B
PHP
34 lines
606 B
PHP
--TEST--
|
|
Calling XMLReader::open() and ::XML() statically
|
|
--SKIPIF--
|
|
<?php
|
|
if (!extension_loaded("xmlreader")) die('skip xmlreader extension not available');
|
|
?>
|
|
--FILE--
|
|
<?php
|
|
$filename = __DIR__ . '/static.xml';
|
|
|
|
$xmlstring = '<?xml version="1.0" encoding="UTF-8"?>
|
|
<books></books>';
|
|
file_put_contents($filename, $xmlstring);
|
|
|
|
$reader = XMLReader::open($filename);
|
|
while ($reader->read()) {
|
|
echo $reader->name, "\n";
|
|
}
|
|
|
|
$reader = XMLReader::XML($xmlstring);
|
|
while ($reader->read()) {
|
|
echo $reader->name, "\n";
|
|
}
|
|
?>
|
|
--EXPECTF--
|
|
books
|
|
books
|
|
books
|
|
books
|
|
--CLEAN--
|
|
<?php
|
|
unlink(__DIR__ . '/static.xml');
|
|
?>
|