Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:95270 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 19801 invoked from network); 17 Aug 2016 17:25:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Aug 2016 17:25:50 -0000 Authentication-Results: pb1.pair.com header.from=ocramius@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ocramius@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: ocramius@gmail.com X-Host-Fingerprint: 74.125.82.43 mail-wm0-f43.google.com Received: from [74.125.82.43] ([74.125.82.43:33051] helo=mail-wm0-f43.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7D/1C-45465-C1E94B75 for ; Wed, 17 Aug 2016 13:25:48 -0400 Received: by mail-wm0-f43.google.com with SMTP id d196so38763557wmd.0 for ; Wed, 17 Aug 2016 10:25:48 -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=y7TKZ7qA2rPfjpFOC9xZOtLl63ypw1TCQvOGQJXRTtU=; b=tjcyXOZ/OZMDIBIDLALpf3W9B+Ehgup5seKwsSk44dfzQPOh6bI66sMXRL3WA3FcMG 6KHB6NB/YL1RvFwBOZeRFa7cWvL36nF6hETtIKCJpHF/wI9X9aIB2kAIhZlB4Rjg97UG 9Pxnb6hshJlGp0AqfI/YGMAAyeu1S19BNHmsuV/FLaDaBHjZPqEbCCRkvFbA0yvwEUbt ewHfSUv/L3HfcXQ+FZD4TxvjtoIxsMk2pq4DOFDlT1mXe+3TTRA6LxNJackcWqJuyEow vft38JwkIXPtILSP7gVs66SYb6UOMcEydAvCiVi0WLlCyYpY0wTTvqaMn5Do3tLx1BOU irAg== 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=y7TKZ7qA2rPfjpFOC9xZOtLl63ypw1TCQvOGQJXRTtU=; b=aEvoaPimZaaBzsqcD6qaBXLuyoQo0zrxsDhsCx8FaTHaUt+qgsycw+oFu46Auhsizh tB7/eHh3yMxeLUVyDKORWsJi3Ju1zXNYGQNfuStwCJGWcLvF631c46rFvVMoEQeqQTgq aSlMywltFB0h0uXhy3142JWHX8KNpm22NSLNUdWczFh3ehFJJhVUhgdC+txEMJo1HR66 pZvlxw22rxaekbu7+PTDq8xKFeoKKI6qzM8U4qJ4Sd0fJ68ZbBaQFgRTom+VGxxOhP5W H1aZenY7R7DmBzEgxWfslkC/omhjqPqrICPgkH4lR+SlRgOVfbutLf22Qonku7wDDcqn VQPQ== X-Gm-Message-State: AEkoousIlTVAx0kWeMPbwGxBTzed5FycOrHNmtgYjOTaKJsMGX4F568e4U/BJ5u9kVUN27yNhsjAskexxxdcvg== X-Received: by 10.194.149.113 with SMTP id tz17mr49345302wjb.64.1471454744963; Wed, 17 Aug 2016 10:25:44 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.125.242 with HTTP; Wed, 17 Aug 2016 10:25:24 -0700 (PDT) In-Reply-To: References: <0668D584-EE51-4932-85D7-01D8BF70E409@trowski.com> <15E198DD-FF66-475D-ABBC-54ECD2B6BF62@trowski.com> Date: Wed, 17 Aug 2016 19:25:24 +0200 Message-ID: To: Aaron Piotrowski Cc: internals Content-Type: multipart/alternative; boundary=089e01160dfa607211053a47c148 Subject: Re: [PHP-DEV] ReflectionType::__toString() prepending \ to class names From: ocramius@gmail.com (Marco Pivetta) --089e01160dfa607211053a47c148 Content-Type: text/plain; charset=UTF-8 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/ --089e01160dfa607211053a47c148--