Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96057 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 40643 invoked from network); 21 Sep 2016 13:33:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Sep 2016 13:33:21 -0000 Authentication-Results: pb1.pair.com smtp.mail=julienpauli@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=julienpauli@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.43 as permitted sender) X-PHP-List-Original-Sender: julienpauli@gmail.com X-Host-Fingerprint: 74.125.82.43 mail-wm0-f43.google.com Received: from [74.125.82.43] ([74.125.82.43:38524] helo=mail-wm0-f43.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 17/85-04117-12C82E75 for ; Wed, 21 Sep 2016 09:33:21 -0400 Received: by mail-wm0-f43.google.com with SMTP id l132so92034607wmf.1 for ; Wed, 21 Sep 2016 06:33:21 -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=3r9kW+yQZ5g9G6QZxP7FqZpEo65ZYbAWZtS/Ey+TcDA=; b=VXocpdOBr6HjHC/FPS/zVQKumuAe5Hvv5grOYQiQ6kXj8bl1iZhn1W8LE5V2RXN0OF pccagJz5KSp1X/Ocn/mJN2XfHM20KmTUXxiNgSdY07wrR0cb6OTRIA9PtCboqPXm9OfQ PiQYllCpsTHTyq2n7N3FvUx0N9jNqCcE8+rsPTC1cswN4a4Xv7R6BvaElaHiB01N3y4/ ZqeUGIrsG0UzTT2fHAas4cUg7VAl9FrY5Uz8V3xNyNbEd1N+nubVVd9RWXNR6RvxjDnd pZU2ERTeTlObDr815fAK+KbU8zv4razyGTgG2AoiPAQv7G4GzFek90u7LHXSLTb89jD6 AAEw== 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=3r9kW+yQZ5g9G6QZxP7FqZpEo65ZYbAWZtS/Ey+TcDA=; b=YICaK79j7PzNpDljEWHbKhxtd6EsFqcIyllw7TJdVVmK+lBX2TcKATHdd4+8zCru9i 2nSvYEx1vlmrUsdKj4pTHoP+CORNaqM4xa7MFdRZEmnXzxy7ER1Z5wGhfAR8NgxMxzPF wVjwP0r73Ynl+dNbua5BoMAJmWlV0F7X2Qrvdw0FtZ3VK8BcqAbrb8cLJ0Qb0OKfAnOo ceRfg0erh+yR7FeX3kSHE/Vf2SL9MRZygXXJ62gVSsBzwoyj1Uw2qM2S1RhCFLnSHc69 H6vXQRMnR3slAeOMNPgwJsBDSfmWU7P+J6oRxT1XrSLnfsPQ5yc0y5BpOKdiar6My2np SOpA== X-Gm-Message-State: AE9vXwPSQWvk3m2uB7C7w6qjwMT4uM+Fqw8APiyj+0pdqb0GliLgt3JGuWbBiGGRxD7Ud5BCScEJdwao4oUgBQ== X-Received: by 10.28.10.138 with SMTP id 132mr3518283wmk.1.1474464798581; Wed, 21 Sep 2016 06:33:18 -0700 (PDT) MIME-Version: 1.0 Sender: julienpauli@gmail.com Received: by 10.194.45.4 with HTTP; Wed, 21 Sep 2016 06:32:38 -0700 (PDT) In-Reply-To: References: Date: Wed, 21 Sep 2016 15:32:38 +0200 X-Google-Sender-Auth: nXIoTLdfiRcLYE0d2lbNsoaP6uA Message-ID: To: Nikita Popov Cc: Nicolas Grekas , "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Fix ReflectionType::__toString() BC break From: jpauli@php.net (Julien Pauli) On Wed, Sep 21, 2016 at 3:14 PM, Nikita Popov wrote: > 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 People used __toString() because there was no other way to "get the name" of the param. But __toString() should give a "string representation of the objects it is affected to". The fact that in 7.0 it returned the exact name of the param, was a coincidence. Now, in 7.1 , we changed it to represent the param more accurately, including the nullable fact, thus adding a '?' to the type ; BUT we also added a way to get the name of the param (like you expect it) : the getName() method. So now, in 7.1 , one who used __toString() should now use getName(). And __toString() changed in 7.1 , breaking BC yes. Should the break stay ? It is RM to decide. But, if we must wait for PHP 8 to be able to change so little things, then we perhaps need to change our release management to have one major per year ? I mean, we need to change things, we need to evoluate , and that can't be done without breaking BC in some parts. That is all the challenge behind BC breaks .... RM thoughts ? Julien.Pauli