|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-06-27 07:46 UTC] oancea at gmail dot com
Description:
------------
There is an inconsistency between the old style class constructor (class name) and the new one (__construct) when defining interfaces (see reproduce code bellow).
Reproduce code:
---------------
interface IConfigurator {
public function __construct();
}
class XmlConfigurator implements IConfigurator {
public function XmlConfigurator() {
printf("%s\n", __METHOD__);
}
}
$config = new XmlConfigurator();
Expected result:
----------------
One of:
* XmlConfigurator::XmlConfigurator
* Fatal error: old style constructor is deprecated
Actual result:
--------------
Fatal error: Class XmlConfigurator contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (IConfigurator::__construct) in
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 20 21:00:01 2025 UTC |
How about this one: abstract class IConfigurator { public abstract function __construct(); } class XmlConfigurator extends IConfigurator { public function XmlConfigurator() { printf("%s\n", __METHOD__); } } $config = new XmlConfigurator(); Can you point me to the exact documentation where it states that the old style constructor should not be used, at least not in interfaces or in abstract classes? Thank-you.