1 | <?php |
||
28 | trait SingletonTrait |
||
29 | { |
||
30 | /** |
||
31 | * Singletons' pool |
||
32 | * |
||
33 | * Use array here to make Singleton class INHERITABLE! |
||
34 | * |
||
35 | * @var SingletonInstance[] |
||
36 | * @access private |
||
37 | * @static |
||
38 | */ |
||
39 | private static $singletons = []; |
||
40 | |||
41 | /** |
||
42 | * {@inheritDoc} |
||
43 | */ |
||
44 | public static function getInstance()/*# : SingletonInterface */ |
||
52 | |||
53 | /** |
||
54 | * no instantiation from outside |
||
55 | * |
||
56 | * @return void |
||
|
|||
57 | * @access protected |
||
58 | * @final |
||
59 | */ |
||
60 | protected function __construct() |
||
63 | |||
64 | /** |
||
65 | * prevent from being cloned. |
||
66 | * |
||
67 | * @return void |
||
68 | * @access public |
||
69 | * @final |
||
70 | */ |
||
71 | final public function __clone() |
||
75 | |||
76 | /** |
||
77 | * prevent from being unserialized. |
||
78 | * |
||
79 | * @return void |
||
80 | * @access public |
||
81 | * @final |
||
82 | */ |
||
83 | final public function __wakeup() |
||
87 | } |
||
88 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.