Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93770 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 80065 invoked from network); 4 Jun 2016 16:18:11 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Jun 2016 16:18:11 -0000 Authentication-Results: pb1.pair.com smtp.mail=ocramius@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ocramius@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.43 as permitted sender) X-PHP-List-Original-Sender: ocramius@gmail.com X-Host-Fingerprint: 74.125.82.43 mail-wm0-f43.google.com Received: from [74.125.82.43] ([74.125.82.43:35787] helo=mail-wm0-f43.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 63/F6-25194-24FF2575 for ; Sat, 04 Jun 2016 12:18:10 -0400 Received: by mail-wm0-f43.google.com with SMTP id a136so35412415wme.0 for ; Sat, 04 Jun 2016 09:18:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=UjuA4oDq4gCbuVaBdh+DP/Y5KGce0hLcI/lrAnJ/Ar4=; b=U+3MhZVPPW0mR5730Hf1dyCmvRg6azwc/6aJKiE/LmzSAOrOJWf1bBh4ooR9/Z8q/u VJ1IkM3g0dRmvQo0DFUaet0YX1t+qeXS7Lj8M8G0bQo2VOnoTJuTk6qQoyh6WoiuNYwo Em/5SHG/0trhZYhGLYe977rSo6Ex1xMi3YyU2dGUMj8B4UnLHF/924S+Ddz4btJbVoFo 7nU6tiSVu7vKy6nSeexXQrQtsMrxNFZG3/xviltA6/rBE2SFokbSz5uLsweWT8C/Gqt8 A/cXDHVxjvY2TmnAvTAnj6vFgAZsTfxBt3EwxP5ifPkCK6UqW8aBDGM0QKqd30wVGLKx XdpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=UjuA4oDq4gCbuVaBdh+DP/Y5KGce0hLcI/lrAnJ/Ar4=; b=MIHZ9jGfL6SXPnif9hIBDNWiKSzI2ngL/sGnw6hbTwlCBJCLgKbvRHLnrDJKaLYeBy 8onMj/e7LzIWhu576EhllrgZHuVhST8Kfz4oAziHxzojWkd06M4ReO3X+72PYR3Nbuif RuUwOp7kSYZ6LDwV7hAJdZyUhbV7ifAwJWB4L5TjTfcbAVYNCy5Q9YexR4jEfPGL/RZa +wh0HimSFunFwIkCUVYRjJNdHYoEoynLKWbJ4N/QrWSD5TO++ElJzRpH+q+ie3Dj0zdW 781A10v5lcR35/yado6x2SkET3/m/1Dp0i7t4wnulcbVa580cNXPkZXmwiOZJGZBGXAq o3CQ== X-Gm-Message-State: ALyK8tJknEegKIgr0PxTNa77Yg/r+8u2Jk/zEd/jtBD7KTBGEwQ5vupiPbBv+lnBUKLkkqIBZlLwPG1RwMzqOA== X-Received: by 10.194.151.73 with SMTP id uo9mr7889131wjb.177.1465057087739; Sat, 04 Jun 2016 09:18:07 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.163.106 with HTTP; Sat, 4 Jun 2016 09:17:46 -0700 (PDT) In-Reply-To: References: Date: Sat, 4 Jun 2016 18:17:46 +0200 Message-ID: To: PHP Internals List Cc: Dan Ackroyd Content-Type: multipart/alternative; boundary=089e012294464a61190534762fd0 Subject: Re: [PHP-DEV] [RFC DISCUSSION] typeof From: ocramius@gmail.com (Marco Pivetta) --089e012294464a61190534762fd0 Content-Type: text/plain; charset=UTF-8 It would be beneficial to not reduce this to stringly-typed programmer (again), as Dan mentioned. Returning something like a ReflectionType instance (which then implements __toString) would be much simpler, efficient and easy to use. Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ On 4 June 2016 at 18:05, Fleshgrinder wrote: > On 6/4/2016 4:34 PM, Dan Ackroyd wrote: > > Hello FG, > > > > Having a standard way to get the type of a variable, that matches the > > name of how it appears in PHP is a good idea. > > > > The 'extended' parameter is not such a good idea, for various reasons > > but mainly because it's simpler for people to call is_callable() as > > well as typeof, rather than having to interpret the extended string to > > tell if a string represents a callable. > > > > The same is true for floats; it is easier for people to call > > is_infinite or is_nan rather than searching inside a string for > > 'infinite' or 'invalid'. > > > > cheers > > Dan > > > > Hi Dan, > > many thanks for your feedback. This is definitely NOT the purpose of the > extended mode, and I tried to emphasize this in the RFC. I also think it > would be very bad to introduce anything that would compete with any of > the existing is_* functions. It is also the reason why the strings are > very verbose and human readable: they are meant for debug and error > messages. > > // complicated code ... > // error branch {{{ > > $type = typeof($v, true); > throw new Ex('Expected Foo but got ' . $type); > > // }}} > // complicated code ... > > This matches the main usage -- according to my research -- of the > existing gettype() function in userland software. :) > > -- > Richard "Fleshgrinder" Fussenegger > > --089e012294464a61190534762fd0--