Re: [PHP-DEV] ReflectionClass::getMethod()

2004-12-30 Thread Sebastian Bergmann
Andi Gutmans wrote: > I don't feel like arguing about it because hasMethod() is good enough > for me. Do we not need hasProperty() (for getProperty()) and hasConstant() (for getConstant()), too? -- Sebastian Bergmann http://www.sebastian-bergmann.de/ GnuPG Key: 0xB85B5D69

Re: [PHP-DEV] ReflectionClass::getMethod()

2004-12-29 Thread Andi Gutmans
And now the attachment. At 11:31 AM 12/25/2004 +0100, Sebastian Bergmann wrote: [EMAIL PROTECTED] wrote: > Why not just returning null when a method does not exist? > Actually CALLING a non-existing method should be treated as an error... Because try { $class = new ReflectionClass($this

Re: [PHP-DEV] ReflectionClass::getMethod()

2004-12-29 Thread Andi Gutmans
Sebastian, I don't feel like arguing about it because hasMethod() is good enough for me. Look at the attached example. It should make you understand why throwing an exception *without* having something like hasMethod() is very inefficient. Exceptions should be used for error situations. If a refl

Re: [PHP-DEV] ReflectionClass::getMethod()

2004-12-27 Thread Sebastian Bergmann
Christian Schneider wrote: > You don't have to treat everything like a nail just because you have a > hammer. You are right. And would you (or someone else) have spoken up between the time I committed the change and the release of PHP 5.0.3 I would have been okay with reverting. But now the c

Re: [PHP-DEV] ReflectionClass::getMethod()

2004-12-27 Thread Christian Schneider
Sebastian Bergmann wrote: The Reflection API was introduced at the same time as exceptions. It therefore makes perfect sense to make consistent use of exception in the Reflection API. You don't have to treat everything like a nail just because you have a hammer. So the people who know how to

Re: [PHP-DEV] ReflectionClass::getMethod()

2004-12-25 Thread [EMAIL PROTECTED]
This doesn't really clear it out. I can either use the "cleaner" method, and an exception would be raised when I'd try to call NULL(), or, have the OPTION to check whether it's NULL before calling it. IMHO It's much more consistent and clean. You STILL can use exceptions the way you did, and in AD

Re: [PHP-DEV] ReflectionClass::getMethod()

2004-12-25 Thread Sebastian Bergmann
[EMAIL PROTECTED] wrote: > Why not just returning null when a method does not exist? > Actually CALLING a non-existing method should be treated as an error... Because try { $class = new ReflectionClass($this); $method = $class->getMethod($this->name); } catch (Reflection

Re: [PHP-DEV] ReflectionClass::getMethod()

2004-12-25 Thread Sebastian Bergmann
Christian Schneider wrote: >> Calling getMethod() for a method that does not exist is an error and >> should be consistently treated as such by raising an exception. > > I disagree. The same could be said for getenv(). The Reflection API was introduced at the same time as exceptions. It therefo

Re: [PHP-DEV] ReflectionClass::getMethod()

2004-12-24 Thread [EMAIL PROTECTED]
Why not just returning null when a method does not exist? Actually CALLING a non-existing method should be treated as an error... On Fri, 24 Dec 2004 18:47:26 +0100, Christian Schneider <[EMAIL PROTECTED]> wrote: > Sebastian Bergmann wrote: > > You assume wrong. My point is that you should not u

Re: [PHP-DEV] ReflectionClass::getMethod()

2004-12-24 Thread Christian Schneider
Sebastian Bergmann wrote: You assume wrong. My point is that you should not use getMethod() when you do not know whether or not the method exists. Ok, let's look at the options then: 5.0 - getMethods() [sure, you could probably use clever tricks to make this shorter but the general clumsiness wi

Re: [PHP-DEV] ReflectionClass::getMethod()

2004-12-24 Thread Sebastian Bergmann
Christian Schneider wrote: > I assume that Sebastian would use something along the lines of You assume wrong. My point is that you should not use getMethod() when you do not know whether or not the method exists. If you do not know whether or not the method exists use getMethods() in PHP 5.0

Re: [PHP-DEV] ReflectionClass::getMethod()

2004-12-24 Thread Marcus Boerger
Hello Derick, in 5.0 the solution is to use getMethods() and look for it. Since that is not the best to do and not what we really want to i'll commit johannes' patch for hasMethod() later today. marcus Friday, December 24, 2004, 1:00:44 PM, you wrote: > On Fri, 24 Dec 2004, Sebastian Bergmann

Re: [PHP-DEV] ReflectionClass::getMethod()

2004-12-24 Thread Christian Schneider
Derick Rethans wrote: I think it doesn't make sense if there is no method to actually check if it's there. Now you start throwing exeptions without having a way to avoid it. THAT is crazy. I assume that Sebastian would use something along the lines of try { $reflectionClass->getMethod("foo"

Re: [PHP-DEV] ReflectionClass::getMethod()

2004-12-24 Thread Sebastian Bergmann
Derick Rethans wrote: > THAT is crazy. Throwing away consistency is crazy, too. -- Sebastian Bergmann http://www.sebastian-bergmann.de/ GnuPG Key: 0xB85B5D69 / 27A7 2B14 09E4 98CD 6277 0E5B 6867 C514 B85B 5D69 -- PHP Internals - PHP Runtime Development Mailing List To uns

Re: [PHP-DEV] ReflectionClass::getMethod()

2004-12-24 Thread Derick Rethans
On Fri, 24 Dec 2004, Sebastian Bergmann wrote: > Andi Gutmans wrote: > > Sebastian, throwing an exception is relatively slow and cumbersome and > > sucks if you want to do something like a Delegation model and run > > through objects and check if a method can be called. Having exceptions > > throw

Re: [PHP-DEV] ReflectionClass::getMethod()

2004-12-24 Thread Sebastian Bergmann
Andi Gutmans wrote: > Sebastian, throwing an exception is relatively slow and cumbersome and > sucks if you want to do something like a Delegation model and run > through objects and check if a method can be called. Having exceptions > thrown each time the object doesn't have the method is crazy.

Re: [PHP-DEV] ReflectionClass::getMethod()

2004-12-23 Thread Andi Gutmans
Adding hasMethod() sounds good to me. Sebastian, throwing an exception is relatively slow and cumbersome and sucks if you want to do something like a Delegation model and run through objects and check if a method can be called. Having exceptions thrown each time the object doesn't have the metho

Re: [PHP-DEV] ReflectionClass::getMethod()

2004-12-23 Thread Sebastian Bergmann
Timm Friebe wrote: > > I think we could all agree on > > bool hasMethod(string $name) > > (and not changing getMethod()) though, right? Yes, although I do not think that hasMethod() is really needed. -- Sebastian Bergmann http://www.sebastian-bergmann.de/ GnuPG Key: 0

Re: [PHP-DEV] ReflectionClass::getMethod()

2004-12-23 Thread Timm Friebe
On Thu, 2004-12-23 at 07:43 +0100, Sebastian Bergmann wrote: > Andi Gutmans wrote: > > Exceptions should be thrown for errors. > > And trying to get a method that does not exist is an error. ...which is fine, but without an elegant way of checking if that method exists I don't think it should be

Re: [PHP-DEV] ReflectionClass::getMethod()

2004-12-22 Thread Marcus Boerger
Hello Timm, Thursday, December 23, 2004, 1:06:01 AM, you wrote: > On Wed, 2004-12-22 at 14:28 -0800, Andi Gutmans wrote: >> Hi, >> >> It seems that in the past few months ReflectionClass::getMethod() was >> changed to throw an Exception if the method doesn't exist. > -- snip -- > revision 1.11

Re: [PHP-DEV] ReflectionClass::getMethod()

2004-12-22 Thread Sebastian Bergmann
Sebastian Bergmann wrote: > methods, but I think it is better to use the same error signalling in - methods, + exception, -- Sebastian Bergmann http://www.sebastian-bergmann.de/ GnuPG Key: 0xB85B5D69 / 27A7 2B14 09E4 98CD 6277 0E5B 6867 C514 B85B 5D69 -- PHP Internals -

Re: [PHP-DEV] ReflectionClass::getMethod()

2004-12-22 Thread Sebastian Bergmann
Andi Gutmans wrote: > Exceptions should be thrown for errors. And trying to get a method that does not exist is an error. > Can anyone shed some light on this? Why was this changed? To make consistent use of ReflectionException, IIRC. For instance, the following code throws an Reflect

Re: [PHP-DEV] ReflectionClass::getMethod()

2004-12-22 Thread Andi Gutmans
Thanks Timm. Sebastian, what do you think? Andi At 01:06 AM 12/23/2004 +0100, Timm Friebe wrote: On Wed, 2004-12-22 at 14:28 -0800, Andi Gutmans wrote: > Hi, > > It seems that in the past few months ReflectionClass::getMethod() was > changed to throw an Exception if the method doesn't exist. -- sni

Re: [PHP-DEV] ReflectionClass::getMethod()

2004-12-22 Thread Timm Friebe
On Wed, 2004-12-22 at 14:28 -0800, Andi Gutmans wrote: > Hi, > > It seems that in the past few months ReflectionClass::getMethod() was > changed to throw an Exception if the method doesn't exist. -- snip -- revision 1.113 date: 2004/07/19 19:14:10; author: sebastian; state: Exp; lines: +9 -5

[PHP-DEV] ReflectionClass::getMethod()

2004-12-22 Thread Andi Gutmans
Hi, It seems that in the past few months ReflectionClass::getMethod() was changed to throw an Exception if the method doesn't exist. I don't understand the reasoning because as it's a reflection API I would expect it to return false and not an exception. Exceptions should be thrown for errors.