Re: simple interface standard?
| From: | Bertrand Mansion | Date: | Mon, 30 Aug 2004 09:13:52 +0000 |
| Subject: | Re: simple interface standard? | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-33049@lists.php.net to get a copy of this message | ||
Greg Beaver wrote:
>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>>
I would use Interface instead of simply "I" as some suggested because that's clearer
to read and identify. But I would use it as a postfix like this:
PEAR_Something_Interface
>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
> }
>}
NB: Personally, I find it a bit silly to use instanceof for an interface when a class actually
*implements* one or more interfaces, but apparently PHP5 allows it...
I think I will wait until I see some code before giving you an opinion about this. Is this going to
duplicate PEAR_ErrorStack features for PHP5 PEAR_Exception only ?
Bertrand Mansion
Mamasam