Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:58213 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 90053 invoked from network); 27 Feb 2012 22:49:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Feb 2012 22:49:50 -0000 Authentication-Results: pb1.pair.com smtp.mail=keisial@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=keisial@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.54 as permitted sender) X-PHP-List-Original-Sender: keisial@gmail.com X-Host-Fingerprint: 74.125.82.54 mail-ww0-f54.google.com Received: from [74.125.82.54] ([74.125.82.54:34465] helo=mail-ww0-f54.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7F/E2-11273-D880C4F4 for ; Mon, 27 Feb 2012 17:49:49 -0500 Received: by wgbdq13 with SMTP id dq13so676701wgb.11 for ; Mon, 27 Feb 2012 14:49:46 -0800 (PST) Received-SPF: pass (google.com: domain of keisial@gmail.com designates 10.180.93.4 as permitted sender) client-ip=10.180.93.4; Authentication-Results: mr.google.com; spf=pass (google.com: domain of keisial@gmail.com designates 10.180.93.4 as permitted sender) smtp.mail=keisial@gmail.com; dkim=pass header.i=keisial@gmail.com Received: from mr.google.com ([10.180.93.4]) by 10.180.93.4 with SMTP id cq4mr32306411wib.21.1330382986728 (num_hops = 1); Mon, 27 Feb 2012 14:49:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=OlTivnnWruBJx4IU5d2Fw4Otb9mCt9YQJpT0fkhBn+M=; b=Q4ItPOSu1PamCJ0Cxsj9LcO5cBUASCxdtRzg8wJQQdJUgtosM/RsChL5HDVjDjHOit WZM+igCH7I8z/S3kQw6KkIm4M/5ionu03HQgnrwicdvkJ/503VF/UYG+7/dMjDarnS1h 2jYEf8IaZYTkocCb3r01dszzhblC7TC98fCaM= Received: by 10.180.93.4 with SMTP id cq4mr25595107wib.21.1330382986687; Mon, 27 Feb 2012 14:49:46 -0800 (PST) Received: from [192.168.1.26] ([80.28.70.71]) by mx.google.com with ESMTPS id by4sm19065700wib.3.2012.02.27.14.49.44 (version=SSLv3 cipher=OTHER); Mon, 27 Feb 2012 14:49:45 -0800 (PST) Message-ID: <4F4C09AE.8010801@gmail.com> Date: Mon, 27 Feb 2012 23:54:38 +0100 User-Agent: Thunderbird MIME-Version: 1.0 To: Richard Lynch CC: "internals@lists.php.net" References: <41055a3dd36db02d3d09012231787a8d.squirrel@www.l-i-e.com> <4F4BB316.6080600@gmail.com> <2b2726ae802163c88909a8e4e161d246.squirrel@www.l-i-e.com> In-Reply-To: <2b2726ae802163c88909a8e4e161d246.squirrel@www.l-i-e.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Scalar type hinting From: keisial@gmail.com (=?ISO-8859-1?Q?=C1ngel_Gonz=E1lez?=) On 27/02/12 20:05, Richard Lynch wrote: > You are correct. > > I'd have to come up with some OTHER scenario not involving fatal > error, such as: > > strict $db = new DB(); > > and your database being down, unavailable, or connection parameters > being wrong. > > The principle remains. > > You probably still want $db to be NULL in that situation, rather than > an unusable DB object. > > Otherwise, you'll have to write a lot more sanity checking code > elsewhere, which is what you are trying to avoid in the first place... > > Or, perhaps not. > > Perhaps you really do want this case to just plain bomb out with a > failure that the $db is not strictly an object, with no recourse to > try again, or deal with the error in application logic... It could be throwing an exception. You usually want it to be just what you want. In some cases you may want to accept NULLs. You should provide a different qualifier in that case, such as "strict?" Yes, you may end up with things like nullable strict DB $db = DB::factory(); which doesn't look like PHP at all. But I suppose that's what you wanted?