Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:95320 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 44727 invoked from network); 19 Aug 2016 17:16:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Aug 2016 17:16:29 -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 74.125.82.53 as permitted sender) X-PHP-List-Original-Sender: ocramius@gmail.com X-Host-Fingerprint: 74.125.82.53 mail-wm0-f53.google.com Received: from [74.125.82.53] ([74.125.82.53:38615] helo=mail-wm0-f53.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 07/E3-17996-BEE37B75 for ; Fri, 19 Aug 2016 13:16:27 -0400 Received: by mail-wm0-f53.google.com with SMTP id o80so50574241wme.1 for ; Fri, 19 Aug 2016 10:16:27 -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=pZkRogWKhqE2ODr2+ZKPlFdKqO6p4JcNmdJefEmSkLo=; b=a5gpaqtZ9sOJcA1GelaaMoITX5/nZ611aNoxUWkYzPMkPUSiemSwpCJvMuOMLPKoRO kWIe191+PVVL++U25OJYHtVG+QY3ObXdyH7Qks4ixIg1Anbebg3I9dod+5RsH7gcWe8t GADJ0z0pTZr8ioNOXIveKkWV1iR5kAJL4SiTuMfduvqZLVcs4E67VMflVaU7UraW9LLH vGydqdZ34hXRgCkDmdqq7iOB0SiCZKLTecnhfw0V58vIAbgVLxzhFDwJjfZ2cRz6Y7WZ swSgY12WO9Ro2j8GlKCLRZEPrWEy2UvhvEOinzNClMJvtcZb23hZ0DWMzEWXuuJ9TQbp Cp4Q== 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=pZkRogWKhqE2ODr2+ZKPlFdKqO6p4JcNmdJefEmSkLo=; b=l7MB4KP+LUj3G5ZuwS1DlIQ/SMQeUwLuuKn7aX/Wzyrv5b8Qj0UGdV4uwZ4cYo8SmM vquyx6Qr8e+2m0Gs/w89HD5FQoq8GOSyt7UrJuSQ9F53g/ZMrMiI0AOIpF2z9h45/T2V ZWXOA4NchPXiAq/TJ+LuKzgMzZMQWC0p30NLbuMORbf4ptNmaitL8gneo42nT1Odfsem 0jAz+SeKxjM15QA/inO7Hr4O15+NJwXsJhzArvKEv8PJh3XzsYjWZFGzf3arUYYoGwKm Q8cfTALXC7c3Ns55mSB/tpI+rzuFXTBqO20ZSMZl1N/g9NYI7oh2SiDAAq/mUaasAAOW FlcA== X-Gm-Message-State: AEkoouttD4hlGqp7h72XfGEhri4nxu5OZX809kHYgb1ndnI1CWDglhN2y/fbfM5UQL9ztpAVKoI4r4smLV0QAw== X-Received: by 10.194.190.232 with SMTP id gt8mr7809716wjc.141.1471626984032; Fri, 19 Aug 2016 10:16:24 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.125.242 with HTTP; Fri, 19 Aug 2016 10:16:03 -0700 (PDT) In-Reply-To: References: <0668D584-EE51-4932-85D7-01D8BF70E409@trowski.com> <15E198DD-FF66-475D-ABBC-54ECD2B6BF62@trowski.com> Date: Fri, 19 Aug 2016 19:16:03 +0200 Message-ID: To: Aaron Piotrowski Cc: internals Content-Type: multipart/alternative; boundary=047d7b87465ea01522053a6fdb5d Subject: Re: [PHP-DEV] ReflectionType::__toString() prepending \ to class names From: ocramius@gmail.com (Marco Pivetta) --047d7b87465ea01522053a6fdb5d Content-Type: text/plain; charset=UTF-8 Hey Aaron, I am currently going through the changes, and just figured that 7.1 implements https://wiki.php.net/rfc/reflectiontypeimprovements, even though the RFC was declined: ./sapi/cli/php -r 'class Foo { public function bar() : ?Foo {} } var_dump((new ReflectionMethod("Foo", "bar"))->getReturnType());' object(ReflectionNamedType)#2 (0) { } Was there a newer RFC that I missed? Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ On Wed, Aug 17, 2016 at 7:25 PM, Marco Pivetta wrote: > On Wed, Aug 17, 2016 at 7:17 PM, Aaron Piotrowski > wrote: > >> >> > On Aug 17, 2016, at 12:02 PM, Marco Pivetta wrote: >> > >> > That would have been a headache anyway. We saw it coming, and it will >> be fixed on our end, but please don't try to outsmart it. >> > I know that there is good intention on your side, but this is really >> going to just make it an issue. >> >> Looks like this problem is more complicated than I thought. I thought >> prepending the \ would mean little work on your end, but it appears I was >> wrong. >> >> I'm still confused as to what's going on and what the best solution is... >> Currently Doctrine is manually prepending \ to class names. Obviously your >> logic would have to change between 7.0 and 7.1, but then going forward you >> could rely on ReflectionType::__toString() to return a syntax-valid type >> name, rather than modifying it. Or perhaps rather than relying on casting >> to a string and examining the string, Doctrine should be using >> ReflectionNamedType::getName() and ReflectionType::allowsNull() for 7.1 and >> beyond. (Just a suggestion, I'd have to dig into the code to really >> understand what's going on, and I don't have a ton of time to do so at the >> moment.) >> > > The problem is that we're not talking about 1 library, but a few (and I'm > only talking about the ones I know of). > Changing behavior is going to cause issues. > > >> > From the codegen-side (I do write a lot of code generators), having `\` >> prepended in front of stuff makes things just more complex to deal with, >> since I have to strip it and re-introduce it anyway in multiple locations >> in the code, while it should just be attached in the final output-logic bit. >> > Instead, please keep the reflector on-spot: reflecting things, telling >> us what they are. What the code generator does with the definitions is up >> to the code generator after that. >> > >> > We have to adjust the code for `void` and `?` anyway, so this is just >> more changes to keep track of, and it would break existing code. >> >> It sounds like you'd prefer the ? was not prepended to the string as >> well, is that correct? Again it sounds like it would be better to use >> methods other than __toString(). I understand __toString() was the only way >> to get the type name before, but now that this has been fixed perhaps it >> should be avoided in your use-cases. > > > I think that adding the `?` would be semantically correct, from a > reflector perspective (remember, we are only reflecting: please completely > ignore the idea of using this for codegen, it is a separate domain). > > I can't tell you for sure right now, but I will check on Friday. > > Libraries that directly affect me personally are doctrine/common, > zendframework/zend-code and ocramius/proxy-manager, so I am only talking > about these 3 for now. > If I remember correctly, in all three a `(string)` cast is being used for > discovering scalar types, although I am not sure. > > Can you please poke me at EOD on Friday, so maybe we look at this together? > > Cheers, > > Marco Pivetta > > http://twitter.com/Ocramius > > http://ocramius.github.com/ > > --047d7b87465ea01522053a6fdb5d--