A Better WordPress Singleton

class PluginClass
{
public static $instance = null;
public static function init()
{
if ( null === self::$instance ) {
self::$instance = new PluginClass();
self::$instance->boot();
}
return self::$instance;
}
protected function __construct()
{
// Startup
}
protected function boot()
{
// Boot
}
}
PluginClass::init();
normal-singleton-and-boot.php
class PluginClass
{
protected static $instance = null;
public function __construct($file)
{
if (static::$instance !== null) {
throw new Exception;
}
static::$instance = $this;
}
public static function get()
{
return static::$instance;
}
}
improved-singleton.php
call_user_func(array(new PluginClass(__FILE__), 'boot'));
improved-boot.php