Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94394 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 39056 invoked from network); 5 Jul 2016 21:06:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Jul 2016 21:06:17 -0000 Authentication-Results: pb1.pair.com smtp.mail=morrison.levi@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=morrison.levi@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.192.176 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.192.176 mail-pf0-f176.google.com Received: from [209.85.192.176] ([209.85.192.176:36190] helo=mail-pf0-f176.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1A/B2-19446-8412C775 for ; Tue, 05 Jul 2016 17:06:17 -0400 Received: by mail-pf0-f176.google.com with SMTP id t190so73366949pfb.3 for ; Tue, 05 Jul 2016 14:06:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=KVgOXjNbJ3k/VWW6tR1Tgc3d0swun63kAj5/wAKqpyU=; b=AzFTq6HcokEHAAVf4lGDgq2VTiDb6T3SpJNbBJqpXOiC2E6p8OpEQFIiTf1oGOwQV0 FnMyU+pcjBC8m/Kn2oAqbjBuyHbLmFXI/u9hA4dnBHSkGIi+7gtrflm1Y0CScv5hV6Td NV/eAwCuAttpzMwlEdstOJztGEWgOYfdA3M/Vlcdy3UPL5igEdyy4EqMzdGgMBZ8e08D 1MWXkL0NezuZEdlph29PQSz7rk/RhE3hh8B9mCTVj8Ln+CHjWFrh51282id5SnWvbQ7K JNnNS4nFNij5keAjtnoDI4IW5GW3hAV7Xt/M1It093Ij23ffhV1Gui6t/xVFV1Ff3n0Y +Uog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=KVgOXjNbJ3k/VWW6tR1Tgc3d0swun63kAj5/wAKqpyU=; b=YkZbCRGkUODRqhmGYuDVk+baj2LvDHXHuDI2oDVN5oHxYQZadECtF4hLqM0C18hE+I 6+2VoTHhdNe4Zrq5R+WzxRkPUH4K6ajNhQY3eJXrkMh0ojR+Y/FzREcDpIBr18Ixna5R 3xKHoiDi32QYuljYIwb4z3Ys644Gfd9udcXpzzThqIjDD7jeiBXbxsXKrTDuD+IKNITg +CDQ9kOSx4gDcI/w5B4tIyMCbC5N+qok4BiJHKasRkHsrGaxaPdO+5sMVK/+zTjE4rNo GCShC6zvwAE7X3VvPpxC5WUkLHtF8ewcz8+Xi4mrBCbOb/7kGxAm0mJpRNnyUHFAWiIr WtJA== X-Gm-Message-State: ALyK8tLvYy9pavJzJz/3XMocpHPWAwgs1ruYrDFWa8HlynfOWKeph1KiLo0CEx/Rhf7JrvVIzz7Y/Sr5v1lDYw== X-Received: by 10.98.29.81 with SMTP id d78mr35388154pfd.142.1467752773172; Tue, 05 Jul 2016 14:06:13 -0700 (PDT) MIME-Version: 1.0 Sender: morrison.levi@gmail.com Received: by 10.66.23.72 with HTTP; Tue, 5 Jul 2016 14:06:12 -0700 (PDT) In-Reply-To: References: <1f39f97a-6aaf-8550-9f82-a7e80465f903@telia.com> Date: Tue, 5 Jul 2016 15:06:12 -0600 X-Google-Sender-Auth: zDiJAKuYmOnUnIALQVnFNLI2VKE Message-ID: To: Rowan Collins Cc: internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [RFC][Vote] ReflectionType Improvements From: levim@php.net (Levi Morrison) > 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 > } I don't think this is actually simpler if you expand the comment to handle both cases: try { $r = $type->getReflectionClass(); handle_class($type); } catch (ReflectionException $e) { if ($type->isBuiltin()) { handle_builtin(); } else { handle_undefined($type); } } 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. Another option is adding a method `hasClass()` that would return `true` if a `getClass()` call would be considered valid and `false` otherwise. To me this doesn't seem as good as subtypes but consider it better than forcing a caller to handle an exception in a situation that I don't consider exceptional. It would have been great if people actually contributed to the discussion before voting phase, but such is life.