Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101317 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 39420 invoked from network); 11 Dec 2017 09:16:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Dec 2017 09:16: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 209.85.128.180 as permitted sender) X-PHP-List-Original-Sender: ocramius@gmail.com X-Host-Fingerprint: 209.85.128.180 mail-wr0-f180.google.com Received: from [209.85.128.180] ([209.85.128.180:35835] helo=mail-wr0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A5/BA-53433-DFC4E2A5 for ; Mon, 11 Dec 2017 04:16:46 -0500 Received: by mail-wr0-f180.google.com with SMTP id g53so16745464wra.2 for ; Mon, 11 Dec 2017 01:16:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=NXzOOPl9s+r2DiPjHh75mZEVkIiftm/+rKwjfETOV+E=; b=AUITcmjTn08ecQ6/Q7ibNGKAS5lADWXn/v85DZkcD8iXp/tLOJhO7wM89lyy6x2ZCW 0o3XEt4pFpqZq1lf6aHXAZXQygMWOxTpz/I6DCWZUs0WQtnmfzsUl+YizyYyacEbdQkq Ieh5eA4lcj14c5RNFGJ37PChYuEfRUGk0X6Noe+R15paKL8cznrMnmWX0p5vZZuoOz6n E76JfEx4mdM6kGuH5yZid8q+YdozWi65k+It9qkhCwDtlajithY4S0qNIaSvilXOS9tY Bl12Zi7jnjAaLneqBZ41H2h/0m1F74wSCwtCQg4I82cNZOvtVsE6dRrZqz9TB6msT0Ig FvlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=NXzOOPl9s+r2DiPjHh75mZEVkIiftm/+rKwjfETOV+E=; b=n/QMfYb6+9f4xhHt///AUBM0f+dDN8hXa6WkyOUhRJS97pWAXLuI57hxzfRP1WU3yu 41CbFvR4By5GYksGgvdKLmwQMZiyubvG/TkyZ7A8NAt9WaDiLSGlUf1Hx6SR/t6MeuW5 TlyzytYmbruNZo/w5zsSBWKPAUn1aNyzt3JuhlCIhng+kj/j6nqr1AbhiIAZAqFlMnJA kMwbjARs8zFv83K688ww1Tj1f8A1N7qnz3R04GbvCukImI3qb1wsS5+C4D3fa6BhYyUq HmaaK3Z163RIJZTVIm8VQvySlPdec+PUjyl4qTdhd5D8tJtyY4zlCjzBCxf9a+WLzUJn UddQ== X-Gm-Message-State: AJaThX5BI0fgbGj4gfVW8QsYboNVsBxdAsbW12pr+9/MMXizObmp63Nu vOCEpWUGUw6dFUypoVpIMi57czyTUJRaKqzs0ZfKeoOA X-Google-Smtp-Source: AGs4zMY8A7jTOfmwH7rOxHnARpSSsQyrKrRD/L84W65lvPXIQIom0nbe8W2mh8jScxaYQOvWGWtmiRMNIeR5Q7qbrm8= X-Received: by 10.223.176.121 with SMTP id g54mr36338801wra.165.1512983803025; Mon, 11 Dec 2017 01:16:43 -0800 (PST) MIME-Version: 1.0 Received: by 10.223.184.205 with HTTP; Mon, 11 Dec 2017 01:16:22 -0800 (PST) In-Reply-To: References: Date: Mon, 11 Dec 2017 10:16:22 +0100 Message-ID: To: Andreas Hennings Cc: PHP Internals List Content-Type: multipart/alternative; boundary="001a11498112215da105600cfe9a" Subject: Re: [PHP-DEV] Reflection API: Add ::getFullName() method. From: ocramius@gmail.com (Marco Pivetta) --001a11498112215da105600cfe9a Content-Type: text/plain; charset="UTF-8" On Mon, Dec 11, 2017 at 10:03 AM, Andreas Hennings wrote: > On 11 December 2017 at 09:16, Marco Pivetta wrote: > > If you really want to expose a symbol's FQN, > > Just to clarify: For me, "FQN" means "fully-qualified name", which > begins with "\\". > This is specifically not what I propose here. I want the name without > the leading namespace separator. > So maybe "getFullName()" is misleading. > A FQN does not start with `\`. In strings, you always use the FQN > > > I suggest exposing the internal > > name as per `(array)` cast semantics. > > This distinction is not needed here. > The semantics for array keys in array-to-object casting are to > distinguish overshadowed private properties from parent classes. > This is because values for these properties can coexist within one object. > > E.g. > > class B { > private $x = 'b'; > } > > class C extends B { > private $x = 'c'; > } > > var_export((array)(new C)); > > > Output: https://3v4l.org/0QE3s > > array ( > '' . "\0" . 'C' . "\0" . 'x' => 'c', > '' . "\0" . 'B' . "\0" . 'x' => 'b', > ) > > > For ReflectionClass->getProperties() and ->getProperty($name) only > gives us the version of each property that is visible on the top > level. > > https://3v4l.org/LWWSf > > E.g. > > $obj = new > > (new \ReflectionClass(C::class)->getProperty('x') > That still makes merging property definitions extremely messy - as a heavy reflection user, I don't see the value in such an API then, besides display (var_dump()) purposes... > > > namespace A { > > class B { > > public $c; > > private $d; > > private $e; > > } > > } > > > > That would be: > > > > "A\B#\$c" > > "A\B#\0*\0\$d" > > "A\B#\0A\\B\0\$e" > > > > Obviously, the `\0` is horrible and can probably be improved: depends on > > whether the API is intended for human or machine consumption. If it is > > machine consumption, strings are the wrong approach anyway. > > Machine or human? > One goal is that these names can be used as array keys or unique > identifiers whenever we deal with a collection of reflectors of mixed > type. > At the same time, the name is designed to be very close to what is > printed in exception messages, @see doc comment, etc. > In this case, I don't see a conflict between human-readable and > machine-readable. > > Maybe when you say "machine consumption" you are thinking of something > else? > Machine consumption would be VOs, not strings ;-) > > > I'd also add that this would be (fucking finally!) a good way to fix > PHP's > > documentation horrible usage of `::` for both instance and static > members. > > Ok, tbh, so far I thought of using the same "::" for both :) > So for all properties it would be Cat::$color. > > Maybe instead we could do Cat->color for instance members? > I have been using `#` for a while, but I can adapt as long as the problem is being fixed at some point in time :P Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ --001a11498112215da105600cfe9a--