Re: Regarding object casting
Hi Matīss,
Internal classes are able to define what happens when casting to different
primitive types. There was an RFC [1] to extend this behavior to userland,
but it has since been withdrawn. See archives for further discussion about
this.
Best regards,
--Matthew
On Mon, Dec 2, 2013 at 4:19 AM, Matīss Roberts Treinis
<mrtreinis@gmail.com>wrote:
> Good day, PHP internals folks.
>
> As we all know, objects in PHP casts to true by default, except one
> particular class - SimpleXML objects created from empty tag.
>
> Many people in the community has had a problem with this limitation (or
> lack of functionality) to be able to set cast value of the object and are
> exploiting the SimpleXML to achieve the ability to control object casting..
>
> The question would be, why this exception - SimpleXML? Could we have a
> magic method or other way to control how object is being casted?
>
> Thoughts?
>
> Thanks.
>
Thread (3 messages)