Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:72844 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 2961 invoked from network); 27 Feb 2014 21:11:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Feb 2014 21:11:45 -0000 Authentication-Results: pb1.pair.com smtp.mail=pjsturgeon@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=pjsturgeon@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.46 as permitted sender) X-PHP-List-Original-Sender: pjsturgeon@gmail.com X-Host-Fingerprint: 209.85.215.46 mail-la0-f46.google.com Received: from [209.85.215.46] ([209.85.215.46:54550] helo=mail-la0-f46.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A3/B0-33117-F0AAF035 for ; Thu, 27 Feb 2014 16:11:44 -0500 Received: by mail-la0-f46.google.com with SMTP id hr17so2078819lab.5 for ; Thu, 27 Feb 2014 13:11:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=0HOKmSxyeshoiRbxGcU3ckLjpdqlXRi02HW/qFoAvdc=; b=ftoLsDWGIk5WSagOE+jjJzcEhzRUo+u9CH0joTdWAnPVMVciBJrKBb3TimKv7MBiAy vvGMk75J9istv+8u0OkbXcvrYsyjWtSH3ITr4YyW57FzmiXPSORKVCy589/tUsv+dGeV 7Rm1ZUNkdKI6fCkFixOdzGb/J0gXnS8n2rA0kWk+HpwJ71mFPciNzfD0HtoP0UTJeL17 G9yB3BsC61/lmtCeUPwpDrq1qyVqZMqb6YFXwOECNKMeijU0rCdSGBB8W6e7wGUhv58u GDejtsxqC0tTJoR9NVeP4CPZnOZC8o0ORIyT4YcXb2juydzrUcDzM7M1mj7XEvZ0Guoj yvpA== MIME-Version: 1.0 X-Received: by 10.152.87.140 with SMTP id ay12mr8144058lab.1.1393535500607; Thu, 27 Feb 2014 13:11:40 -0800 (PST) Received: by 10.114.66.44 with HTTP; Thu, 27 Feb 2014 13:11:40 -0800 (PST) In-Reply-To: References: <52D865C7.4070009@sugarcrm.com> Date: Thu, 27 Feb 2014 16:11:40 -0500 Message-ID: To: Andrey Andreev Cc: "internals@lists.php.net" Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] Introducing "Array Of" RFC From: pjsturgeon@gmail.com (Philip Sturgeon) From the survey I posted ( http://grokbase.com/p/php/php-internals/141rva4cf7/php-dev-vote-array-of-v-generics ) the most popular option seemed to be "C) I want both". While I am not just blindly suggesting we copy Java, they do have both features with different syntax, so the idea for this RFC is going to be: keep on trucking with the array of syntax and we put it to a vote. If people do not like the RFC as it is then we can revisit the syntax, but as people are interested in both features it just makes sense to assume this syntax is up for the job. The only open question remaining is: Should null be an acceptable value inside the array, or can it only contain items of the type specified? The following equivalent code will explain the difference: A) foreach ($foos as $foo) { if (! $foo instanceof Face) { throw new Exception ('AAAGGGGGHHH!'); } } or B) foreach ($foos as $foo) { if (! is_null($foo) and ! $foo instanceof Face) { throw new Exception ('AAAGGGGGHHH!'); } } Logic suggests to me that A makes more sense, as if you ask specifically for an array of "Face" and want to act on it like every single item is an instance of "Face", then letting null's slip into there just adds more boilerplate and introduces a second - and totally uneccessary - array traversal to find them or remove them. So, should we allow nulls in an arrayof-style type hint?