|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52160 Invalid E_STRICT redefined constructor error
Submitted: 2010-06-23 15:21 UTC Modified: 2010-06-26 21:19 UTC
From: manannon at seatiger dot org Assigned: felipe (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.2.14RC1 OS: Linux
Private report: No CVE-ID: None
 [2010-06-23 15:21 UTC] manannon at seatiger dot org
The following class generates the E_STRICT warning: Strict standards: Redefining already defined constructor for class Log. 

However according to, 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:
class Log
	public function __construct() { } 
	public static function log() { }

Expected result:

Actual result:
Strict standards: Redefining already defined constructor for class Log in ....


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-06-25 01:32 UTC]
-Status: Open +Status: Analyzed
 [2010-06-25 01:32 UTC]
"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.

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-25 01:42 UTC] 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-26 21:19 UTC]
-Status: Analyzed +Status: Closed -Assigned To: +Assigned To: felipe
 [2010-06-26 21:19 UTC]
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
Thank you for the report, and for helping us make PHP better.

 [2010-06-26 21:19 UTC]
Automatic comment from SVN on behalf of felipe
Log: - Fixed bug #52160 (Invalid E_STRICT redefined constructor error)
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Thu Sep 28 22:01:24 2023 UTC