Bug #52160 [Opn->Ana]: Invalid E_STRICT redefined constructor error
| From: | felipe@php.net | Date: | Thu, 24 Jun 2010 23:32:39 +0000 |
| Subject: | Bug #52160 [Opn->Ana]: Invalid E_STRICT redefined constructor error | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-151855@lists.php.net to get a copy of this message | ||
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: Open
+Status: Analyzed
Type: Bug
Package: Scripting Engine problem
Operating System: Linux
PHP Version: 5.2.14RC1
New Comment:
"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.
Previous Comments:
------------------------------------------------------------------------
[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