Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96052 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 33202 invoked from network); 21 Sep 2016 13:14:51 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Sep 2016 13:14:51 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.169 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.213.169 mail-yb0-f169.google.com Received: from [209.85.213.169] ([209.85.213.169:36268] helo=mail-yb0-f169.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 12/E3-04117-AC782E75 for ; Wed, 21 Sep 2016 09:14:50 -0400 Received: by mail-yb0-f169.google.com with SMTP id u125so30133892ybg.3 for ; Wed, 21 Sep 2016 06:14:50 -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=tMHo3H9EBUbG34ZYwFMzzh2uNmrB+Qf7/3NLqbdMUMc=; b=mJfcvjMBeJ7WMJHfVDb/8fvttYBINnkjymNmO30AyQjeYmp844zCY9g9kbBeqZ3w1y YHDUjEaWvJRChYCJa5mTvw8kVF4aQPyXnaW1MZSUwzxwL4dCu+oawtl/lGVtNDurIByF PuPkGu8bgNk79IuGQam6XqXLIQ/M38I9pMhxiSIVUBWiql82Oi7o/RH8m1ovTZpTYv4m q7cnyMK7PhYHmuRz9w5g4LIGoi+9hLIpF0HQWLREzl1rH5BMegVljPT+Z4IhqHYgEKTD tw08zTSn9TsN19Stc31LKrmnFDI7B0It0mGfeMCdaMOazgxFgOEOL4evL7rtz6BcCSM0 mXPw== 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=tMHo3H9EBUbG34ZYwFMzzh2uNmrB+Qf7/3NLqbdMUMc=; b=WJKy5cW7e16Z6JjmHSMK4dj013brHGZJwSJ8OwpsXpO15aGGGIiTvaVNDoI/JfUWtL rQm779HEPwwcxtgjq4lb1tGjbL3JrDzBJOnCWkmPDqzNqZft2puvB8ye6/0tTC8INw9l DI4ACwFCxYq6ZFHzAqyhtHOOGU9uMLxTfnYuI00QbazzVcqqbaBkqQznlFV7tEYtgr8q 8GIYUkjfkYb1zTTIgXqhtDnLP8UmrKBB1lxd1KjVzbil/U5C7kFTLbcQOQtKG4i4pr+k h18guc3c48YUDW8FlpaTgL1QtKdutnwiFH7URkRSDxCMSmO3Psc9CMjAuGpCyZ49mO3i 40bA== X-Gm-Message-State: AE9vXwNTSCNY3+JV3ONSFBfWvY/dO4SGNW7hS39WXDtNnSPkIqnRvvuEutjHJWFXN8shMuYtAYAzHXr18267EQ== X-Received: by 10.37.40.5 with SMTP id o5mr34604917ybo.140.1474463687797; Wed, 21 Sep 2016 06:14:47 -0700 (PDT) MIME-Version: 1.0 Received: by 10.13.215.150 with HTTP; Wed, 21 Sep 2016 06:14:47 -0700 (PDT) In-Reply-To: References: Date: Wed, 21 Sep 2016 15:14:47 +0200 Message-ID: To: Nicolas Grekas Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=94eb2c14e262587140053d045459 Subject: Re: [PHP-DEV] Fix ReflectionType::__toString() BC break From: nikita.ppv@gmail.com (Nikita Popov) --94eb2c14e262587140053d045459 Content-Type: text/plain; charset=UTF-8 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 --94eb2c14e262587140053d045459--