Re: [RFC DISCUSSION] typeof
| From: | Fleshgrinder | Date: | Sat, 04 Jun 2016 16:05:58 +0000 |
| Subject: | Re: [RFC DISCUSSION] typeof | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-93769@lists.php.net to get a copy of this message | ||
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
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc