Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:95343 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 88818 invoked from network); 21 Aug 2016 15:08:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Aug 2016 15:08:04 -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.192.179 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.192.179 mail-pf0-f179.google.com Received: from [209.85.192.179] ([209.85.192.179:36369] helo=mail-pf0-f179.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 24/E2-50790-2D3C9B75 for ; Sun, 21 Aug 2016 11:08:02 -0400 Received: by mail-pf0-f179.google.com with SMTP id h186so23832069pfg.3 for ; Sun, 21 Aug 2016 08:08:01 -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=1xMc1tmg1tWC1ZiNHtyooZRtBq7+/Fa1XG+PZRJnl8A=; b=LvRlJK+T1ry+TI8WK/bOJc/V2jHyTGL3WcO5SaYoC2LOz81NJo9ZQLStuHCapWV7TK /VdOic0o725oKVuhz26VOfMu+0Txvk/l7Li2owTWWzyGyblUOWhgKo/6INUQZh3t9cz/ eeeY+KXzHDvSGz/EpXwaB11OT25ZnBHCMeXYiRm4JjhgTV/NkCYwEblH/WW+pmYliPaz 6CTVCg1Khb6eY4IgGWjBzHTsemSLEsyJ01Ho/xSg/wZwViwRu5sDEoRuHhUZKYAbNSPL 7ArZLWSmWTvGilnkgT3TiQClLpRSsjqeGO5o/jrBzQzwDmjAjdmefQ5CapQBxGZo98Sk LtlQ== 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=1xMc1tmg1tWC1ZiNHtyooZRtBq7+/Fa1XG+PZRJnl8A=; b=bn9mThBwKK202XFBW5RbwfYIZU0sbCLuHE7vRGvSbrkPhVErQlRPq4iju2jTulSvbv 1Wk9X03WLImJZ7NiLZS7wqEBj14iRgrQ6p63DRiih9g0qz+hUoYje6+g8/n6A4h8qivi a56dywfafkWm8qjYc2Ej2AEweUmWt3Ip0tjW2TTiCDlDWwhe+KnjciCWiwVTcxDEzt+1 2ga/Rqs3jsCevjbs0DwZw8MEHxkrhcH68FelsWECYYtrwC3G9+QVWJ3G2Kx3vuW32C6Z JENqy9pwcfdMXy6yPHcZIxtl/6oNRkVhzdukFCbyD9zhjU/n53//28bRgnKxahSymwTm KJYw== X-Gm-Message-State: AEkooutquz36vh6RYRnrNFppwYRFRrCMKpaqUFn+omMIOnh6Rhj5Xil1eb8sbOP6CT3ueEDHU1g1srR/A8V8xA== X-Received: by 10.98.71.140 with SMTP id p12mr34073036pfi.93.1471792079320; Sun, 21 Aug 2016 08:07:59 -0700 (PDT) MIME-Version: 1.0 Sender: morrison.levi@gmail.com Received: by 10.66.24.42 with HTTP; Sun, 21 Aug 2016 08:07:58 -0700 (PDT) In-Reply-To: References: <0668D584-EE51-4932-85D7-01D8BF70E409@trowski.com> <15E198DD-FF66-475D-ABBC-54ECD2B6BF62@trowski.com> Date: Sun, 21 Aug 2016 09:07:58 -0600 X-Google-Sender-Auth: E9UvrauQB31ZGnAvj9Ex-v2DDXY Message-ID: To: Aaron Piotrowski Cc: Marco Pivetta , internals , Stanislav Malyshev Content-Type: multipart/alternative; boundary=94eb2c0b7e2a123b98053a964c09 Subject: Re: [PHP-DEV] ReflectionType::__toString() prepending \ to class names From: levim@php.net (Levi Morrison) --94eb2c0b7e2a123b98053a964c09 Content-Type: text/plain; charset=UTF-8 On Sun, Aug 21, 2016 at 8:37 AM, Aaron Piotrowski wrote: > Hi Marco, > > > On Aug 19, 2016, at 1:31 PM, Marco Pivetta wrote: > > > > Hi Aaron et all, > > > > I tried to implement support for 7.1 in zend-code as a start: > > > > https://github.com/zendframework/zend-code/pull/87 > > > > A few issues arise: > > > > * `ReflectionType#__toString()` is too volatile, especially if we want to > > support multiple versions of PHP, therefore it's a good idea to not think > > too much about it, and instead deprecate it. Most issues I had while > > working with the feature were related with string formatting, and that's > > simply gotta die: just using a more specific API should cut it (getName, > > getClass, isNullable, etc. As few strings as possible, please!). > > * A page where we can see the current state of the `ReflectionType` API > > (and its subtypes) would be golden. > > * `ReflectionType#__toString()` seems to crash in very interesting ways > > when `?string` is reflected (see issue above - couldn't isolate > precisely) > > > > I've reverted the changes so that `ReflectionType::__toString()` is now > identical to 7.0, including *not* prepending a ? for nullable types. The > method is now just an alias of `ReflectionNamedType::getName()`. > > `ReflectionType::__toString()` should be discouraged for code generation > going forward, as it seems there's just not a way to add type features in a > BC way. My attempt to incorporate nullable types in a way that would allow > for even more complex types such as `callable(?\Type\Name, ?bool)` just > caused too many problems. > > > I am currently going through the changes, and just figured that 7.1 > implements https://wiki.php.net/rfc/reflectiontypeimprovements, even > though the RFC was declined: > > > > ./sapi/cli/php -r 'class Foo { public function bar() : ?Foo {} } > var_dump((new ReflectionMethod("Foo", "bar"))->getReturnType());' > > object(ReflectionNamedType)#2 (0) { > > } > > Only `ReflectionNamedType` was added so the object returned from parameter > and return types could have a `getName()` method. The rest of the RFC was > not implemented. This should be completely BC while allowing future types > like unions or callables. See some discussion here: > https://github.com/php/php-src/pull/2068 > > Aaron Piotrowski > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > This is too big of a revert. You must attempt to generate exactly what was written in user code which requires the prepended question mark. --94eb2c0b7e2a123b98053a964c09--