[PATCH] __toString()

php.internals

Marcus Börger

20 years ago
Hello internals, the patch implements __toString to have obejcts be automatically converted to strings anywhere a string is requested. We have talked a lot about this in the past and during OSCON Andi agreed again on it and said that the HEAD version of the engine should be ready for it now. Futher more we have enough time to fix any outstanding engine issues regarding this. http://php.net/~helly/php/ext/ze2/ze2-tostring-20050925.diff.txt If nobody objects with a real technical issue i'll commit the patch early in the week. The patch is a little big longer because it ensures that __toString gets treated and especially gets cached just like any other magic function is. Best regards, Marcus

Andi Gutmans

20 years ago
Give me a couple of days to review the patch itself. I think we should then commit to HEAD, and see how it goes. There's hopefully enough time in the PHP 6 process to validate that this kind of patch doesn't hit any conceptual problems re: propagating to pre-compile/post-shutdown execution stages... Andi At 05:36 AM 9/25/2005, Marcus Boerger wrote:

Marcus Börger

20 years ago
Hello Andi, i don't see your point here. We've discussed this tons of times. Either fix the engine if you know it's broken, show us a real problem with the pacth or accept the fact that we want to make progress here. Blocking patches because they have a slight potential in causing some problems without telling about the problems and coming up with some test script doesn't help anybody here. You are just waisting my time with that. All other who saw the patch agreed to it already. marcus Sunday, September 25, 2005, 6:31:59 PM, you wrote:

Andi Gutmans

20 years ago
Marcus, I think you misread my email. I said that it *should* be commited. I did want an additional two days to review because we did *have* feedback for the patch (as you saw). I don't know who "All others" are, but I don't know many who can understand this patch to the lowest level of details. So I don't know where you got the idea of blocking. Let me quote myself "I think we should then commit to HEAD"... That said, although many are trigger happy, I am noting that architecturally, this has far reach implications (it will reach everyplace in the engine which does a convert_to_*() etc.). I apologize that I can't pinpoint a precise problem right now (such as convert_to_* being called after dtors are called). All I tried to say is that we have to be aware that this is a very sensitive area to change and there is a good chance we might bump into problems. So as I said in the conference and in my email, I'm not against progress, I am just stating we need some time to make sure that it's indeed progress and doesn't regress us into trouble. That's why we need (and have) enough time to make sure things don't break ala exceptions not propagating everywhere or changing behavior of return by reference. One problem I pointed out which had to do with exceptions not propagating from __toString() was very valid, and we agreed to not allow it (did you actually implement that part of the discussion?). Believe me, from a usability perspective, I think __toString() working automagically is very nice... I'm just being less trigger happy and want to make sure we're covered. Andi At 10:05 AM 9/25/2005, Marcus Boerger wrote:

Mike Robinson

20 years ago
Andi Gutmans writes:
> Believe me, from a usability perspective, I think > __toString() working automagically is very nice... I'm just > being less trigger happy and want to make sure we're covered.
Humbly, this is a smart and prudent approach, to a nice piece of work I might add. Best, Mike Robinson

Marcus Börger

20 years ago
Hello Andi, the excepton part is not in it jet but i'll do it (or dmitry can do it easily). However i don't see a point here. And i don't see a point in your dtors either. If anything that happens with the current implementation of the patch is wrong then either it is an edgecase we have to fix or it would have happened with __get/__set/__call as well which use the exact same ideas besides the fact that they are called for different reasons of course. That said i again don't see any reason to wait unless someone can show something that is causing a real problem and not something that eventually might effect some unknown parts in a way that theoretically might be bad. p.s.: you often enough said gimme some time and we just lost things. Tuesday, September 27, 2005, 2:17:55 AM, you wrote:

Marian Kostadinov

20 years ago
I'd like to do some tests of the new __toString functionality but it seems that it is committed only in PHP6-CVS branch. Is there a way to get a windows binary snapshot for this branch?

Edin Kadribasic

20 years ago
http://ftp.emini.dk/pub/php/win32/php6/ Edin Marian Kostadinov wrote:

Marcus Börger

20 years ago
Hello Edin, cool, thanks! marcus Wednesday, September 28, 2005, 10:52:00 PM, you wrote:
> http://ftp.emini.dk/pub/php/win32/php6/
> Edin
> Marian Kostadinov wrote: >> I'd like to do some tests of the new __toString functionality but it >> seems that it is committed only in PHP6-CVS branch. Is there a way to >> get a windows binary snapshot for this branch? >>
Best regards, Marcus

Jeremy Johnstone

20 years ago
Hello All, Was this actually added into PHP? Can anyone confirm if PHP's toString() magic method will work everywhere a string is used (aka printf, switch, etc)? If so, will this be possibly available in the 5.1x branch (since it's sorta a bug/consistency fix) or will it only make it into the next major release? -Jeremy On 9/28/05, Marcus Boerger <helly@php.net> wrote:
> > Hello Edin, > > cool, thanks! > > marcus > > Wednesday, September 28, 2005, 10:52:00 PM, you wrote: > > > http://ftp.emini.dk/pub/php/win32/php6/ > > > Edin > > > > Marian Kostadinov wrote: > >> I'd like to do some tests of the new __toString functionality but it > >> seems that it is committed only in PHP6-CVS branch. Is there a way to > >> get a windows binary snapshot for this branch? > >> > > > > > Best regards, > Marcus > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >
-- --------------------------- Jeremy Johnstone http://www.jeremyjohnstone.com jsjohnst@php.net

Marcus Börger

20 years ago
Hello Jeremy, it is supposed to work everywhere in head and will be available in 5.2. regards marcus Friday, January 27, 2006, 12:54:28 AM, you wrote:
> Hello All,
> Was this actually added into PHP? Can anyone confirm if PHP's toString() > magic method will work everywhere a string is used (aka printf, switch, > etc)? If so, will this be possibly available in the 5.1x branch (since it's > sorta a bug/consistency fix) or will it only make it into the next major > release?
> -Jeremy
> On 9/28/05, Marcus Boerger <helly@php.net> wrote: >> >> Hello Edin, >> >> cool, thanks! >> >> marcus >> >> Wednesday, September 28, 2005, 10:52:00 PM, you wrote: >> >> > http://ftp.emini.dk/pub/php/win32/php6/ >> >> > Edin >> >> >> > Marian Kostadinov wrote: >> >> I'd like to do some tests of the new __toString functionality but it >> >> seems that it is committed only in PHP6-CVS branch. Is there a way to >> >> get a windows binary snapshot for this branch? >> >> >> >> >> >> >> Best regards, >> Marcus >> >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php >> >>
> -- > --------------------------- > Jeremy Johnstone > http://www.jeremyjohnstone.com > jsjohnst@php.net
Best regards, Marcus

Ron Korving

20 years ago
Marcus, you are my hero :) Will it end up in 5.1? Ron "Marcus Boerger" <helly@php.net> wrote in message news:1728334199.20050925143657@marcus-boerger.de...
> Hello internals, > > the patch implements __toString to have obejcts be automatically
converted
> to strings anywhere a string is requested. We have talked a lot about this > in the past and during OSCON Andi agreed again on it and said that the
HEAD
> version of the engine should be ready for it now. Futher more we have
enough
> time to fix any outstanding engine issues regarding this. > > http://php.net/~helly/php/ext/ze2/ze2-tostring-20050925.diff.txt > > If nobody objects with a real technical issue i'll commit the patch
early

Andi Gutmans

20 years ago
Nope, it's too far-reaching for it to make it into 5.1. It will take some time to be sure that it doesn't screw up anyplace (similar to the infamous shutdown problems)... At 10:46 AM 9/25/2005, Ron Korving wrote:

Marcus Börger

20 years ago
Hello Ron, no, we declined it for 5.1 becasue it was to late in release process when we (i) rememebred it....so blame me for not having it in 5.1, or blame yourself for not reminding us :-) regards marcus Sunday, September 25, 2005, 7:46:09 PM, you wrote:
> Marcus, you are my hero :) > Will it end up in 5.1?
> Ron
> "Marcus Boerger" <helly@php.net> wrote in message > news:1728334199.20050925143657@marcus-boerger.de... >> Hello internals, >> >> the patch implements __toString to have obejcts be automatically > converted >> to strings anywhere a string is requested. We have talked a lot about this >> in the past and during OSCON Andi agreed again on it and said that the > HEAD >> version of the engine should be ready for it now. Futher more we have > enough >> time to fix any outstanding engine issues regarding this. >> >> http://php.net/~helly/php/ext/ze2/ze2-tostring-20050925.diff.txt >> >> If nobody objects with a real technical issue i'll commit the patch > early >> in the week. >> >> The patch is a little big longer because it ensures that __toString gets >> treated and especially gets cached just like any other magic function is. >> >> Best regards, >> Marcus
Best regards, Marcus

Ron Korving

20 years ago
I knew I had forgotten something ;) Ron "Marcus Boerger" <helly@php.net> wrote in message news:899874576.20050925203300@marcus-boerger.de...
> Hello Ron, > > no, we declined it for 5.1 becasue it was to late in release process > when we (i) rememebred it....so blame me for not having it in 5.1, or
blame
> yourself for not reminding us :-) > > regards > marcus > > Sunday, September 25, 2005, 7:46:09 PM, you wrote: > > > Marcus, you are my hero :) > > Will it end up in 5.1? > > > Ron > > > "Marcus Boerger" <helly@php.net> wrote in message > > news:1728334199.20050925143657@marcus-boerger.de... > >> Hello internals, > >> > >> the patch implements __toString to have obejcts be automatically > > converted > >> to strings anywhere a string is requested. We have talked a lot about
this
> >> in the past and during OSCON Andi agreed again on it and said that the > > HEAD > >> version of the engine should be ready for it now. Futher more we have > > enough > >> time to fix any outstanding engine issues regarding this. > >> > >> http://php.net/~helly/php/ext/ze2/ze2-tostring-20050925.diff.txt > >> > >> If nobody objects with a real technical issue i'll commit the patch > > early > >> in the week. > >> > >> The patch is a little big longer because it ensures that __toString
gets
> >> treated and especially gets cached just like any other magic function
is.

Dmitry Stogov

20 years ago
Hi Marcus, This is improved version of your patch. It breaks only two tests those must be changed. (instead of > 10 those shouldn't) Please review. Thanks. Dmitry.

Marcus Börger

20 years ago
Hello Dmitry, looks good Monday, September 26, 2005, 8:55:30 PM, you wrote: