| 1 | <?php |
||
| 9 | class Singleton |
||
| 10 | { |
||
| 11 | |||
| 12 | private static $instance = array(); |
||
| 13 | /** |
||
| 14 | * @var float $loadTs |
||
| 15 | */ |
||
| 16 | protected $loadTs = 0; |
||
| 17 | /** |
||
| 18 | * @var float $loadMem |
||
| 19 | */ |
||
| 20 | protected $loadMem = 0; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @var bool Flag thath indicates that actual class is already loaded |
||
| 24 | */ |
||
| 25 | protected $loaded = false; |
||
| 26 | |||
| 27 | public function __construct() |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Singleton instance generator |
||
| 33 | * @return $this |
||
| 34 | */ |
||
| 35 | 1 | public static function getInstance() |
|
| 44 | |||
| 45 | /** |
||
| 46 | * Instance generator alias |
||
| 47 | * @return $this |
||
| 48 | */ |
||
| 49 | public static function create() |
||
| 53 | |||
| 54 | /** |
||
| 55 | * Magic setter |
||
| 56 | * @param string $variable |
||
| 57 | * @param mixed $value |
||
| 58 | */ |
||
| 59 | public function __set($variable, $value) |
||
| 63 | |||
| 64 | /** |
||
| 65 | * Magic getter |
||
| 66 | * @param string $variable |
||
| 67 | * @return mixed |
||
| 68 | */ |
||
| 69 | public function __get($variable) |
||
| 73 | |||
| 74 | /** |
||
| 75 | * Prevent the instance from being cloned |
||
| 76 | * @return void |
||
| 77 | */ |
||
| 78 | private function __clone() {} |
||
| 79 | |||
| 80 | public function __toString() |
||
| 85 | } |
||
| 86 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.