Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96056 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 39213 invoked from network); 21 Sep 2016 13:31:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Sep 2016 13:31:19 -0000 Authentication-Results: pb1.pair.com smtp.mail=ocramius@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ocramius@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.51 as permitted sender) X-PHP-List-Original-Sender: ocramius@gmail.com X-Host-Fingerprint: 209.85.215.51 mail-lf0-f51.google.com Received: from [209.85.215.51] ([209.85.215.51:32775] helo=mail-lf0-f51.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 73/35-04117-6AB82E75 for ; Wed, 21 Sep 2016 09:31:19 -0400 Received: by mail-lf0-f51.google.com with SMTP id b71so14443539lfg.0 for ; Wed, 21 Sep 2016 06:31:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=oIjrHB+2XA5y1cbE7i62fYAvZHdNUUI++6d8Tu5EOwY=; b=G0YXNqvG/vhMimutiRO1lkIMscS96Pj0gUfAGTVfS/p8mzyQ8nLOL/N62syBiPOxp2 6Vb5d6qqNz3j05UH08cS8daTaXIb/NIDu8mhfeJShw2YMJWCFb+txlwQddsSd7mUmWV2 EqupoUoFsCeEY3HWHtOk24QrFND2b+hGf7tZ7opD/46t5L+bkp1II+VOBjh3TFUkF0ea A2kNy8JPyCr2UrHklheOYcoWt7+xzMWag84pQC370We8tc28Hmj5ACQCQHZ5yxZrEeYm qI+8L6Zvzp68vXtg3k3fvffiMG4Wf2LjhYktNATudLsI3ck3i4gYGtPbxzDqK+GSoS0Y lH9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=oIjrHB+2XA5y1cbE7i62fYAvZHdNUUI++6d8Tu5EOwY=; b=ddmtXNzuOXl8MyCadGuBUDzp8TaMHgV0k/FSIG18HvZExu4V8WKLUZSx9F8+vDF2ic U+pQGOU+Dh8Z4e1X8VurnRnRv8INvcO1xPmg6lF01LNKkCYa7yVA041a/Ys9cqT2Fixy HVzkVD3PdVIe1Ix497yIDDE6QuRMV5Wsmn6LS6eRugP1rkN8bY+bQTdyyU/QPN6WQkRM aAAxvglXYzqHTAMnZUBRA07hgK+bW8KTWoqSOoMEB2plzw74N4tlyN4taDjLhjZ8sxv2 VYIxfJ3s74+KOA2Rb+TDMqjLG6k1jCXrhT+hhhv/ZPQ+5cHcizg6jLaMordiNlmPK+nV tmPg== X-Gm-Message-State: AE9vXwNDpgPok5+sb2zt/elEJtNEdSdWlK9ns6w9xTO+BOGqq7bCm3IRG5bNTZQe2ORwTc8Kb2TqImw+3p+Ehw== X-Received: by 10.194.110.130 with SMTP id ia2mr32846636wjb.98.1474464675218; Wed, 21 Sep 2016 06:31:15 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.19.229 with HTTP; Wed, 21 Sep 2016 06:31:14 -0700 (PDT) Received: by 10.194.19.229 with HTTP; Wed, 21 Sep 2016 06:31:14 -0700 (PDT) In-Reply-To: References: Date: Wed, 21 Sep 2016 15:31:14 +0200 Message-ID: To: Niklas Keller Cc: Nicolas Grekas , Nikita Popov , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=089e010d89ea334a68053d048fae Subject: Re: [PHP-DEV] Fix ReflectionType::__toString() BC break From: ocramius@gmail.com (Marco Pivetta) --089e010d89ea334a68053d048fae Content-Type: text/plain; charset=UTF-8 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 > --089e010d89ea334a68053d048fae--