Bug #52160 [Ana->Csd]: Invalid E_STRICT redefined constructor error
Edit report at http://bugs.php.net/bug.php?id=52160&edit=1
ID: 52160
Updated by: felipe@php.net
Reported by: manannon at seatiger dot org
Summary: Invalid E_STRICT redefined constructor error
-Status: Analyzed
+Status: Closed
Type: Bug
Package: Scripting Engine problem
Operating System: Linux
PHP Version: 5.2.14RC1
-Assigned To:
+Assigned To: felipe
New Comment:
This bug has been fixed in SVN.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2010-06-25 01:42:28] manannon at seatiger dot org
Wouldn't it be better/correct not to emit the E_STRICT at all (for the
latter case) rather than just changing the message? The code is 100%
correct and according to spec, especially since log() is static.
This bug makes it impossible to create an E_STRICT clean Log::log() type
method (Log->log() is also unavailable if there is a constructor
defined).
------------------------------------------------------------------------
[2010-06-25 01:32:39] felipe@php.net
"Since it has already found a __construct() method, it should not assume
that log() is also a constructor."
Yes, It should not, and actually does not do this. But the E_STRICT is
emitted for both cases, though.
I.e.:
class foo {
function foo() { }
function __construct() { } // E_STRICT + redefinition
}
class bar {
function __construct() { }
function bar() { } // E_STRICT only
}
However, we should change the message for the late.
------------------------------------------------------------------------
[2010-06-23 15:21:25] manannon at seatiger dot org
Description:
------------
The following class generates the E_STRICT warning: Strict standards:
Redefining already defined constructor for class Log.
However according to http://php.net/manual/en/language.oop5.decon.php,
PHP5 will only assume log() is a constructor if it cannot find a
__construct() method:
"For backwards compatibility, if PHP 5 cannot find a __construct()
function for a given class, it will search for the old-style constructor
function, by the name of the class."
Since it has already found a __construct() method, it should not assume
that log() is also a constructor.
Test script:
---------------
<?php
class Log
{
public function __construct() { }
public static function log() { }
}
Expected result:
----------------
Nothing
Actual result:
--------------
Strict standards: Redefining already defined constructor for class Log
in ....
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=52160&edit=1
Thread (4 messages)