Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96070 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 65509 invoked from network); 21 Sep 2016 16:54:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Sep 2016 16:54:56 -0000 Authentication-Results: pb1.pair.com header.from=derokorian@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=derokorian@gmail.com; spf=pass; 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: derokorian@gmail.com X-Host-Fingerprint: 74.125.82.43 mail-wm0-f43.google.com Received: from [74.125.82.43] ([74.125.82.43:35395] helo=mail-wm0-f43.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E8/2A-04117-E5BB2E75 for ; Wed, 21 Sep 2016 12:54:55 -0400 Received: by mail-wm0-f43.google.com with SMTP id l132so279310480wmf.0 for ; Wed, 21 Sep 2016 09:54:54 -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=ufX8QKzJQEJXkK1BSDklAhcqSeIc8KrO2OZfX9X+4cA=; b=d6RbsX/pWRLbWOBlXFRTU+ehjlXGfTz2FRxLOM6REVJ7YemDLApXMJ1pTog2uYrgTR Oic5TdYoqlEQLePnEiqO5hIlld0Tl6vXiwZSenyyO4O0uS/dYi4wL620gTXc9+z0AhHn byG4hLHBo1RH0s0Iqyf7gGSzYrLShmhLTuxv64UxgEowEOXboo+eX7Rtfeu6F5e79pG0 PDHnX9jn3GyavU6pRMfYESJuCsdz0R1Uzcmy1nKnmMnN3QcQ146Sg7L+vli/RYcUEW6f K6IXMV5dc62fhGqWkeGScmx7D2uM4l3iYB+il/MfymOWliwe8ATvCG1U5i/Qz5XSi5xj 1FVA== 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=ufX8QKzJQEJXkK1BSDklAhcqSeIc8KrO2OZfX9X+4cA=; b=AU+xiE70ok7QfwxBxG0Gnjtab2T7G6Evlc3LANPBejKFbyGDUH0ER/diEYALzeS4Js 8uZo95sqXyQHlcAqS5dbiPp3UtSAp5flDdys0+B2cjMc6vLuozxR8YW0jAWYNWQnQhxj LsLKOfboJU+JWIm+lriGeDmV8afPkUYMG72aJkYTtMtMRp744oEu7rO3b6TFSCySRnEd WAYuZatfI7RO2bevVo4/DCllSOmPtx5Xml8qt0QmyYWmmUrqtMV0kdPrahr8i7fef+jv 4+ZTODrtk4KCQRbjxO8HvG1MS6DTInsyCQU2SXUhjvFe8z4KrloZc4gniyDxB+fYPkGE rCTg== X-Gm-Message-State: AE9vXwPr4wcadcjdnHrT0Olkz1Rt8lh0OCsfX8wDcvT5PcVNONnJPjju5yB09Dcflq4+6l4D5K1Rysp20TrYWA== X-Received: by 10.28.168.9 with SMTP id r9mr3946915wme.93.1474476891882; Wed, 21 Sep 2016 09:54:51 -0700 (PDT) MIME-Version: 1.0 Received: by 10.28.224.134 with HTTP; Wed, 21 Sep 2016 09:54:51 -0700 (PDT) In-Reply-To: References: Date: Wed, 21 Sep 2016 10:54:51 -0600 Message-ID: To: Nicolas Grekas Cc: Nikita Popov , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a114cbf145ed233053d0767f3 Subject: Re: [PHP-DEV] Fix ReflectionType::__toString() BC break From: derokorian@gmail.com (Ryan Pallas) --001a114cbf145ed233053d0767f3 Content-Type: text/plain; charset=UTF-8 On Wed, Sep 21, 2016 at 10:34 AM, Nicolas Grekas wrote: > > >> I'm not so sure its a BC though. Technically nullable types don't exist >> in 7.0 and as such would be impossible to return said question mark. Its >> only adding support for a new feature, not changing how an existing feature >> works IMO. If nullable types had been in 7.0 its highly probably, that >> __toString would have returned the leading question mark back then. >> > > Here is the BC break: https://3v4l.org/VUbIS > > As light as it looks to be, the output on PHP7.1RC2 is not the same as in > PHP7.0. > Yet, __toString() is the only public interface that is available on PHP > 7.0, > so people have already built things on top. > > I get that the output changed, but so did the type definition with the new feature. However, I feel this is a problem with the way types are inferred. To me Type $foo = null is an entirely different definition than ?Type $foo, but that's not how its implemented in the language. To me Type $foo = null should say "I have a parameter that is not required, but when its passed it needs to be an instance of Type", whereas ?Type $foo should say "I require this parameter, and it needs to be an instance of Type or null". If these definition were the result of those expressions, then we could have a third state, namely ?Type $foo = null which would say "I do not require this parameter, but when its passed it needs to be an instance of Type or null". I think the reason it works this way is, get this, for BC since previously Type $foo = null was the only way to make a parameter nullable, while having the intentional or unintentional side effect of making it optional (or the only way to make it optional, while having the side effect of making it nullable). However, given the current workings, Type $foo = null IS in fact nullable, therefore the string representation of that type is in fact ?Type. To handle this in code written around current __toString seems pretty simple: $type = method_exists($RefType, 'getName') ? $RefType->getName() : (string) $RefType; Given how simple that is, I'm not understanding what makes it such a big deal for you (or anyone else) either? > > Nicolas > p.s. to Nikita: my bad for the too short quote... > --001a114cbf145ed233053d0767f3--