php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #39057 Docs for DOMDocument::load() describe it as static, but gives error in E_STRICT.
Submitted: 2006-10-06 08:17 UTC Modified: 2007-10-14 23:38 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (50.0%)
From: nickj-phpbugs at nickj dot org Assigned:
Status: Closed Package: Documentation problem
PHP Version: 5CVS-2007-03-20 (snap) OS: Ubuntu Linux
Private report: No CVE-ID: None
 [2006-10-06 08:17 UTC] nickj-phpbugs at nickj dot org
Description:
------------
From http://php.net/manual/en/function.dom-domdocument-load.php : "This method may also be called statically to load and create a DOMDocument object." There is also a code example. Running the static example code with E_ALL | E_STRICT error_reporting generates a warning.

Reproduce code:
---------------
echo "<blah/>" > file.xml
php5.2-200610042230/sapi/cli/php  -r 'error_reporting(E_ALL | E_STRICT); $doc = DOMDocument::load("file.xml");'

Expected result:
----------------
No error.

Actual result:
--------------
PHP Strict Standards:  Non-static method DOMDocument::load() should not be called statically in Command line code on line 1


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-12-02 07:57 UTC] bjori@php.net
The method _can_ be called statically, but it shouldn't.
Most internal object methods cannot be called statically.
 [2006-12-07 01:18 UTC] nickj-phpbugs at nickj dot org
> The method _can_ be called statically, but it shouldn't.

Well in that case, there is definitely a documentation bug. Please tell me, where does it say this in the documentation?

It should say "Calling this method statically is deprecated, and will generate an error in E_STRICT error logging mode".

Instead it says this method can be called statically, period.

Calling a method in a way that the documentation says is valid, and getting a error (even under the strictest error logging) is a bug - reopening.

Please either fix the method to not generate an error, or fix the documentation to say "you shouldn't do this".

> Most internal object methods cannot be called statically.

How is that relevant? This method's documentation explicitly says it _can_ be called statically. To then generate an error that says DOMDocument::load() is a "Non-static method" is at best misleading, and at worst just plain wrong.
 [2006-12-29 00:58 UTC] didou@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

I removed the whole static part.
Thank you for your feedback
 [2007-03-20 07:25 UTC] nickj-phpbugs at nickj dot org
> I removed the whole static part.

At http://php.net/manual/en/function.dom-domdocument-load.php , it currently says: "If called statically, returns a DOMDocument." I think either every reference to static should be removed entirely, or using the static calls should be officially described as deprecated in the documentation, or the function should be updated to run without generating an error in E_STRICT.

Personally, I would prefer the third option, but the other two also solve the problem (by making what PHP actually does match what the documentation says it does).

Also I have verified that the error-message is still present in the latest PHP 5.2 snapshot (200703200530) when using E_STRICT.

> we would like to ask you to be a bit patient.

I've waited nearly 3 months, hope that's sufficient time to wait before reopening for the reason described above.
 [2007-05-09 06:32 UTC] david dot nqd at gmail dot com
Quick suggestion that may save some people a fair bit of time. Could someone replace "If called statically, returns a DOMDocument." with "If called statically, returns a DOMDocument, but also causes an E_STRICT warning."
 [2007-08-17 16:27 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 [2007-10-14 23:38 UTC] nickj-phpbugs at nickj dot org
There is a PHP patch for this (rather than a tweak to the 
documentation) that should fix this. It's by Noah Fontes,
not me, and he cautioned me that it was outdated code, 
and that it touches the Zend internals. However, I think
it's best to include it here as ideally there would be 
a "deep fix" with an update to PHP for this problem, rather
that with a tweak to the documentation to indicate that 
this is a known problem. Noah's patch is at:
http://files.nickj.org/php/allow_static.patch
 [2020-02-07 06:10 UTC] phpdocbot@php.net
Automatic comment on behalf of didou
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=f403566f96c7819cb95177c6fcfb8e2480eb0f51
Log: Fix #39057: Loose the static call
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 13 18:01:32 2025 UTC