summaryrefslogtreecommitdiff
path: root/Zend/tests/bug68652.phpt
blob: 8e54af2e3485840942b6cef2028638fe709b4325 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
--TEST--
Bug #68652 (segmentation fault in destructor)
--FILE--
<?php
class Foo {

    private static $instance;
    public static function getInstance() {
        if (isset(self::$instance)) {
            return self::$instance;
        }
        return self::$instance = new self();
    }

    public function __destruct() {
        Bar::getInstance();
    }
}

class Bar {

    private static $instance;
    public static function getInstance() {
        if (isset(self::$instance)) {
            return self::$instance;
        }
        return self::$instance = new self();
    }

    public function __destruct() {
        if (!isset(self::$instance)) return;
        Foo::getInstance();
    }
}


$foo = new Foo();
?>
--EXPECTF--
Fatal error: Uncaught Error: Access to undeclared static property: Bar::$instance in %sbug68652.php:%d
Stack trace:
#0 %s(%d): Bar::getInstance()
#1 [internal function]: Foo->__destruct()
#2 {main}
  thrown in %sbug68652.php on line %d