Hi Sebastian,
This is not really a good example as the getInstance() method alone is
> not sufficient for a reusable implementation of the Singleton pattern.
>
Yes, it was just a pseudo-code and not a true singleton implementation.
> A trait for a reusable implementation of the Singleton pattern should
> look more like
> ...
> which of course does not work as traits are stateless and
>
Would it work if instance is saved inside a local static var like:
public static function getInstance() {
static $instance = NULL;
if (is_null($instance)) {
$instance = new self();
}
return $instance;
}
/Simas