Why a such ugly thing :
$foo =& Foo::construct($options);
if (PEAR::isError($foo)) { ... }
when you could do :
$foo = new Foo($options);
if ($foo->hasError()) { ... }
?
It's very subjective, of which is better,
a) will probably throw a "no such method error" at some point,
b) you are more likely to catch a error in a later method call, indicating that the object was not constructed properly..
I don't think it makes anything clearer. My Idea was to make some base class
provide this sort of features. See, class Foo extends SomeBaseClass. I must
confess I thought about the PEAR base class itself...
But, well, as Lukas stated, the most stylish is :
try {
$foo = new Foo($options);
}
catch (InvalidOption $e) {
...
}
It's a very personal decision, but i really dont like the idea of assigments throwing errors too often, it makes the process of reading code, and guessing where you need to catch exceptions a little more complex: (eg. only method calls need to be try'd, or almost anything could throw an exception?)
Regards
Alan
-- og