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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 02:01:29 2024 UTC