Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:55496 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 96727 invoked from network); 18 Sep 2011 12:27:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Sep 2011 12:27:09 -0000 Authentication-Results: pb1.pair.com smtp.mail=frederic.hardy@mageekbox.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=frederic.hardy@mageekbox.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mageekbox.net from 217.70.183.196 cause and error) X-PHP-List-Original-Sender: frederic.hardy@mageekbox.net X-Host-Fingerprint: 217.70.183.196 relay4-d.mail.gandi.net Linux 2.6 Received: from [217.70.183.196] ([217.70.183.196:51733] helo=relay4-d.mail.gandi.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E0/11-22692-B93E57E4 for ; Sun, 18 Sep 2011 08:27:07 -0400 X-Originating-IP: 217.70.178.133 Received: from mfilter3-d.gandi.net (mfilter3-d.gandi.net [217.70.178.133]) by relay4-d.mail.gandi.net (Postfix) with ESMTP id 7F40A172084; Sun, 18 Sep 2011 14:27:03 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mfilter3-d.gandi.net Received: from relay4-d.mail.gandi.net ([217.70.183.196]) by mfilter3-d.gandi.net (mfilter3-d.gandi.net [10.0.15.180]) (amavisd-new, port 10024) with ESMTP id waZmQaed8xDO; Sun, 18 Sep 2011 14:27:01 +0200 (CEST) X-Originating-IP: 78.224.200.11 Received: from [192.168.0.11] (oul69-5-78-224-200-11.fbx.proxad.net [78.224.200.11]) (Authenticated sender: frederic.hardy@mageekbox.net) by relay4-d.mail.gandi.net (Postfix) with ESMTPA id 42897172070; Sun, 18 Sep 2011 14:26:58 +0200 (CEST) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=iso-8859-1 In-Reply-To: Date: Sun, 18 Sep 2011 14:26:58 +0200 Cc: RQuadling@gmail.com, Ferenc Kovacs , Nikita Popov , PHP internals Content-Transfer-Encoding: quoted-printable Message-ID: <8A2C4A73-0ECA-4EC0-A71D-BD28D1CCEA46@mageekbox.net> References: To: Pierre Joye X-Mailer: Apple Mail (2.1084) Subject: Re: [PHP-DEV] __constructor parameter limitations. From: frederic.hardy@mageekbox.net (=?iso-8859-1?Q?Fr=E9d=E9ric_Hardy?=) Hi ! > For one I do think that enforcing strictness, or as I see it, clean > code and implementation, should be done in php. We did not do that in > the past and it has created more issues than anything else in the long > run. +1. > One solution to solve the need of having different methods or > constructors signatures is to support multiple signature per method or > constructor, as long as the signature of the parent class or interface > is available. This is something becoming more and more common in other > languages and is actually very handy. Having such things would have > also avoided bad (per design while necessary) sutff like the recent > reflection function to create objects without invoking the > constructor. +1. The possibility to defined multiple signature per method will be a great = improvement. A class like this : class foo { function barForArray(array $array) {...} function barForACall(aCall $objectClass) {...} function barForCallable(Callable $callable) {...} } foreach ($arrayOfUndeterminedThings as $data) { switch (true) { case is_array($data): $foo->barForArray($data); break; case $data instanceof aCall: $foo->barForACall($data); break; case $data instanceof Callable: $foo->barForCallable($data); break; } } will become : class foo { function bar(array $array) {...} function bar(aCall $objectClass) {...} function bar(Callable $callable) {...} } foreach ($arrayOfUndeterminedThings as $data) { $foo->bar($data); } Best regards, Fred -- =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Fr=E9d=E9ric Hardy : Architecte d'application/Admin. syst=E8me/Ergonome CV : = http://blog.mageekbox.net/public/cv.frederic.hardy.pdf Blog : http://blog.mageekbox.net Twitter : http://twitter.com/mageekguy =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D