Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96062 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 49532 invoked from network); 21 Sep 2016 14:40:02 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Sep 2016 14:40:02 -0000 Authentication-Results: pb1.pair.com header.from=morrison.levi@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=morrison.levi@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.172 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.213.172 mail-yb0-f172.google.com Received: from [209.85.213.172] ([209.85.213.172:33253] helo=mail-yb0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1C/37-04117-1CB92E75 for ; Wed, 21 Sep 2016 10:40:01 -0400 Received: by mail-yb0-f172.google.com with SMTP id 2so27425980ybv.0 for ; Wed, 21 Sep 2016 07:40: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=hT/x+lp9umvxL5cga7pL7DUfTYSUOsjY6LfLdEB2s6g=; b=tLOWrZIBvpJB3VxL3SRsU079EVcWKgCOh/fdweb9Q6mNRKEwD3d2w7rKtvFTxagNHt GnwjBlqjRFO7n7XVVSs7V6ntSLFI6JD/crVoHRBbApA79VcuIyXlJS4MqsPm6ICrhmJE zZBqGJ3XNp74xpQ3t2+6xKF+It4Vs/AWUfn8pp1Cob4eNwvZUFXpm2wVVw6nLTP9h270 6kMGBCGaOFW1s5OeEsspoenlY5ofPIA1JXm503n6gJWLyV+NqCs0TzUdSDEQ7/0x50mS L2tzCq8iZtXRHSNz62RuLYoAngi9PXQlurVYJK0miDLJLZ+aI2yG+bxtFbzy+Tjx1FAX GLrQ== 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=hT/x+lp9umvxL5cga7pL7DUfTYSUOsjY6LfLdEB2s6g=; b=Cd763Ne5BGaa9nbTiQ7V98mTwDW0lIFlxxwJMQJm7PqHieB1aR1vyHY3nZap7NYMgv eJbuUqojbzJcLTdmDz+f7dXK65eolP1YoEintHFrEy2dZDM0eKHIag+Hg30FafGINDGj Z740VDhERTfNkjullhfeLY9syaazJvBzM0Eip0+NgWjC7M/o04wNzwPh2EYk/dG3srRX MsMylXVEsdXj0//jc8LK7jbxaYCLBmDqlmsXPB3fHWx47U0klM32czsi+WEDIgiWeaOm NZM1ZCvT1Vn2ow02O78Z63H6fWS+52ciZykU4N0np6dCWJ87vvUovOvzhu+GGJvlGSZM dZdQ== X-Gm-Message-State: AE9vXwOhFmGOSxSSiW4DL844eUgoXW1aIoE1oCEvZiFhYbBLj15MWfkowopUCF+Kizx28oKzwFqaRO50jA7E/w== X-Received: by 10.37.75.198 with SMTP id y189mr35023287yba.146.1474468798698; Wed, 21 Sep 2016 07:39:58 -0700 (PDT) MIME-Version: 1.0 Sender: morrison.levi@gmail.com Received: by 10.13.193.66 with HTTP; Wed, 21 Sep 2016 07:39:58 -0700 (PDT) In-Reply-To: References: Date: Wed, 21 Sep 2016 08:39:58 -0600 X-Google-Sender-Auth: h7VWsgN6YbFKoNkaRHziERbG1m4 Message-ID: To: Marco Pivetta Cc: Niklas Keller , Nicolas Grekas , Nikita Popov , "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Fix ReflectionType::__toString() BC break From: levim@php.net (Levi Morrison) How big of a deal will this be come 7.2? or 8.0? A few projects will break on 7.1 regardless of whether the question mark is prepended or not, as has already been discussed in previous threads. The key is as Nikita has pointed out that if we don't prepend it this method is basically useless and must be deprecated. Whereas if we do prepend it then it works as it supposed to and is distinct from getName(). On Wed, Sep 21, 2016 at 7:31 AM, Marco Pivetta wrote: > That still means that code designed for 7.0 will break while reflecting 7.0 > code (`= null` scenario) when run on 7.1, effectively preventing upgrade, > Niklas. > > On 21 Sep 2016 15:27, "Niklas Keller" wrote: > >> 2016-09-21 15:14 GMT+02:00 Nikita Popov : >> >> > On Wed, Sep 21, 2016 at 10:55 AM, Nicolas Grekas < >> nicolas.grekas@gmail.com >> > > >> > wrote: >> > >> > > Hello, >> > > >> > > our turn to be hit by this 7.1 BC break in Symfony: >> > > `ReflectionType::__toString()` now adds a `?` in front of type hints >> > where >> > > `null` is allowed by their default values. >> > > >> > > But since `zend_bool` is really an `unsigned char`, we have plenty of >> > room >> > > to store and forward this semantic subtlety (nullable being set through >> > > `?Foo $arg` vs `Foo $arg = null`) so that >> `ReflectionType::__toString()` >> > > can be accurate again, thus BC. >> > > >> > > See https://github.com/php/php-src/pull/2136 >> > > >> > > Thank for you consideration of this patch. >> > > >> > >> > I don't like this. The way I see it, either ReflectionType::__toString() >> > gives you a complete representation of the type (which includes "?" no >> > matter how you happen to write it in the source code) or it does not -- >> in >> > which case this function is fundamentally broken and needs to go away. In >> > other words, either we stick with the behavior currently implemented in >> PHP >> > 7.1, or we go back to the PHP 7 behavior (there will never be a leading >> ?, >> > it just returns the name) **and we deprecate the method**. >> > >> > I consider the last part important because going to the PHP 7 behavior >> > fundamentally breaks the method (it is not actually a string >> representation >> > of the type). Furthermore, this forces consumers of ReflectionType to >> > switch to the new API based on getName() and isNullable(). >> > >> > Nikita >> > >> >> As Nikita said, starting with PHP 7.1, we'll have ReflectionType::getName() >> which does exactly what you want. You can use `__toString()` on previous >> versions and use the proper `getName()` starting with PHP 7.1. >> >> Regards, Niklas >>