php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29206 DOMDocument::LoadXML: Strict Standards: DOMDocument::loadXML(); is not static
Submitted: 2004-07-16 11:56 UTC Modified: 2006-01-10 01:32 UTC
From: tommy at vandervorst-bs dot nl Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 5.0.0 OS: Windows Server 2003 Standard
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: tommy at vandervorst-bs dot nl
New email:
PHP Version: OS:

 

 [2004-07-16 11:56 UTC] tommy at vandervorst-bs dot nl
Description:
------------
The following code:

$d = DOMDocument::loadXML("<some><xml><here></here></xml></some>");

works perfectly well, but when setting PHP to report E_STRICT warnings:

error_reporting(E_ALL|E_STRICT);

It says:

Strict Standards: Non-static method DOMDocument::loadXML() should not be called statically in [some script] on line [some line]

which I think is incorrect, since DOMDocument::loadXML is (even according to the manual, http://nl2.php.net/manual/en/function.dom-domdocument-loadxml.php) a static function.

Reproduce code:
---------------
<?php

error_reporting(E_ALL|E_STRICT);
$d = DOMDocument::loadXML("<some><xml><here></here></xml></some>");

?>

Expected result:
----------------
No error, this code is (in my eyes) perfectly valid.

Actual result:
--------------
Strict Standards: Non-static method DOMDocument::loadXML() should not be called statically in [some script] on line [some line]

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-07-16 12:43 UTC] rrichards@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

This is not a pure static method as it is really an object method that is also allowed to be called statically, so under E_STRICT, that non-fatal message is issued.
add $d->saveXML() and you will see the document was loaded.
 [2006-01-10 01:32 UTC] nforbes@php.net
Surely the error message here is misleading. These functions/methods are clearly marked with ALLOW_STATIC... they definitely should not throw any sort of notice.

Here's a patch to eliminate the message completely:
http://noel.dotgeek.org/allow_static.patch

 [2012-04-15 14:37 UTC] hanskrentel at yahoo dot de
In PHP 5.3.10 Windows I have the problem that it's giving an error.

In my eyes it does not violate strict standards as the PHP documentation for that 
function states that this function can be called statically as well.

Could this be reviewed?
 [2012-10-11 12:49 UTC] kjarli at gmail dot com
DOMDocument::load has exactly the same problem. Either allow it or disallow it 
but do not give a warning if you use it even tho the documentation states it's 
allowed.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 23:01:29 2024 UTC