Re: Regarding object casting

From: Date: Tue, 03 Dec 2013 07:13:31 +0000
Subject: Re: Regarding object casting
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-70476@lists.php.net to get a copy of this message
I have reopened the mentioned RFC ( https://wiki.php.net/rfc/object_cast_to_types) with kind permission of the original author. I would like to discuss fallowing matter, regarding to the mentioned RFC - how would these changes affect comparison? Would it be possible to adapt the changes to allow an object to be truthy and falsy in comparison operations, like it is to the SimpleXML? 2013/12/2 Matthew Fonda <mfonda@php.net> > 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. >> > >

« previous php.internals (#70476) next »