[dev] [cvs] commit: framework/Image/Image/Effect/im round_corners.php

Chuck Hagenbuch chuck at horde.org
Fri Nov 9 00:13:10 UTC 2007


Quoting Michael Rubinsky <mike at theupstairsroom.com>:

>> Wouldn't it be better to check if a method exists, instead of checking
>> version numbers?
>
> Yes, but $this->_image->_imagick is a proxy class...->roundCorners()  
>  would go to __call().  A pear error would be returned from __call()  
> if  the method doesn't exist, but a pear error could be returned for  
> a  number of other reasons as well, so it seemed cleaner to check  
> for the  version number.  I guess the other option would be to add a  
>  methodExists() method to the proxy...but I figured I already have  
> the  getVersion function since we need it for other checks anyway.

I think we should add the methodExists (or perhaps hasCapability()  
like some of our other drivers have) and use it when what is in doubt  
is whether a method exists. If something is truly version dependent,  
then use the version check. Even though the version check might work  
for this, checking for something other than what you really mean can  
cause trouble down the road (look at javascript browser sniffing...)

If you don't want the extra method you can just return a different  
error from __call() (using an error code) if the method doesn't exist.

-chuck


More information about the dev mailing list