Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91015 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 41709 invoked from network); 29 Jan 2016 18:28:03 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Jan 2016 18:28:03 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.45 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.45 mail-wm0-f45.google.com Received: from [74.125.82.45] ([74.125.82.45:37100] helo=mail-wm0-f45.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C8/D0-35322-23FABA65 for ; Fri, 29 Jan 2016 13:28:03 -0500 Received: by mail-wm0-f45.google.com with SMTP id l66so66000693wml.0 for ; Fri, 29 Jan 2016 10:28:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-type:content-transfer-encoding; bh=mKiRuRu0r7Bb3sFtk0ukj2BRvHMEaLpOLlEbv0GaHZg=; b=swLHpSX5jlRXHp5VgwT9Xt34FB4Bxkqttx66+/WTckrCffPAXl4Q6kk7pUbT2yp180 uq53JhZiq4KU//2jACpwAxHTiXJPTCXWXm9rZgOXMdYaDPjUZ9PGLlSUntdO7HfkDijS IiVtzwa7rjuuo7gkBwDJz/CW9AbtffW5D5/WJsFLUOgQvakMvdJ47pTrVUZPNCd/Bi/Z KVjeRZ4b7MZd8XdN1Zb6Q6elJeuYtQk8is2VOLzsimsagdEWWrbp+vyqSZ2Q1mBk3Z3j MopbmPGAQi+90YJuV5whMMoUBlWhFtL9hTxmRm8d2AXlLw/FNUvNX9u9uGkRnUNxzO7d niyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-type :content-transfer-encoding; bh=mKiRuRu0r7Bb3sFtk0ukj2BRvHMEaLpOLlEbv0GaHZg=; b=A2fLByYLFmMOoYT2XuSM7E1i39YP6y5F135h2JNhSi1OxIhSULpwfD1EhR6CqMK/c7 XQPzkcu1bvWzW9i4s7r5V32SNhcCweNa4K86UIMZqGcXDsGMVuibvAt+tLYBGYK4cGSW 0nfXwYGH667wqcRkemn06sFdbY+VCHiSut547s/eDt8sCl3YFR3nLonWdRUvxNa7mPGN sd516AI742Pkj9ar00v7pq6DG/wXkyWe9y6N7lAZBHLv6DpmM3+8ttdD5iJ/qblnJ0Gb O3RpxCkBc4klYmOLwon82uwjImE9BjNypnWGdFs4IJ4utaSV2Zt7aShDoBPTAJNOE6Pk 3Rbw== X-Gm-Message-State: AG10YOSKrJNGoN/0wQxXPJmqbyU7sYJf2qgWiEwIiZYlSe0LoTEO2BQozkH0Xan6/f3qWQ== X-Received: by 10.28.87.21 with SMTP id l21mr10060967wmb.8.1454092079327; Fri, 29 Jan 2016 10:27:59 -0800 (PST) Received: from [192.168.0.150] ([93.188.182.58]) by smtp.googlemail.com with ESMTPSA id o7sm16772139wjf.45.2016.01.29.10.27.58 for (version=TLSv1/SSLv3 cipher=OTHER); Fri, 29 Jan 2016 10:27:58 -0800 (PST) To: "internals@lists.php.net" References: <56AB42F7.7080403@gmail.com> Message-ID: <56ABAED1.2040402@gmail.com> Date: Fri, 29 Jan 2016 18:26:25 +0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] get_class behavior From: rowan.collins@gmail.com (Rowan Collins) Dan Ackroyd wrote on 29/01/2016 13:56: > On 29 January 2016 at 10:46, Rowan Collins wrote: >> You appear to be suggesting that "get_class()" should behave differently >> than "get_class(null)". >> I don't know if internal parameter handling (ZPP) works like userland >> parameters > Regardless of how internals works, it's a thing in userland PHP. > > function foo($bar = null) > { > echo "number of args is: ".func_num_args(). "\n"; > } > > foo(); > foo(null); > > // Output is: > // number of args is: 0 > // number of args is: 1 > > It's a useful thing to do when you want to distinguish between null > being passed, and the default value being used. Just like in this > case. The same is possible for internal functions. OK, so it's possible, but it's not something I've seen done very often, and in my opinion it would be a really confusing thing to do. "Ah, an optional parameter, what does it default to?" "Nothing" "You mean null?" "No, null has a separate meaning" "Separate from what?" "Nothing" etc... It's worryingly reminiscent of the endless debates about isset() and distinguishing an non-existent variable from one which has been explicitly set to null - you're inventing an extra kind of "very null". Presumably you'd get to this point by saying "if $bar is an int, do this; if $bar is null, do this; oh, I need a third case, let's do some magic with func_num_args()"; so what happens when you need a fourth case? Even worse, in this case, you're doing the opposite of what many functions do - rather than saying "this parameter used to be optional, but now you have to be specific even if you pass null", you're saying "this parameter is still optional, but if you pass its default value in you'll get a notice/warning". I understand the intention, but I think this approach would just lead to confusion. Regards, -- Rowan Collins [IMSoP]