|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-05-16 11:56 UTC] rrichards@php.net
[2007-05-16 12:02 UTC] RQuadling at GMail dot com
[2007-05-16 12:08 UTC] RQuadling at GMail dot com
[2007-05-16 13:13 UTC] rrichards@php.net
[2010-09-05 05:22 UTC] philip@php.net
-Summary: [chm] bug on
function.dom-domdocument-loadxml.html
+Summary: DOMDocument->loadXML() documents static is
okay, but gives E_STRICT
-Status: Wont fix
+Status: Verified
-Type: Bug
+Type: Documentation Problem
-PHP Version: 5CVS-2007-05-15 (snap)
+PHP Version: 5.3.4-dev
[2010-09-05 05:22 UTC] philip@php.net
[2010-10-22 15:50 UTC] kalle@php.net
-Package: DOM XML related
+Package: Documentation problem
[2010-11-10 22:34 UTC] salathe@php.net
[2010-11-10 23:01 UTC] salathe@php.net
-Status: Verified
+Status: Closed
-Assigned To:
+Assigned To: salathe
[2010-11-10 23:01 UTC] salathe@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 04 05:00:01 2025 UTC |
Description: ------------ DOMDocument->loadXML() is documented as being able to be called statically - DOMDocument::loadXML() But this generates a strict error. I don't know if this is doc bug or a libxml/DOM bug. $doc will be correctly populated and workable. I know that "loadXML() is not a true static function. It is just allowed to be called statically. When called statically within a method of an instantiated DOMDocument object it acts as if the method had been called directly from the object itself rather than statically." (I've read the bugs), but what does this mean for the user where the documentation says it a static call IS allowed and the that the static call actually works (but gives the Strict warning). The error says "should not", not "cannot". In looking at all the methods in all the extensions in php-src, all those with ZEND_ACC_ALLOW_STATIC, when called statically, result in the warning shown. Either it shouldn't be allowed to be called Statically (and the documentation amended to remove this option) or it should be allowed to be called statically (and the strict message is removed). Either way something isn't right. There are only 4 files in the whole of the php-src/ext folder with ZEND_ACC_ALLOW_STATIC com_persist.c, document.c, domimplementation.c and php_xmlreader.c The example in the dox for DOMImplementation->hasFeature() uses a static call ... ... if (DOMImplementation::hasFeature($key, '2.0')) { ... And this results in a lot of Strict errors. Clearly, not what you would be expecting. Without the ZEND_ACC_ALLOW_STRICT, I assume you wouldn't be able to call them statically (it seems that way in zend_vm_execute.h, so should this be removed from these extensions? Reproduce code: --------------- <?php $domxml = DOMDocument::loadXML('<root><node /></root>'); $domhtml = DOMDocument::loadHTML('<html><head><title>Title</title></head><body>Stuff</body></html>'); $xmlxml = XMLReader::XML('<html><head><title>Title</title></head><body>Stuff</body></html>'); $features = array( 'Core' => 'Core module', 'XML' => 'XML module', 'HTML' => 'HTML module', 'Views' => 'Views module', 'Stylesheets' => 'Style Sheets module', 'CSS' => 'CSS module', 'CSS2' => 'CSS2 module', 'Events' => 'Events module', 'UIEvents' => 'User interface Events module', 'MouseEvents' => 'Mouse Events module', 'MutationEvents' => 'Mutation Events module', 'HTMLEvents' => 'HTML Events module', 'Range' => 'Range module', 'Traversal' => 'Traversal module' ); foreach ($features as $key => $name) { if (!DOMImplementation::hasFeature($key, '2.0')) { echo "Has feature $name\n"; } else { echo "Missing feature $name\n"; } } ?> Expected result: ---------------- Has feature Core module Missing feature XML module Has feature HTML module Has feature Views module Has feature Style Sheets module Has feature CSS module Has feature CSS2 module Has feature Events module Has feature User interface Events module Has feature Mouse Events module Has feature Mutation Events module Has feature HTML Events module Has feature Range module Has feature Traversal module Actual result: -------------- Strict Standards: Non-static method DOMDocument::loadXML() should not be called statically in C:\static_calls.php on line 2 Strict Standards: Non-static method DOMDocument::loadHTML() should not be called statically in C:\static_calls.php on line 3 Strict Standards: Non-static method XMLReader::XML() should not be called statically in C:\static_calls.php on line 4 Strict Standards: Non-static method DOMImplementation::hasFeature() should not be called statically in C:\static_calls.php on line 24 Has feature Core module Strict Standards: Non-static method DOMImplementation::hasFeature() should not be called statically in C:\static_calls.php on line 24 Missing feature XML module Strict Standards: Non-static method DOMImplementation::hasFeature() should not be called statically in C:\static_calls.php on line 24 Has feature HTML module Strict Standards: Non-static method DOMImplementation::hasFeature() should not be called statically in C:\static_calls.php on line 24 Has feature Views module Strict Standards: Non-static method DOMImplementation::hasFeature() should not be called statically in C:\static_calls.php on line 24 Has feature Style Sheets module Strict Standards: Non-static method DOMImplementation::hasFeature() should not be called statically in C:\static_calls.php on line 24 Has feature CSS module Strict Standards: Non-static method DOMImplementation::hasFeature() should not be called statically in C:\static_calls.php on line 24 Has feature CSS2 module Strict Standards: Non-static method DOMImplementation::hasFeature() should not be called statically in C:\static_calls.php on line 24 Has feature Events module Strict Standards: Non-static method DOMImplementation::hasFeature() should not be called statically in C:\static_calls.php on line 24 Has feature User interface Events module Strict Standards: Non-static method DOMImplementation::hasFeature() should not be called statically in C:\static_calls.php on line 24 Has feature Mouse Events module Strict Standards: Non-static method DOMImplementation::hasFeature() should not be called statically in C:\static_calls.php on line 24 Has feature Mutation Events module Strict Standards: Non-static method DOMImplementation::hasFeature() should not be called statically in C:\static_calls.php on line 24 Has feature HTML Events module Strict Standards: Non-static method DOMImplementation::hasFeature() should not be called statically in C:\static_calls.php on line 24 Has feature Range module Strict Standards: Non-static method DOMImplementation::hasFeature() should not be called statically in C:\static_calls.php on line 24 Has feature Traversal module