Re: [RFC][Vote] ReflectionType Improvements

From: Date: Wed, 06 Jul 2016 09:23:11 +0000
Subject: Re: [RFC][Vote] ReflectionType Improvements
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-94400@lists.php.net to get a copy of this message
On 05/07/2016 22:06, Levi Morrison wrote:
Compare that to using only if-else for control flow:
    if ($type->isBuiltin()) {
        handle_builtin();
    } else if ($type instanceof ReflectionClassType) {
        handle_class($type);
    } else {
        handle_undefined($type);
    }
I'd much prefer the latter.
Yeah, I agree the control flow looks more natural with an elseif there. But that fits fine with my other suggestion:
    if ($type->isBuiltin()) {
        handle_builtin();
    } else if ( object_type_exists($type->getName()) ) {
        handle_class($type);
    } else {
        handle_undefined($type);
    }
As I say, if you dislike the verbosity and future-proofing of "class_exists() || interface_exists()", then that's not uniqe to this situation, but a general lack in the language. Why add methods or whole types to this one area of reflection rather than providing a more basic building block?
It would have been great if people actually contributed to the discussion before voting phase, but such is life.
Yes, for my part, I apologise that I didn't pay any attention to this RFC previously, and just happened upon this sub-thread. I can understand your frustration at this all coming so late. Regards, -- Rowan Collins [IMSoP]

« previous php.internals (#94400) next »