Re: [RFC] Scalar Type Hinting With Casts (re-opening)

From: Date: Thu, 24 Jul 2014 14:26:50 +0000
Subject: Re: [RFC] Scalar Type Hinting With Casts (re-opening)
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-76012@lists.php.net to get a copy of this message
On 24 Jul 2014, at 13:20, Simon Schick <simonsimcity@gmail.com> wrote:

>> Conversion is allowed only if data-loss does not happen. There are a few exceptions
>> (objects using __toString, strings containing leading numerics, etc). Here's a table of
>> examples.
> 
> But if you look at the table, strings containing leading numbers are
> not allowed.

Good catch, fixed.

> And just as a thought: What about objects where the __toString method
> returns a string like "42"? Would that also be accepted as an
> argument, that just accepts integers?

No it wouldn’t, as that’s not what cast_object does, existing conversion functions do, or what
the patch does at present.
--
Andrea Faulds
http://ajf.me/






Thread (250 messages)

« previous php.internals (#76012) next »