Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101316 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37775 invoked from network); 11 Dec 2017 09:04:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Dec 2017 09:04:09 -0000 Authentication-Results: pb1.pair.com smtp.mail=andreas@dqxtech.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=andreas@dqxtech.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain dqxtech.net from 209.85.215.48 cause and error) X-PHP-List-Original-Sender: andreas@dqxtech.net X-Host-Fingerprint: 209.85.215.48 mail-lf0-f48.google.com Received: from [209.85.215.48] ([209.85.215.48:43275] helo=mail-lf0-f48.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C3/6A-53433-80A4E2A5 for ; Mon, 11 Dec 2017 04:04:09 -0500 Received: by mail-lf0-f48.google.com with SMTP id 94so18268487lfy.10 for ; Mon, 11 Dec 2017 01:04:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dqxtech-net.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=qMgjVfMfkrmquNKe7Ki+waMPxIu5YX9JHgMWG2GHSsM=; b=i/m3p61XBW+/6ptIUwFt3yyzyzdRmuHAE374scJme+rJRXsHgSAkzoQSpFGbom2d2j MDqmZDy/dl/BSen9jGq7OHTf7pHaqjQaibo+lc6roPXtpBSe+4NeisvLl5LsxJuOKWMF 6dbsJbhnqNBYrn036RZXPzjqZQwWeG40t1rbi3QcUWXupYRgsVJvXirwv10y/9smoARf H/Rx2qSE4Upw+Kdqaafb9YU32dWxwU3lccZxg9k5Vt+B4MjMSjQg3TeZ76SjUu91JL7B yeT4h3KYKVABpmFkruLvEIcIngfoLm4YfhpuQ0HP4fw95/RmkVGM+qH+fOVzRfCa2xqn /onw== 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=qMgjVfMfkrmquNKe7Ki+waMPxIu5YX9JHgMWG2GHSsM=; b=Njn3PHjRpLgZBSspG4oamRcdHrvjmL06cpwaS4/tj9t01vOd5p8dFoqdIYo2Fl0N1i 6KnVj2IQTCWOQjed2dOKDOUZHcA46N5lspKfbe2pUcNhN3JwdNmQrdnkKoxDuQE7zcNp IJBMs9Ron9ERf0cJ7pFX07WPUl0sMsNNbe363kvZWDJlThA7YvuKFo0sqpeVnKpmV0Xc 6v0Albpe3AKvGqXWolVGf7hEWU5lYQgFK36Y+5TPe/Nd7I0Et7WOZ4A0etTByJUbm9B1 CyM0KfsS+0rF6xjI+GITsSBfEUcJngQvarE211ETfJmYBEWA8cmpMFM53ALXNgzPrOaQ KU2Q== X-Gm-Message-State: AJaThX6acuvMAxODTQ1vFQ845Um3yKsUm+v8DmJGBACr00f1bleC3IzB P75A31sdZsNNTGaNjyWzpKLO4+aU X-Google-Smtp-Source: AGs4zMbG/RNNUrr6lAxiqtAC2yMZmbHAHIshz1D/+imYbJSqi8WSznH36064AhWdR/49kC0OzjO9yQ== X-Received: by 10.25.141.74 with SMTP id p71mr16614628lfd.10.1512983043791; Mon, 11 Dec 2017 01:04:03 -0800 (PST) Received: from mail-lf0-f48.google.com (mail-lf0-f48.google.com. [209.85.215.48]) by smtp.googlemail.com with ESMTPSA id h91sm2638683lfi.7.2017.12.11.01.04.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Dec 2017 01:04:03 -0800 (PST) Received: by mail-lf0-f48.google.com with SMTP id x20so18320420lff.1 for ; Mon, 11 Dec 2017 01:04:02 -0800 (PST) X-Received: by 10.46.20.83 with SMTP id 19mr20433678lju.23.1512983041542; Mon, 11 Dec 2017 01:04:01 -0800 (PST) MIME-Version: 1.0 Received: by 10.25.170.16 with HTTP; Mon, 11 Dec 2017 01:03:40 -0800 (PST) In-Reply-To: References: Date: Mon, 11 Dec 2017 10:03:40 +0100 X-Gmail-Original-Message-ID: Message-ID: To: Marco Pivetta Cc: PHP Internals List Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] Reflection API: Add ::getFullName() method. From: andreas@dqxtech.net (Andreas Hennings) 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. > 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') > > 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? > > 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?