Re: Re: __toString & friends

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



thx  Thiago .
I suggested there
  http://bugs.php.net/bug.php?id=46128



""Thiago H. Pojda"" <thiago.pojda@xxxxxxxxx> a écrit dans le message de 
news: c0e7fa7f0809190708u3b198159je032ef29eba54026@xxxxxxxxxxxxxxxxx
http://bugs.php.net should help you out.

In the bug reporting page there's a Feature request item (It's the 3rd item
in the Type of bug select).

Btw, I liked this idea :)

On Fri, Sep 19, 2008 at 8:58 AM, Leurent Francois 
<131.php@xxxxxxxxxxxx>wrote:

> Is there any feature submission  process were we could discuss of this
> subject ?
>
>
> "Colin Guthrie" <gmane@xxxxxxxxxxxxxx> a écrit dans le message de news:
> gapele$188$1@xxxxxxxxxxxxxxxx
> > Nathan Rixham wrote:
> >> concurred; I recently made a class that turn's all objects into XML; 
> >> and
> >> implented it in my __toString()'s :)
> >
> > In that case rather than __toBool() __toInt() etc. it should really
> > support a magic __cast() method or similar.
> >
> > This method would contain a single argument that represents the type
> (e.g.
> > a class name or a builtin type....
> >
> > function __cast($type)
> > {
> >   switch ($type)
> >   {
> >     case 'string':
> >       return 'Foo';
> >     case 'array':
> >       return array('Foo');
> >     case 'DomDocument':
> >       // etc.
> >   }
> > }
> >
> > And if you did:
> >
> > $foo = new MyClass;
> >
> > $xml = (DomDocument)$foo;
> >
> > It would return the result of __cast called with $type == 'DomDocument'.
> >
> > That would be nice and generic.
> >
> > I could see that being quite useful (tho' arguably, itmplementing a
> cast()
> > method is not that hard:
> >
> > $xml = $foo->cast('DomDocument');
> >
> > It's not as neat tho' :)
> >
> > col
> >
> > --
> >
> > Colin Guthrie
> > gmane(at)colin.guthr.ie
> > http://colin.guthr.ie/
> >
> > Day Job:
> >   Tribalogic Limited [http://www.tribalogic.net/]
> > Open Source:
> >   Mandriva Linux Contributor [http://www.mandriva.com/]
> >   PulseAudio Hacker [http://www.pulseaudio.org/]
> >   Trac Hacker [http://trac.edgewall.org/]
> >
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Thiago Henrique Pojda



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux