Christian Schneider wrote:
abstract static protected function __construct(CrazySettings $s,
CrazyView $v);
<snip>
Static doesn't really make sense as interfaces as object instance related.
Well actually the constructor is implicitly a static function too. The
whole allowing/disallowing constructor in interfaces question is in
principle exactly the same as allowing static methods in interfaces.
Anyway, I see only one use case for interface constructors:
interace IConstructableFromBananas {
function __construct(Bananas $b);
}
function thingsThatUseBananasFactory($className) {
$class = new ReflectionClass($className);
if (!$class->implementsInterface("IConstructableFromBananas")) {
trigger_error("$className doesn't implement
IConstructableFromBananas", E_USER_ERROR);
}
return new $className(BananaFactory::getBananas());
}
I'm not so sure whether this is useful to anyone, but I don't see it
hurting anyone either.
Ants
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php