Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:7272 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 42449 invoked by uid 1010); 22 Jan 2004 14:48:19 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 42411 invoked by uid 1007); 22 Jan 2004 14:48:19 -0000 Date: 22 Jan 2004 14:48:19 -0000 Message-ID: <20040122144819.42410.qmail@pb1.pair.com> To: internals@lists.php.net Organization: X-User-Real-E-Mail: your email address User-Agent: PHP News Reader v2.4.1 (CDSHEEN) Mime-Version: 1.0 Content-Type: text/plain; charset="big5" Content-Transfer-Encoding: 8bit X-HTTP-Posting-Host: unknown, unknown X-HTTP-Proxy-Server: 164.129.1.39 X-Posted-By: 64.21.80.2 Subject: base class From: stephane.drouard@st.com (Stephane Drouard) PHP implements an "stdClass". I expected that: * this was the base class for all classes, even if they do not explicitly "extends stdClass", * this class implemented all the "standard" methods (__construct(), __destruct(), ...). In the PHP5 presentation, it is mentionned the interest of unified constructors. Currently it is not possible to call parent::__construct() if the class does not derived from another one, or none of its parent implements a constructor. Another problem: when you change a class implementation and decide to now implement a constructor, you have to review all its derived classes. Which finally limits the benefit of unified constructors. I think all classes should be derived from a common base class (stdClass or a new dedicated one), even if it's not explicitly written. This base class should also implement all the standard methods: __construct() Empty. __destruct() Empty. __clone() Does the bit for bit copy of the object. Note: I also added a post concerning a new cloning implementation proposal. In that case, __clone() would be empty. __toString() To be compatible with the current implementation, this method should return "Object id #n". However I would prefer it returns the class name instead, which gives a more useful piece of information than it's ID. __get() Display the "Notice: Undefined property ..." and returns NULL. __set() Create a new member (public). Note: I would appreciate that a notice is also displayed, because I don't consider this is a normal way to create members. __call() Generates a "Fatal error: Call to undefined method ...". Regards, Stephane