Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67477 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 72836 invoked from network); 24 May 2013 04:30:13 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 May 2013 04:30:13 -0000 Authentication-Results: pb1.pair.com header.from=swhitemanlistens-software@cypressintegrated.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=swhitemanlistens-software@cypressintegrated.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain cypressintegrated.com designates 173.1.104.101 as permitted sender) X-PHP-List-Original-Sender: swhitemanlistens-software@cypressintegrated.com X-Host-Fingerprint: 173.1.104.101 rproxy2-b-iv.figureone.com Windows 2000 SP2+, XP SP1 (seldom 98 4.10.2222) Received: from [173.1.104.101] ([173.1.104.101:60103] helo=rproxy2-b-iv.figureone.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id ED/1B-16824-CCCEE915 for ; Fri, 24 May 2013 00:30:05 -0400 Received: from localhost ([216.220.114.66]) by rproxy2-b-iv.figureone.com (Brand New Heavy v1.0) with ASMTP id JJC93601 for ; Thu, 23 May 2013 21:30:01 -0700 Date: Fri, 24 May 2013 00:29:20 -0400 Reply-To: Sanford Whiteman X-Priority: 3 (Normal) Message-ID: <271053872.20130524002920@cypressintegrated.com> To: "Richard Lynch" In-Reply-To: <6b642a96e673c29dbaf2f239be15f7f6.squirrel@www.l-i-e.com> References: <6b642a96e673c29dbaf2f239be15f7f6.squirrel@www.l-i-e.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Cannot call constructor From: swhitemanlistens-software@cypressintegrated.com (Sanford Whiteman) > I use some OOP library, that is a "black box" and I like it that way. Hmm, there's "well-documented, change-controlled, trustable API that you shouldn't try to work around" and then there's "black box." I'm not sure the latter ever sounds like a good thing... I've always used it as a bad word. > Suddenly my code doesn't work. Maybe the resource is only needed under > certain conditions. So their __construct doesn't get called, but > nothing bad happens until the circumstances where they need the > __construct called. If their __construct suddenly becomes mandatory, they are deprecating something they (I presume explicitly) supported in the past: ctor overrides without call super. So either they put this in giant blinking text in their UPDATING file and you missed it, or they broke backward compatibility and didn't know it or didn't care. If I were faced with their situation, I'd make the ctor final to make damn sure you realized something was wrong. Then I would say overriding __construct is no longer supported because continuing to support it means mandating call super, which is an impossible contract for the language (this anguage) to enforce. I would abstract the whole thing out to an initChild() type pattern and so on. If you have to change your code, them's the breaks, as long as they give a clear path. I don't think the solution is to work around such mistakes on the part of a lib developer by silencing (?) calls to a nonexistent method _in addition to_ mandating call super -- IMO, that's even smellier than call super on its own. Why not add auto-super contracts to PHP instead (which would include skipping nonexistent super methods)? Making the undefined method error catchable instead of fatal I agree with, though. More like the more catchable world of Reflection. -- Sandy