Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93774 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 89275 invoked from network); 4 Jun 2016 17:37:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Jun 2016 17:37:49 -0000 Authentication-Results: pb1.pair.com header.from=php@golemon.com; sender-id=softfail Authentication-Results: pb1.pair.com smtp.mail=php@golemon.com; spf=softfail; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain golemon.com does not designate 209.85.214.42 as permitted sender) X-PHP-List-Original-Sender: php@golemon.com X-Host-Fingerprint: 209.85.214.42 mail-it0-f42.google.com Received: from [209.85.214.42] ([209.85.214.42:35522] helo=mail-it0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8A/98-25194-CE113575 for ; Sat, 04 Jun 2016 13:37:49 -0400 Received: by mail-it0-f42.google.com with SMTP id z189so13636233itg.0 for ; Sat, 04 Jun 2016 10:37:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golemon-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to; bh=4fR6Uh5SAlrtxdj23otxfJKAubckNjRn6PkR4JAVLkk=; b=W3SRIfdmsGEmUYWBzlsv7vYDDDa+0I72ikUYYcuWgE31RdVETjAfU0cYRjZReOdKea uErJhhHApFkgv/jHlP+FYtLXrok9Hwl9HFTUWm5XYzJeVKix848AWfJ5aH1Ij0WEg6t+ 1MnqGkZ5eQ5rb6MmHuGEWEWgK97jnHRSURziuGgBptrfTepA3Z3TcRApPrdEF+q2IFmb uUmXxokB+q7YybSEQP3NxeXTjXrGPx2JD1+1NEzUa/19y8D3/kZgejq3DE5C8E/vDMAW VuwzCYSU8Spp6JtIwXZq2PoGRgPKkJLU9LcxrSHoMoh0nvUOvYUDzRbz0EqjQb1yrW74 Ko5A== 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:date :message-id:subject:from:to; bh=4fR6Uh5SAlrtxdj23otxfJKAubckNjRn6PkR4JAVLkk=; b=UsaHIiRe7xplbK95skNcfPMgbfJ38oekCpmA1A3CZ5b2HmSvJDMSAmyY+6J6SxGqzx soetVW04ms+AykSO0cMVC/8sQMTQzsMlli5Y56K36MM+4za7vuu58KzftbAEGy64Fe6Q hJ3J/lC6gAecKzcx97QZswByPHKaj8pLFQ8MCRrlE3biLYMkjZmN2ZnZ0kNIpB4uT+W3 OtNGQipfthBzmw2FHwOVqNKuSvSebpgtxFMyR1jpSMzX5jMo9p0lpURCSUOh6lOOIqL3 aT9tbIwD4vxqClZyAsrsl7+zfRuKULSE4Ghzeaj6ETrnCHsFA7d73qo8DB0No+GDGN0u ml6g== X-Gm-Message-State: ALyK8tJYx204a7gOzLTQ6wETvMtS5MDCaawDxNoIXTqpI77AaBosMF9fJLvRr0BrwEwRaCFCFEv+AB/VRJxqXg== MIME-Version: 1.0 X-Received: by 10.36.104.2 with SMTP id v2mr7349614itb.64.1465061866078; Sat, 04 Jun 2016 10:37:46 -0700 (PDT) Sender: php@golemon.com Received: by 10.36.9.67 with HTTP; Sat, 4 Jun 2016 10:37:45 -0700 (PDT) X-Originating-IP: [107.198.91.68] In-Reply-To: References: Date: Sat, 4 Jun 2016 10:37:45 -0700 X-Google-Sender-Auth: P4lV_LMwAC6WrEIS1XNvFJLeU2U Message-ID: To: PHP internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [RFC DISCUSSION] typeof From: pollita@php.net (Sara Golemon) On Sat, Jun 4, 2016 at 5:12 AM, Fleshgrinder wrote: > I prepared my first contribution to internals: > Welcome! > https://github.com/php/php-src/pull/1932 > I've put a couple minor notes on the implementation. Nothing technically wrong, just style and micro-perf. > I would like to discuss the proposed new function here. > My number one issue with this PR is that it's all PHP code. There's nothing in here that couldn't be done as a composer installable library wrapping the existing gettype() and mapping around the oddities you mention in the RFC. Wouldn't it be better to make something that'll work across PHP versions, rather than something only available in 7.1? Beyond that, though on a similar vein, the extended format feels like unparsable overkill for any use case but logging, and in the case of logging you probably want the value as well which calls for something more in the var_*() family. var_describe, perhaps? By comparison, when it comes to code logic, there's nothing I do with (typeof($foo, true) === 'bool true') that I can't do with ((gettype($foo) === 'boolean') && $foo). I'll grant that the former is marginally more readable, but only in the most generous, liberal sense. If you'd like a new typeof() function, I think we should design it to be much more robust like what Marco suggested. I don't care if that's ReflectionType or ReflectionVariable or ReflectionBananaForScale. Something that serves both programmatic needs by having ->isCallable() ->isNumeric() etc methods *and* serves human readability through a __toString() method seems to make much more sense. Lastly, with all the work going into gradual typing, I can see us specifically wanting the name `typeof` at some later point. So at the VERY least, I'd rename this to var_type() or similar. -Sara