mirror of
https://github.com/opencultureconsulting/php-basics.git
synced 2025-03-09 00:00:38 +01:00
Make singleton constructor private
This commit is contained in:
parent
0a449fbb4c
commit
424faf83a0
@ -31,12 +31,12 @@ trait Singleton
|
||||
/**
|
||||
* Holds the singleton instance.
|
||||
*
|
||||
* @access protected
|
||||
* @access private
|
||||
* @static
|
||||
*
|
||||
* @var self
|
||||
*/
|
||||
protected static $singleton;
|
||||
private static ?self $singleton;
|
||||
|
||||
/**
|
||||
* Get a singleton instance of this class.
|
||||
@ -57,13 +57,13 @@ trait Singleton
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a singleton class, thus the constructor is protected.
|
||||
* This is a singleton class, thus the constructor is private.
|
||||
* (Get an instance of this class by calling self::getInstance())
|
||||
*
|
||||
* @access protected
|
||||
* @access private
|
||||
* @abstract
|
||||
*/
|
||||
abstract protected function __construct();
|
||||
abstract private function __construct();
|
||||
|
||||
/**
|
||||
* This is a singleton class, thus cloning is prohibited.
|
||||
|
Loading…
x
Reference in New Issue
Block a user