php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34019 Implementing interface with a __construct method strange behaviour
Submitted: 2005-08-06 14:09 UTC Modified: 2006-06-01 09:47 UTC
From: stochnagara at hotmail dot com Assigned: helly (profile)
Status: Closed Package: Class/Object related
PHP Version: 5.2 OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: stochnagara at hotmail dot com
New email:
PHP Version: OS:

 

 [2005-08-06 14:09 UTC] stochnagara at hotmail dot com
Description:
------------
When a class implements an interface which declares a funciton __construct with a given prototype and the class does not follow this prototype, then PHP does not raise a fatal error like in all other cases.

I know that __construct has a lot of special features but I think we need at least a notice for that.

Reproduce code:
---------------
interface constr {
	function __construct();
}

class implem implements constr {
	function __construct ($a) {
	}
}


Expected result:
----------------
Fatal error:  Declaration of implem::__construct() must be compatible with that of constr::__construct() in ...

Actual result:
--------------
5

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-06 23:39 UTC] helly@php.net
I think we should either disable __construct/__destruct enforcement or ensure the interface rules apply since that is imho the only thing that would make sense.
 [2006-03-05 19:24 UTC] helly@php.net
Fixed in head now
 [2006-06-01 09:47 UTC] stochnagara at hotmail dot com
This bug seems to be fixed now.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 12 10:01:33 2025 UTC