Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:95392 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37935 invoked from network); 22 Aug 2016 21:14:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Aug 2016 21:14:39 -0000 Authentication-Results: pb1.pair.com smtp.mail=morrison.levi@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=morrison.levi@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.49 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.220.49 mail-pa0-f49.google.com Received: from [209.85.220.49] ([209.85.220.49:33719] helo=mail-pa0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DA/B6-33251-E3B6BB75 for ; Mon, 22 Aug 2016 17:14:39 -0400 Received: by mail-pa0-f49.google.com with SMTP id ti13so41018384pac.0 for ; Mon, 22 Aug 2016 14:14:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=8bfhvdSJRIqtXCc30ca7qoBeOF4198YtWXPG7tuhk3Y=; b=VctIKda8QUyX6oJSRP4wyTLK2EiXoTC7n4FNSi7JEGLhlwCzmjEfixOdMBJSqfQ8kp 3iMUPbO9CagYcLqhmaaRfyyBg9WHfDH2mCdNVFV68IBeHeQQEx6ezge9KdGIFga8mC8x kyNE80mV3x1gaHnYAkesH01oHqC6O/uOdqLR0dWFptc+CikInimiayzOuvaQ9qH8kk1T t3OKUzYLIAavnqSw6We480gBREmwxyxnRDQAkNPy7HpfSnSKbCjMtzSd5YYemcR21aXq bZpBhYwFKFeQg+ndf8CiuWFORNtfwkqUo3mCoe1Jk7PLHtLnum5QzI6uthEfpgUQugiM GUAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=8bfhvdSJRIqtXCc30ca7qoBeOF4198YtWXPG7tuhk3Y=; b=MGfbhbeSDdRWWMqVUZav7wl8TzYyHiEJAvVYlvmVC4PiyFvg4wEj5c/vSmyem7gClw 4eK0IW6qlfm8lp7ggQ9jjYmobXUBrlYljrsHXYCVu6adEiENbRbwxU5KRESFz6bBZC8c fv6jOWlaH8xk4DPjtt/iX/Cj0SPSerGX3NgKkG+ez3KwhZYZeLkfcb5X16jOOkg3Ve7E xW3lVE9jSRnwJCCjaHNYgaBxBh9xibyDYAwvzc8+4DhH7Y1G2iFdIAQ6BJOaARbU5GO6 nNVSgD/8r3WgpC+i85MbtLeaG8aMyeOkQCbSzolmFzB46E6ABCMNj+xS1EqBp74ndh57 Tqqg== X-Gm-Message-State: AEkoouvAnA1d68p4UtENd2PO6LOwOkNdRBBPf1PuTgjszld1j1wDhHwMkwWicdxQljAVQsTz1uelTcydKT7Mug== X-Received: by 10.66.43.7 with SMTP id s7mr46879892pal.27.1471900475815; Mon, 22 Aug 2016 14:14:35 -0700 (PDT) MIME-Version: 1.0 Sender: morrison.levi@gmail.com Received: by 10.66.24.42 with HTTP; Mon, 22 Aug 2016 14:14:34 -0700 (PDT) In-Reply-To: References: <0668D584-EE51-4932-85D7-01D8BF70E409@trowski.com> <15E198DD-FF66-475D-ABBC-54ECD2B6BF62@trowski.com> Date: Mon, 22 Aug 2016 15:14:34 -0600 X-Google-Sender-Auth: V-LVfXb2DQ4OxvhTm5FxaioDANM Message-ID: To: Dan Ackroyd Cc: Nikita Popov , Marco Pivetta , Aaron Piotrowski , internals , Stanislav Malyshev Content-Type: multipart/alternative; boundary=bcaec5304bc7017c6f053aaf8907 Subject: Re: [PHP-DEV] ReflectionType::__toString() prepending \ to class names From: levim@php.net (Levi Morrison) --bcaec5304bc7017c6f053aaf8907 Content-Type: text/plain; charset=UTF-8 On Mon, Aug 22, 2016 at 2:56 PM, Dan Ackroyd wrote: > On 22 August 2016 at 06:33, Nikita Popov wrote: > > > > Hi. > > > > Now that we have made ReflectionType::__toString() be useless and not > > represent the type, this method should be deprecated in favor of using > > ReflectionNamedType::__toString(), ::allowsNull() and any further > extensions > > that will be introduced later. > > > > If we want to go that route, doesn't it make sense to: > > * Leave ReflectionType::__toString() as it pre-7.1.0beta3 - i.e. not > including the ?nullable marker or the slash. > > * Explain that ReflectionType::__toString() is a legacy function that > isn't nullable aware and that people should use the other functions to > get the full type information for anything that might contain > functions that have nullable parameters. > > * Add a ReflectionType::isNullable() function so that can be reflected > properly, exactly as the user wrote them rather than an approximation. > > Levi Morrison wrote: > > You must attempt to generate exactly what was written in user code > > This is exactly why I don't think it's acceptable for the type > information to be including a question mark to indicate nullable. > > I use reflection to take a function that has this signature: > > function foo(Bar $sc = null) {...} > > which is valid PHP 5.x and 7.0 code, and then generate a decorated > function like: > > function loggingFoo(Bar $sc = null) { > echo "before \n"; > foo($sc); > echo "after \n"; > } > > If the type for the parameter suddenly starts having a ?nullable in > it, it means I can't run the code generator to produce code that can > be used on 5.x and 7.0 - even though the code being reflected on is > valid 5.x and 7.0 code. > > We need to be able to generate exactly what was written in the user > code from Reflection, not just an equivalent form that only works on > 7.1+ > > cheers > Dan > Ack > Let's step back for a moment here and look at some data. We introduced ReflectionType in a major release, a dot zero. Now in the next minor release (a dot one) we are adjusting its toString representation because of a new feature that affects the string representation of a single class of types in Reflection, those with a default of null. There are four projects affected by this change if it happens and at least one affected if it does not. If this is changed then four very recent and active projects are affected on a *single minor release* and if we do not change it then *at best* it is redundant and at least one project is affected. Furthermore, if generics or callable prototypes or union or intersection types or theoretically any number of type system changes occurs then the toString will change, and these four mentioned projects have to be adjusted anyway. The choice is very clear to me. We preserve the original intention and prepend the question mark. --- Lastly I acknowledge that my wording earlier was too strict; we don't generate *exactly* what the user wrote because of aliases, namespaces etc. A better descriptor would have been "equivalent". --bcaec5304bc7017c6f053aaf8907--