PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?
class DomainsSess implements ISess {
protected function __construct () {
// code
}
static public function instantiate () {
return new DomainsSess;
}
}
// this should create a new instance
$domains_session = DomainsSess::instantiate();
// this should return an error
$domains_session = new DomainsSess;
?>
I want every instance of this object created using the instantiate() method, and not using the new operator from outside the class.
So if the inteface constructor has a protected visibility, it should be accessible and overridable from a sub-class and not from the outside.
It seems that php doesn't allow the constructor on an interface to be have protected visibility.
A class that implements this type of interface (protected constructor) can instantiate objects from within a static method.
So it would seem possible to have a protected constructor on an interface.
Anybody know why php won't allow it?