If you really want to expose a symbol's FQN, I suggest exposing the
internal name as per `(array)` cast semantics.

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.

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.

On 11 Dec 2017 04:00, "Andreas Hennings" <andr...@dqxtech.net> wrote:

I propose a new method ::getFullName() for all methods that implement
\Reflector.
(I would add it to the \Reflector interface, but this would be a BC break.)

The full name would be, depending on the type:

function: "str_replace()", "Acme\foo()".
class: "Acme\Animal\Cat", "stdClass".
method: "Acme\Animal\Cat::meow()".
property: "Acme\Animal\Cat::$color".
etc.

I don't know if we can cover all reflection API classes in a meaningful way.
E.g. for ReflectionObject, the full name would be the same as for the
class, otherwise it would get complicated.

Currently the ::__toString() and ::export() return something else,
which is not really useful.

The goal is to have something that is different for different items.
E.g. a class and a function with the same name need to have a
different "full name", hence the added "()" for functions and methods.

As a rule of thumb, the "full name" is what one would put after a @see
tag in phpDoc, but without the leading "\\".
For consistency with the rest of PHP and reflection API, we should use
QN and not FQN as return value.


Related: I started another thread proposing a ::getHash() method.
I originally though to propose the two things in the same thread, but
I now think they should be discussed independently.

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to