Re: [PHP-DEV] __toString(), __toArray()

2010-01-13 Thread Clint Priest
Etienne Kneuss wrote: Hello, On Tue, Jan 12, 2010 at 11:40 PM, Chris Stockton wrote: Hello, On Mon, Jan 11, 2010 at 8:32 PM, mm w <0xcafef...@gmail.com> wrote: cast is not needed in PHP i 'd rather be more interesting in class Obj { function __catch($data, $type) { //$type

Re: [PHP-DEV] __toString(), __toArray()

2010-01-13 Thread Ionut G. Stan
It appears that, mm w is talking about some aspect oriented feature. I would welcome a magic method that would intercept calls/access to existing methods/properties (not only inaccessible ones), in the same sense that __getattribute__ works in Python for example IIRC. It may also be a good tim

Re: [PHP-DEV] __toString(), __toArray()

2010-01-13 Thread Etienne Kneuss
Hello, On Tue, Jan 12, 2010 at 11:40 PM, Chris Stockton wrote: > Hello, > > On Mon, Jan 11, 2010 at 8:32 PM, mm w <0xcafef...@gmail.com> wrote: >> cast is not needed in PHP >> >> i 'd rather be more interesting in >> >> class Obj { >>     function __catch($data, $type) { >>            //$type [ s

Re: [PHP-DEV] __toString(), __toArray()

2010-01-12 Thread mm w
:-D, without any magic, I am sorry if I hurt you I though you were tougher than a cookie, don't worry about my friends I have plenty on face-cooked, but for God Sake I am still eating alone at noon 8-) On Tue, Jan 12, 2010 at 9:50 PM, Chris Stockton wrote: > I don't move any magics, I'm worrie

Re: [PHP-DEV] __toString(), __toArray()

2010-01-12 Thread Chris Stockton
I don't move any magics, I'm worried your knowledge of social skills? Theirs people be your friends? Weird On Jan 12, 2010 9:10 PM, "mm w" <0xcafef...@gmail.com> wrote: I don't move any magics,I am worried about your knowledge of php, there's people to give you money ? weird, set get call are onl

Re: [PHP-DEV] __toString(), __toArray()

2010-01-12 Thread mm w
I don't move any magics,I am worried about your knowledge of php, there's people to give you money ? weird, set get call are only call when something doesn't exist catch or catch-able concept is to be able to catch any existing calls no the dynamic ones. On Tue, Jan 12, 2010 at 6:59 PM, Clint Pri

Re: [PHP-DEV] __toString(), __toArray()

2010-01-12 Thread Clint Priest
Eddie Drapkin wrote: What you're proposing is just forcing __call, _callStatic, __get and __set into a single method, which does nothing to reduce the amount of magic, only obfuscate it. And it certainly offers no alternative to "__cast", at least not that I can see. I agree, moving all magi

Re: [PHP-DEV] __toString(), __toArray()

2010-01-12 Thread mm w
I am not forcing anything, it's already there, that's definitely a more useful magic, if people would add a new one, __cast is not critical, catchable objects are __catch even if exists, so my point I 'd rather see useful requests than a unseful one e.g __cast from my perspective __toString and __

Re: [PHP-DEV] __toString(), __toArray()

2010-01-12 Thread Eddie Drapkin
What you're proposing is just forcing __call, _callStatic, __get and __set into a single method, which does nothing to reduce the amount of magic, only obfuscate it. And it certainly offers no alternative to "__cast", at least not that I can see. On Tue, Jan 12, 2010 at 9:11 PM, mm w <0xcafef...@

Re: [PHP-DEV] __toString(), __toArray()

2010-01-12 Thread mm w
the multiplication of magic, the pointed point, need to read more carefully On Tue, Jan 12, 2010 at 6:10 PM, Eddie Drapkin wrote: > How does this have *anything* to do with the discussion at hand? > > On Tue, Jan 12, 2010 at 9:09 PM, mm w <0xcafef...@gmail.com> wrote: >> don't worry it's only for

Re: [PHP-DEV] __toString(), __toArray()

2010-01-12 Thread Eddie Drapkin
How does this have *anything* to do with the discussion at hand? On Tue, Jan 12, 2010 at 9:09 PM, mm w <0xcafef...@gmail.com> wrote: > don't worry it's only for people who are working with MVC and > RootObject structure, there is too much magics already and __cast is > not needed at all, > as we c

Re: [PHP-DEV] __toString(), __toArray()

2010-01-12 Thread mm w
don't worry it's only for people who are working with MVC and RootObject structure, there is too much magics already and __cast is not needed at all, as we cannot monkey patch to add an observer on itself, a nice solution should have a catchable object so __catch any calls function __catch($data,

Re: [PHP-DEV] __toString(), __toArray()

2010-01-12 Thread Chris Stockton
Hello, On Mon, Jan 11, 2010 at 8:32 PM, mm w <0xcafef...@gmail.com> wrote: > cast is not needed in PHP > > i 'd rather be more interesting in > > class Obj { >     function __catch($data, $type) { >            //$type [ static_method, method, get_property, set_property] >            if (observed &

Re: [PHP-DEV] __toString(), __toArray()

2010-01-11 Thread mm w
cast is not needed in PHP i 'd rather be more interesting in class Obj { function __catch($data, $type) { //$type [ static_method, method, get_property, set_property] if (observed && $type == set_property && somevalueIsObserved) { $observer->notify(

Re: [PHP-DEV] __toString(), __toArray()

2010-01-11 Thread Clint Priest
Etienne Kneuss wrote: Hello, On Mon, Jan 11, 2010 at 7:31 PM, Clint Priest wrote: I know there's been requests to add a __toArray() and most of the arguments against it is that there are too many magic functions already. I just thought I'd propose an alternative that would satisfy all of the

Re: [PHP-DEV] __toString(), __toArray()

2010-01-11 Thread Stanislav Malyshev
Hi! Why not a __cast($Type) magic function? The interesting thing is that in the engine the object handler is actually: typedef int (*zend_object_cast_t)(zval *readobj, zval *retval, int type TSRMLS_DC); i.e. the handler is already generic, but implementation API isn't - standard engine h

Re: [PHP-DEV] __toString(), __toArray()

2010-01-11 Thread Etienne Kneuss
Hello, On Mon, Jan 11, 2010 at 7:31 PM, Clint Priest wrote: > I know there's been requests to add a __toArray() and most of the arguments > against it is that there are too many magic functions already.  I just > thought I'd propose an alternative that would satisfy all of them. > > Why not a __c

[PHP-DEV] __toString(), __toArray()

2010-01-11 Thread Clint Priest
I know there's been requests to add a __toArray() and most of the arguments against it is that there are too many magic functions already. I just thought I'd propose an alternative that would satisfy all of them. Why not a __cast($Type) magic function? -- PHP Internals - PHP Runtime Developme

Re: [PHP-DEV] __toString() and exceptions

2008-05-28 Thread Sebastian
Hi, thank you, first of all because this was the first link to Zend Weekly News that worked. ;-) then to the real thing: i already thougt that such an answer was abroad. i know that the zend engine has actually never been written to work with exceptions. altought the zend engine 2 has great ne

Re: [PHP-DEV] __toString() and exceptions

2008-05-28 Thread Guilherme Blanco
Hi Sebastian, This is known and I already asked this quite some time ago. Here is the summary of what have I asked here: http://devzone.zend.com/article/2016-Zend-Weekly-Summaries-Issue-336#Heading6 Regards, On Wed, May 28, 2008 at 3:17 PM, Sebastian <[EMAIL PROTECTED]> wrote: > Hi, > > i just

[PHP-DEV] __toString() and exceptions

2008-05-28 Thread Sebastian
Hi, i just found it's really annoying that you can't throw exception in the context of __toString(). This makes it nealy impossible to work with __toString() because you'll have to watch not to throw exceptions (which is even more annoying..). Could this be adressed? Greetings -- PHP Inte

Re: [PHP-DEV] __toString extension proposal

2006-12-19 Thread Etienne Kneuss
Hi, you can use: class test2 { public function __toString(){ return (string) new test; } } Marian Kostadinov wrote: Hi, there is one issue that I experience since I started using 5.2.0 and especially the new correct __toString behaviour. Generally it works fine. But sometimes I find it usefu

[PHP-DEV] __toString extension proposal

2006-12-19 Thread Marian Kostadinov
Hi, there is one issue that I experience since I started using 5.2.0 and especially the new correct __toString behaviour. Generally it works fine. But sometimes I find it useful to get __toString return another object the also has a __toString method. So my idea is - is it possible (and good idea)

Re: [PHP-DEV] __toString() with cast is broken in php5 RC1

2004-04-03 Thread Andi Gutmans
s Boerger" <[EMAIL PROTECTED]> To: "David Giffin" <[EMAIL PROTECTED]> Cc: "Marcus Boerger" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Friday, April 02, 2004 12:27 PM Subject: Re: [PHP-DEV] __toString() with cast is broken in php5 RC1 > Hello Davi

Re: [PHP-DEV] __toString() with cast is broken in php5 RC1

2004-04-02 Thread Derick Rethans
On Fri, 2 Apr 2004, Adam Maccabee Trachtenberg wrote: > On Fri, 2 Apr 2004, Derick Rethans wrote: > > > *casting* works fine, we just don't do it automagically: > > > > print (string) $obj; > > Not anymore: Yup, I know :) Derick -- PHP Internals - PHP Runtime Development Mailing List To unsubs

Re: [PHP-DEV] __toString() with cast is broken in php5 RC1

2004-04-02 Thread Adam Maccabee Trachtenberg
On Fri, 2 Apr 2004, Derick Rethans wrote: > *casting* works fine, we just don't do it automagically: > > print (string) $obj; Not anymore: class foo { function __toString() { return "I am a string."; } } $foo = new foo; print (string) $foo; Object id #1 -adam -- [EMAIL PROTECTED] au

Re: [PHP-DEV] __toString() with cast is broken in php5 RC1

2004-04-01 Thread Derick Rethans
On Thu, 1 Apr 2004, David Giffin wrote: > Is this going to change back? The php5 documentation on the zend site > shows that both casting and print/echo should work. *casting* works fine, we just don't do it automagically: print (string) $obj; regards, Derick -- PHP Internals - PHP Runtime De

Re: [PHP-DEV] __toString() with cast is broken in php5 RC1

2004-04-01 Thread Jevon Wright
ginal Message - From: "Marcus Boerger" <[EMAIL PROTECTED]> To: "David Giffin" <[EMAIL PROTECTED]> Cc: "Marcus Boerger" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Friday, April 02, 2004 12:27 PM Subject: Re: [PHP-DEV] __toString() with cast

Re: [PHP-DEV] __toString() with cast is broken in php5 RC1

2004-04-01 Thread Marcus Boerger
Hello David, generally the idea is to change this back. But i don't think we will be able to solve the related problems before PHP 5.1. marcus Friday, April 2, 2004, 2:03:38 AM, you wrote: > Hi Marcus, > Is this going to change back? The php5 documentation on the zend site > shows that both c

Re: [PHP-DEV] __toString() with cast is broken in php5 RC1

2004-04-01 Thread David Giffin
Hi Marcus, Is this going to change back? The php5 documentation on the zend site shows that both casting and print/echo should work. I guess people could use the output buffering methods to get the print data for the time being. A not so happy work around :( Thanks again, David On Fri, 2 Apr

Re: [PHP-DEV] __toString() with cast is broken in php5 RC1

2004-04-01 Thread Marcus Boerger
Hello David, that's correct. See the NEWS file, 3rd entry: 18 March 2004, PHP 5 Release Candidate 1 - Fixed numerous bugs with the just-in-time auto-global initialization, that could cause $_SERVER, $argv/$argc and other variables not to work properly. (Zeev) - Fixed data corruption with

[PHP-DEV] __toString() with cast is broken in php5 RC1

2004-04-01 Thread David Giffin
Hi There, I just got a chance tp update to PHP5 RC1 and noticed that some things have changed for the __toString method. It seems that it it only getting called when the object is printed or echo. Casting the object to a string returns the Object #. Here is an example: The Script:

Re: [PHP-DEV] __toString() with strval() and settype()

2004-01-16 Thread Adam Maccabee Trachtenberg
On Fri, 16 Jan 2004, Sterling Hughes wrote: > > Adam Maccabee Trachtenberg wrote: > > >Anyone else care to chime in here? If we're really moving to RC1, I > > > > So to summarize that'd be > > echo, print, (string), strval() and settype() > > using __toString(), right? Sounds +1 to me. > > > > set

Re: [PHP-DEV] __toString() with strval() and settype()

2004-01-16 Thread Sterling Hughes
> Adam Maccabee Trachtenberg wrote: > >Anyone else care to chime in here? If we're really moving to RC1, I > > So to summarize that'd be > echo, print, (string), strval() and settype() > using __toString(), right? Sounds +1 to me. > settype() is a tricky one - i think it should fail for objects,

Re: [PHP-DEV] __toString() with strval() and settype()

2004-01-16 Thread Christian Schneider
Adam Maccabee Trachtenberg wrote: Anyone else care to chime in here? If we're really moving to RC1, I So to summarize that'd be echo, print, (string), strval() and settype() using __toString(), right? Sounds +1 to me. Right now strval() and settype() don't call __toString() but exit() does. - Chri

Re: [PHP-DEV] __toString() with strval() and settype()

2004-01-16 Thread Adam Maccabee Trachtenberg
Anyone else care to chime in here? If we're really moving to RC1, I think it makes sense to lock down as many language-level features as soon as possible. -adam On Thu, 15 Jan 2004, Adam Maccabee Trachtenberg wrote: > On Thu, 15 Jan 2004, Marcus Boerger wrote: > > Marcus -- > > > Thursday, Janua

Re: [PHP-DEV] __toString() with strval() and settype()

2004-01-15 Thread Adam Maccabee Trachtenberg
On Thu, 15 Jan 2004, Marcus Boerger wrote: Marcus -- > Thursday, January 15, 2004, 7:04:09 PM, you wrote: > > > Given an object, $obj, should strval($obj) and settype($obj, 'string') > > return $obj->__toString() if it exists? > > > They currently do not, but (string) $obj does. > > > Are these

Re: [PHP-DEV] __toString() with strval() and settype()

2004-01-15 Thread Marcus Boerger
Hello Adam, Thursday, January 15, 2004, 7:04:09 PM, you wrote: > Question: > Given an object, $obj, should strval($obj) and settype($obj, 'string') > return $obj->__toString() if it exists? > They currently do not, but (string) $obj does. > Are these three operations supposed to be identical,

[PHP-DEV] __toString() with strval() and settype()

2004-01-15 Thread Adam Maccabee Trachtenberg
Question: Given an object, $obj, should strval($obj) and settype($obj, 'string') return $obj->__toString() if it exists? They currently do not, but (string) $obj does. Are these three operations supposed to be identical, but with different syntax? Or are there other differences among them? -ada

Re: [PHP-DEV] __toString()

2003-12-15 Thread Christian Schneider
Marcus Boerger wrote: please try php-cvs version and report any problems (or dislike) as soon as possible. Neither a problem nor a dislike but I noted that __toString() is also called on exit($obj); Didn't check if there's more cases. - Chris -- PHP Internals - PHP Runtime Development Mailing L

Re: [PHP-DEV] __toString()

2003-12-15 Thread Marcus Boerger
Monday, December 15, 2003, 1:28:41 PM, you wrote: > Guys, > We have had this discussion before. There are two extremes to this issue. > The first is to always require the explicit __toString() call and the > second is to never require it and have all places in PHP whether it's > str_replace(),

Re: [PHP-DEV] __toString()

2003-12-15 Thread Marc Dembogurski
If you are going to create an interface, the most reasonable way of implementing that, is by not doing so much magic, and only permit the cast explicitly using (string)$obj for objects that implements the interface Stringable. So problems like: return $someobject . ""; could be solve

Re: [PHP-DEV] __toString()

2003-12-15 Thread Christian Schneider
Derick Rethans wrote: Why print and no echo? ;-) (Or was it the same again...) I hope print and echo will be treated the same. It looks like right now __toString() is never called automatically, I just updated from CVS and I get "Object id #1" for the example program. BTW: The example in Zend/ZE

Re: [PHP-DEV] __toString()

2003-12-15 Thread Sebastian Bergmann
Andi Gutmans wrote: > I think the right trade off is to automatically convert it with "print" > and with concatenation. I can live with that and my only concern was whether or not the above feature was removed or broken. -- Sebastian Bergmann http://sebastian-bergmann.de/ h

Re: [PHP-DEV] __toString()

2003-12-15 Thread Derick Rethans
On Mon, 15 Dec 2003, Andi Gutmans wrote: > I think the right trade off is to automatically convert it with "print" and > with concatenation. All the rest will require explicit calling. > It might not be your dream but it's a realistic approach. Why print and no echo? ;-) (Or was it the same again

Re: [PHP-DEV] __toString()

2003-12-15 Thread Markus Fischer
Hi Andi, On Mon, Dec 15, 2003 at 02:28:41PM +0200, Andi Gutmans wrote : > We have had this discussion before. There are two extremes to this issue. > The first is to always require the explicit __toString() call and the > second is to never require it and have all places in PHP whether it's

Re: [PHP-DEV] __toString()

2003-12-15 Thread Andi Gutmans
Guys, We have had this discussion before. There are two extremes to this issue. The first is to always require the explicit __toString() call and the second is to never require it and have all places in PHP whether it's str_replace(), (string)$obj, $arr[$obj] to automatically convert to string.

Re: [PHP-DEV] __toString()

2003-12-14 Thread Jon Parise
On Mon, Dec 15, 2003 at 01:48:39AM -0500, George Schlossnagle wrote: > >>interface Stringable { > >>public function toString(); > >>} > >> > >>And that way extensions and user code both can decide if they want to > >>give special treatment to objects that implement Stringable. > > > >I thi

Re: [PHP-DEV] __toString()

2003-12-14 Thread George Schlossnagle
On Dec 15, 2003, at 1:37 AM, Jon Parise wrote: On Mon, Dec 15, 2003 at 01:32:57AM -0500, George Schlossnagle wrote: Nope. How is it different or nicer than doing $defect->thrownException()->__toString()? It saves you 4 characters? If it doesn't do anything 'magical', why bother with the __? If y

Re: [PHP-DEV] __toString()

2003-12-14 Thread Jon Parise
On Mon, Dec 15, 2003 at 01:32:57AM -0500, George Schlossnagle wrote: > >Nope. How is it different or nicer than doing > >$defect->thrownException()->__toString()? > >It saves you 4 characters? > > If it doesn't do anything 'magical', why bother with the __? If you > always have to call it manu

Re: [PHP-DEV] __toString()

2003-12-14 Thread Jon Parise
On Mon, Dec 15, 2003 at 08:09:12AM +0200, Andi Gutmans wrote: > >Hopefully, this still works (don't have a recent PHP5 build to try): > > > >print (string)$defect->thrownException(); > > > >The explicit cast also addresses this case: > > > >print (string)$defect->thrownException() . "\n";

Re: [PHP-DEV] __toString()

2003-12-14 Thread George Schlossnagle
On Dec 15, 2003, at 1:09 AM, Andi Gutmans wrote: At 08:35 PM 12/14/2003 -0500, Jon Parise wrote: On Sun, Dec 14, 2003 at 03:41:10PM +0100, Sebastian Bergmann wrote: > > It is supported by "print" and for internal extensions such as > > SimpleXML which require this. > > How is it supported by "p

Re: [PHP-DEV] __toString()

2003-12-14 Thread Andi Gutmans
At 08:35 PM 12/14/2003 -0500, Jon Parise wrote: On Sun, Dec 14, 2003 at 03:41:10PM +0100, Sebastian Bergmann wrote: > > It is supported by "print" and for internal extensions such as > > SimpleXML which require this. > > How is it supported by "print" when > > print $defect->thrownException(

Re: [PHP-DEV] __toString()

2003-12-14 Thread Sebastian Bergmann
Jon Parise wrote: > Hopefully, this still works (don't have a recent PHP5 build to try): > > print (string)$defect->thrownException(); > > The explicit cast also addresses this case: > > print (string)$defect->thrownException() . "\n"; bar; } } $foo = new Foo; print $foo;

Re: [PHP-DEV] __toString()

2003-12-14 Thread Jon Parise
On Sun, Dec 14, 2003 at 03:41:10PM +0100, Sebastian Bergmann wrote: > > It is supported by "print" and for internal extensions such as > > SimpleXML which require this. > > How is it supported by "print" when > > print $defect->thrownException() > > does not work but the object returned

Re: [PHP-DEV] __toString()

2003-12-14 Thread Adam Maccabee Trachtenberg
On Sun, 14 Dec 2003, Sebastian Bergmann wrote: > How is it supported by "print" when > > print $defect->thrownException() > > does not work but the object returned from thrownException() has a > __toString() method? That's part of my problem with __toString, there's a difference between

Re: [PHP-DEV] __toString()

2003-12-14 Thread Cristiano Duarte
Em Sun, 14 Dec 2003 15:41:10 +0100, Sebastian Bergmann escreveu: > Andi Gutmans wrote: >> It is supported by "print" and for internal extensions such as >> SimpleXML which require this. > > How is it supported by "print" when > > print $defect->thrownException() > > does not work but th

Re: [PHP-DEV] __toString()

2003-12-14 Thread Sebastian Bergmann
Andi Gutmans wrote: > It is supported by "print" and for internal extensions such as > SimpleXML which require this. How is it supported by "print" when print $defect->thrownException() does not work but the object returned from thrownException() has a __toString() method? -- Sebasti

Re: [PHP-DEV] __toString()

2003-12-14 Thread Sebastian Bergmann
Derick Rethans wrote: > Actually, you should as __ is reserved for magic methods... Until recently __toString() was a magic method. -- Sebastian Bergmann http://sebastian-bergmann.de/ http://phpOpenTracker.de/ Das Buch zu PHP 5: http://professionelle-softwareentwicklung-mit-

Re: [PHP-DEV] __toString()

2003-12-14 Thread Andi Gutmans
It is supported by "print" and for internal extensions such as SimpleXML which require this. Also in Java toString() isn't called automagically in every place so I wouldn't call it useless. Andi At 08:56 AM 12/14/2003 +0100, Sebastian Bergmann wrote: The following code from PHPUnit stopped wo

Re: [PHP-DEV] __toString()

2003-12-14 Thread Marcus Boerger
Hello Sebastian, Sunday, December 14, 2003, 1:52:38 PM, you wrote: > Marcus Boerger wrote: >> We found out that calling __toString() automatically in any place in >> the executor has unsolveable problems right now (ask Andi for details). > So if __toString() is no longer automatically called w

Re: [PHP-DEV] __toString()

2003-12-14 Thread Derick Rethans
On Sun, 14 Dec 2003, Sebastian Bergmann wrote: > Marcus Boerger wrote: > > We found out that calling __toString() automatically in any place in > > the executor has unsolveable problems right now (ask Andi for details). > > So if __toString() is no longer automatically called what is its > pur

Re: [PHP-DEV] __toString()

2003-12-14 Thread Sebastian Bergmann
Marcus Boerger wrote: > We found out that calling __toString() automatically in any place in > the executor has unsolveable problems right now (ask Andi for details). So if __toString() is no longer automatically called what is its purpose then? I mean, if I have to explicitly call it via -

Re: [PHP-DEV] __toString()

2003-12-14 Thread Marcus Boerger
Hello Sebastian, Sunday, December 14, 2003, 8:56:15 AM, you wrote: > The following code from PHPUnit stopped working after the recent changes > to __toString() > protected function printDefectTrace(PHPUnit_Framework_TestFailure > $defect) { > print $defect->thrownException

[PHP-DEV] __toString()

2003-12-14 Thread Sebastian Bergmann
The following code from PHPUnit stopped working after the recent changes to __toString() protected function printDefectTrace(PHPUnit_Framework_TestFailure $defect) { print $defect->thrownException() . "\n"; print PHPUnit_Runner_BaseTestRunner::getFilteredStack(