ID:               41398
 Updated by:       [EMAIL PROTECTED]
 Reported By:      RQuadling at GMail dot com
 Status:           Wont fix
 Bug Type:         DOM XML related
 Operating System: Windows XP SP2
 PHP Version:      5CVS-2007-05-15 (snap)
 New Comment:

This is specific to internal classes using the ZEND_ACC_ALLOW_STRICT
flag (not a true static method). Technically there should be methods
with different names (one static and one non-static) - hence the
E_STRICT message so the user can then decide whether to break strict
standards or not.

This is something that most likely needs to be clarified in the docs
(you can but in most cases shouldn't)


Previous Comments:
------------------------------------------------------------------------

[2007-05-16 12:08:08] RQuadling at GMail dot com

I would propose that this E_STRICT warning is removed, allowing the
methods to be called statically and NOT generate a warning.

I understand that in userland classes, calling a non static method
statically is wrong (because the original developer didn't say the
method could be called statically), but in the case of the few methods
in DOM/XMLReader (and untested the one in persistent COM), they HAVE
been declared static, so they CAN be called statically and therefore
they ARE following strict rules.

It seems to me anyway.

I know I've missed something here. Is it that internal classes and
userland classes are treated differently internally? (I can't see that
being the case as you'd have to maintain 2 different models of operation
for the same thing).

------------------------------------------------------------------------

[2007-05-16 12:02:01] RQuadling at GMail dot com

So, should the documentation by amended to say that whilst they CAN be
called statically, they shouldn't.

It is trying to define the reason why they shouldn't be called that is
the problem.

I'm not an internals guy, but it if DOES work, even with E_STRICT, why
does it report it as a problem at all.

I can appreciate a WFx on this - if it works why break it.

I suppose what I'm trying to work out is why is it NOT strict OOP?
Calling a static method is just what is being done and it IS working and
no-one can tell why it is a problem to do so.

------------------------------------------------------------------------

[2007-05-16 11:56:20] [EMAIL PROTECTED]

It is there for convenience (even though there are some that do not
agree with it) - and its not going to be changed in any event for BC
reasons.

When E_STRICT is enabled the user is told that Strict standards are
enabled and that they should not call the method statically (it says
should not because the call still works).

When E_STRICT is not enabled then no messages and no problems (and
again is still works).

------------------------------------------------------------------------

[2007-05-15 12:48:22] RQuadling at GMail dot com

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


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=41398&edit=1

Reply via email to