Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94386 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 10720 invoked from network); 5 Jul 2016 14:30:27 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Jul 2016 14:30:27 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.49 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.49 mail-wm0-f49.google.com Received: from [74.125.82.49] ([74.125.82.49:35105] helo=mail-wm0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FA/84-14106-184CB775 for ; Tue, 05 Jul 2016 10:30:27 -0400 Received: by mail-wm0-f49.google.com with SMTP id z126so77973055wme.0 for ; Tue, 05 Jul 2016 07:30:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=3Zm4MhuzFisdRDZ4hNBFWm0f2mw99IIN+K+uFuOYw4g=; b=QSd7RizEXuwXO4zhZbcEAhF97VCu8NSjjPo2WsRP63d0eh/w6SpEZoreRvk8XYIDUW TE271Zlh0i5Pr2pIuVKTGYa2KxSH9bWHxp7JS+bvVmYeksyUxns2wKCim8DhPkB+UNxl F1L6tefXRryGvojwZXxwiO1oHj7HXww+FCmnSPsaI9Cf0KC9kKL/7QunMrg6KL5ipj9r ctQWJC8nUI7QNg5DIPIFKytIDu/ctB8GDZN/bP3/P/W1N4kQ34GPVXjDpwzXbwZJHVmV OMqKkbILW1oAlstIK+Xz5VQWRcNa8nzoGtYXQLjmY35t07XWiNh5jn6cJlFxKaTk/AUB f5ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=3Zm4MhuzFisdRDZ4hNBFWm0f2mw99IIN+K+uFuOYw4g=; b=Z8Te1pM7jVcE/mujTxVPrBVPkZ/Tk6Yt0i1jvOM+1fKyWak1n93j0Juljplb6NrHgB vV7JoZHQFJNkew9OUqHrpZuTB2PpkBf43oM8s7fWWJgIep+nQy4iCHrDR/ens9kkQdFB nTIugBdJsuICSxMBHmFPYuY2fViea+g9VA2LYsbprTq7nEghyMNRUqWX7dA2LjfT8KuZ FoeyfvR6fzsw1PD++7oNxL0bR5+3DS/jf03sP1bCiX2rJ7ecIwH9JC9DpVI+UeLM88l7 aaXtl1xGR8V9Fkl4yJ1X39rfDh4hxwpRBApVUZIiKbeo4PfHE8VPp5i5bahpsClPwqeS 7J0A== X-Gm-Message-State: ALyK8tJSGOJLVWdupXRS8+TKy+gbsCCOAKda42R4oK3wMHpUpj2oaCSsWoiBv7jveHoRTQ== X-Received: by 10.28.154.214 with SMTP id c205mr16896113wme.9.1467729022067; Tue, 05 Jul 2016 07:30:22 -0700 (PDT) Received: from [192.168.0.98] ([93.188.182.58]) by smtp.gmail.com with ESMTPSA id 12sm250140wmj.19.2016.07.05.07.30.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jul 2016 07:30:21 -0700 (PDT) To: internals@lists.php.net References: <1f39f97a-6aaf-8550-9f82-a7e80465f903@telia.com> Message-ID: Date: Tue, 5 Jul 2016 15:28:08 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC][Vote] ReflectionType Improvements From: rowan.collins@gmail.com (Rowan Collins) On 05/07/2016 14:21, Levi Morrison wrote: > if ($type instanceof ReflectionClassType) { > $r = $type->getClass(); > } > The (currently) correct code would be: > > if (class_exists($type->getName()) || interface_exists($type->getName())) { > $r = new ReflectionClass($type->getName()); > } This seems to be combining two checks into one: - is this a "simple / builtin type" or a "class / interface type"? - is the class / interface referenced currently defined or autoloadable? The first question can be answered with the existing ReflectionType::isBuiltin() method. The fact that the second is currently difficult to answer doesn't seem to have anything to do with reflecting type hints. It seems like if there was a use case for "is this type hint a currently defined or autoloadable class / interface?" it would ideally be written something like this: if ( ! $type->isBuiltin() && object_type_exists($type->getName()) ) The term "object type" being bikesheddable as a way of encompassing your hypothetical enums or other future "class-like" types. Of course, the fact that "class_exists" and "ReflectionClass" use different definitions of "class" already is somewhat awkward... Or if the aim is to simplify the reflection usage, why require the if statement at all: try { $r = $type->getReflectionClass(); } catch ( ReflectionException $e ) { // type is builtin or refers to an undefined class } Regards, -- Rowan Collins [IMSoP]