Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:72854 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 38700 invoked from network); 28 Feb 2014 09:04:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Feb 2014 09:04:26 -0000 Authentication-Results: pb1.pair.com header.from=are.you.winning@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=are.you.winning@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.176 as permitted sender) X-PHP-List-Original-Sender: are.you.winning@gmail.com X-Host-Fingerprint: 209.85.216.176 mail-qc0-f176.google.com Received: from [209.85.216.176] ([209.85.216.176:61255] helo=mail-qc0-f176.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8F/01-28957-91150135 for ; Fri, 28 Feb 2014 04:04:26 -0500 Received: by mail-qc0-f176.google.com with SMTP id m20so110461qcx.21 for ; Fri, 28 Feb 2014 01:04:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=xYuPeFbcHQo94pwtnsANE2IOSAYXWUDYorlwYLnR1+M=; b=Z3s3Bpb/iapyv6fuFK6EHBTSsY8hLlboPilYfpnxKTnz4yv0MJVUecB795LiIXPtRL FqzhlO27E6ctVE7PF1LICkMj/BMta24hdLTo5LjqVn2CqjJUQDyY70wDACN0t18fMBb2 mYMgzyfqQ9Gky/RouHAj++fUWPRwcyndgKKOcKiprnIThyacWaJqPgDqgoWjuuRiHlHZ t7vpFbs1WPTHYqSUrYgehN6FVUm9iat7j4x7vqh51uJGuaU7R7Qw2DUPHd8NEZxk3hiY Jph3//nugtdXFcL60Dbf4kidP8ItWEeW25pLUS6pC67TkHRQHqBMNHnE8NgLoH3LoewX KwXg== MIME-Version: 1.0 X-Received: by 10.224.168.203 with SMTP id v11mr1957628qay.57.1393578263430; Fri, 28 Feb 2014 01:04:23 -0800 (PST) Sender: are.you.winning@gmail.com Received: by 10.229.240.193 with HTTP; Fri, 28 Feb 2014 01:04:23 -0800 (PST) In-Reply-To: <531044A8.8050002@googlemail.com> References: <52D865C7.4070009@sugarcrm.com> <531044A8.8050002@googlemail.com> Date: Fri, 28 Feb 2014 09:04:23 +0000 X-Google-Sender-Auth: HmJAwyIbMJaHNVhF7LRPcF0x0cE Message-ID: To: Crypto Compress Cc: Marco Pivetta , PHP Developers Mailing List Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] Introducing "Array Of" RFC From: daverandom@php.net (Chris Wright) On 28 February 2014 08:11, Crypto Compress wrote: > Hello List, > > >> So, should we allow nulls in an arrayof-style type hint? > > > No. Null values (optional values) should be allowed within an > nullable-arrayof-style type hint. > > Compare: function foo(Bar $baz = null) > and: function foo(Bar $baz) > > This is not the same syntax and null is not a type. > Are you suggesting the following? function foo(Bar[] $bars) // required to pass an array of Bar objects function foo(Bar[] $bars = null) // required to pass an array of Bar or null members ...because if so, how do I specify an optional array of Bar objects? And how do I specify an optional array of Bar or null? The whole concept of allowing null members seems to completely defeat the purpose of the ArrayOf hint for me. I can understand wanting to make the parameter optional, but I cannot see a use case for null members from the point of view of the caller. I never null out members of an array, I only omit them from the declaration or remove the member from the array via e.g. unset() or stack operations (pop(), shift() etc). YMMV of course, but for me allowing null members just makes the callee's life more difficult and does not gain anything.