Re: [PHP-DEV] vsprintf()

2013-04-25 Thread Johannes Schlüter
On Wed, 2013-04-24 at 12:54 -0500, Ralph Schindler wrote: I must have left the public in there when I posted it to twitter. I'd have to say it's a little unintuitive when the properties are protected, but all in all, I don't dislike the behavior. Perhaps this just needs to be

[PHP-DEV] vsprintf()

2013-04-24 Thread Rasmus Schultz
This is all kinds of wrong: http://3v4l.org/UZFME So the order in which the properties were defined is the magic that makes this work. Wow. WTF? Do I need to explain in detail why this is all kinds of effed up? - Rasmus Schultz

Re: [PHP-DEV] vsprintf()

2013-04-24 Thread Levi Morrison
On Wed, Apr 24, 2013 at 9:45 AM, Rasmus Schultz ras...@mindplay.dk wrote: Do I need to explain in detail why this is all kinds of effed up? Yes, I'd like that explanation.

Re: [PHP-DEV] vsprintf()

2013-04-24 Thread Johannes Schlüter
On Wed, 2013-04-24 at 11:45 -0400, Rasmus Schultz wrote: This is all kinds of wrong: http://3v4l.org/UZFME So the order in which the properties were defined is the magic that makes this work. Wow. WTF? Do I need to explain in detail why this is all kinds of effed up? vsprintf()'s

RE: [PHP-DEV] vsprintf()

2013-04-24 Thread Richard Bradley
-Original Message- From: Rasmus Schultz [mailto:ras...@mindplay.dk] Sent: 24 April 2013 16:45 To: PHP internals Subject: [PHP-DEV] vsprintf() This is all kinds of wrong: http://3v4l.org/UZFME So the order in which the properties were defined is the magic that makes this work

Re: [PHP-DEV] vsprintf()

2013-04-24 Thread Richard Quadling
On 24 April 2013 17:31, Richard Bradley richard.brad...@softwire.comwrote: -Original Message- From: Rasmus Schultz [mailto:ras...@mindplay.dk] Sent: 24 April 2013 16:45 To: PHP internals Subject: [PHP-DEV] vsprintf() This is all kinds of wrong: http://3v4l.org/UZFME

Re: [PHP-DEV] vsprintf()

2013-04-24 Thread Anthony Ferrara
Richard, Oh! Another magic method opportunity ... /** * Operates just like __toString(), but returns an array. */ public function __toArray(); (ducking) I know you're joking, but this has been brought up before (and I intend to bring it up again):

Re: [PHP-DEV] vsprintf()

2013-04-24 Thread Ralph Schindler
Well, since I was the one who posted it (https://twitter.com/ralphschindler/status/327084619507855361), I'll further explain it. I realized it was doing this when actually running this kind of snippet: http://3v4l.org/ZkE6B I must have left the public in there when I posted it to twitter.

Re: [PHP-DEV] vsprintf()

2013-04-24 Thread Rasmus Schultz
Frankly, a magic method sounds like a much better solution than auto-magically converting objects to arrays. The problem with automatic conversion, is that the order of properties is an implementation detail - the vsprintf() example perfectly illustrates the problem: class User { public

[PHP-DEV] vsprintf returns int not char*

2005-01-04 Thread Kamesh Jayachandran
Hi Derick, in php-src/main/php_sprintf.c PHPAPI int php_sprintf (char*s, const char* format, ...) { va_list args; char *ret; //ret should be of type integer as vsprintf returns int rather than char* va_start (args, format); s[0] = '\0'; ret = vsprintf (s, format, args); va_end