Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?PHP
- NAMESPACE ILLI\Bug;
- INTERFACE Foo {}
- CLASS Instance IMPLEMENTS Foo
- {
- private static $instances = [];
- public static function getInstance()
- {
- $thread = get_called_class();
- if(TRUE === array_key_exists($thread, self::$instances))
- return self::$instances[$thread]; // break point
- self::$instances[$thread] = new self;
- return self::$instances[$thread];
- }
- private static $counter = 0;
- private function __construct()
- {
- static::$counter++;
- if(static::$counter < 4)
- {
- //var_dump(self::getInstance() instanceOf Foo); // trigger infinity... why?
- var_dump(self::getInstance()); // void (displays nothing)
- var_dump(self::$instances); // void (displays nothing) when calling self::getInstance()
- return;
- }
- var_dump(self::$instances);
- var_dump(debug_backtrace(0, 4));
- die();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement