simple interface standard?
| From: | Greg Beaver | Date: | Sun, 29 Aug 2004 22:57:31 +0000 |
| Subject: | simple interface standard? | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-33039@lists.php.net to get a copy of this message | ||
Hi,
Would there be an objection to specfying a simple standard for interfaces?
<<BEGIN STANDARD>>
Mypackage.php
Mypackage/Interface.php
would be a sample structure, so
PEAR.php
PEAR/Interface.php
would contain the PEAR interfaces.
Interface names would follow the convention that already exists:
interface Mypackage_InterfaceSomething
{
}
or,
interface PEAR_InterfaceSomething
{
}
<<END STANDARD>>
This way, I could solve all of my concerns about PEAR_Exception with an interface like so:
interface PEAR_InterfaceMultiError extends SPL_Iterator
{
public function errorCount();
public function addError(PEAR_Exception $e);
public function addWarning(...);
public function iterator functions that allow foreach/while
}
and then users can do this:
if ($e instanceof PEAR_InterfaceMultiError) {
foreach ($e as $error) {
// do stuff
}
}
and then count on a consistent API, regardless of how it is actually implemented in extended exception classes.
Greg