Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96055 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37719 invoked from network); 21 Sep 2016 13:27:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Sep 2016 13:27:34 -0000 Authentication-Results: pb1.pair.com smtp.mail=me@kelunik.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=me@kelunik.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain kelunik.com from 81.169.146.163 cause and error) X-PHP-List-Original-Sender: me@kelunik.com X-Host-Fingerprint: 81.169.146.163 mo4-p00-ob.smtp.rzone.de Received: from [81.169.146.163] ([81.169.146.163:18156] helo=mo4-p00-ob.smtp.rzone.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2F/D4-04117-5CA82E75 for ; Wed, 21 Sep 2016 09:27:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1474464450; l=4726; s=domk; d=kelunik.com; h=Content-Type:Cc:To:Subject:Date:From:References:In-Reply-To: MIME-Version; bh=c24hnTM4aJr3UdBrB09cwSTiqYY4Iji7mwrlFe0eMmQ=; b=bjHM4j9/qJjH9bFvhRqZ/jEeyvH02ll4veFU5/186xh5bDZeBcihrzoxV5tMbKhOjCw V9aF708APTi9g8ZKSapoOtZ2jYBmtMxPLm+RaCRxRMANakQabRbpmupRfBLv705lHyEKp KAytGhIP9czaYTzORUDMpIzamXN0U8DsV2Q= X-RZG-AUTH: :IWkkfkWkbvHsXQGmRYmUo9mls2vWuiu+7SLGvomb4bl9EfHtO3c6 X-RZG-CLASS-ID: mo00 Received: from mail-wm0-f44.google.com ([74.125.82.44]) by smtp.strato.de (RZmta 39.2 AUTH) with ESMTPSA id j07ec3s8LDRUZUT (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp384r1 with 384 ECDH bits, eq. 7680 bits RSA)) (Client did not present a certificate) for ; Wed, 21 Sep 2016 15:27:30 +0200 (CEST) Received: by mail-wm0-f44.google.com with SMTP id l132so91752897wmf.1 for ; Wed, 21 Sep 2016 06:27:30 -0700 (PDT) X-Gm-Message-State: AE9vXwNhdmL8MfTyjwLHBRPEHSlXGpdoDJoXz3FvErpsxlSqL4k7X2BIP1KZUFlIEZT8q6KGzcdt3A8GRJWHEg== X-Received: by 10.28.45.14 with SMTP id t14mr3057768wmt.20.1474464450365; Wed, 21 Sep 2016 06:27:30 -0700 (PDT) MIME-Version: 1.0 Received: by 10.28.125.132 with HTTP; Wed, 21 Sep 2016 06:27:29 -0700 (PDT) In-Reply-To: References: Date: Wed, 21 Sep 2016 15:27:29 +0200 X-Gmail-Original-Message-ID: Message-ID: To: Nikita Popov Cc: Nicolas Grekas , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a11423646ccc2d2053d04814f Subject: Re: [PHP-DEV] Fix ReflectionType::__toString() BC break From: me@kelunik.com (Niklas Keller) --001a11423646ccc2d2053d04814f Content-Type: text/plain; charset=UTF-8 2016-09-21 15:14 GMT+02:00 Nikita Popov : > On Wed, Sep 21, 2016 at 10:55 AM, Nicolas Grekas > > 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 --001a11423646ccc2d2053d04814f--