Re: Re: Subject/Observer design pattern in PEAR

From: Date: Fri, 23 Jul 2004 01:01:13 +0000
Subject: Re: Re: Subject/Observer design pattern in PEAR
References: 1 2 3 4 5 6 7  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-32261@lists.php.net to get a copy of this message
Heino H. Gehlsen wrote:
I agree -- definitely classhints would be the way to go here. That's really the nice thing about using interfaces with PHP5.
So do I, but I'm not sure if it's time to use them yet. (?)
I think it's ok for the error to be fatal, because code must implement the interface (no need to extend a base class or anything). The thing that needs improvement is that error itself & that is something for PHP internals folks to improve. (it has come up & there was support for adding a reference to the calling code, so I anticipate that this will get fixed)
So in the near future the scripts won't always have to die on us should we de the unthinkable?
No, they'll still die, but it would be ideal if the error message indicated the line of the calling code (perhaps in addition to the line of the method). That was suggested at one point on internals@ & seemed to get favorable response. It makes sense to have a fatal error, though, because the whole point is that the one class know what to expect from the other class. I.e. it knows which methods are avaiable & what signature they use. Eventually you will get a fatal error anyway if you pass in a class that doesn't implement the interface (e.g. method doesn't exist error). If the class does actually implement the interface then there's no reason not to have it declare that it implements it -- and no reason not to use the typehints. Typehints are very nice. Currently the only time when they cannot be used is when the parameter is optional. That will [hopefully] be fixed with PHP 5.1. Hans

« previous php.pear.dev (#32261) next »