xref: /PHP-7.0/Zend/tests/lsb_015.phpt (revision feb85801)
1--TEST--
2ZE2 Late Static Binding with exceptions
3--FILE--
4<?php
5function foo() {
6    B::throwException();
7}
8class C {
9    public static function bla() {
10        B::throwException();
11    }
12    public static function getException() {
13        return new Exception();
14
15    }
16}
17class A {
18
19    public static function throwException_after() {
20        C::bla();
21    }
22    public static function throwException() {
23        throw C::getException();
24    }
25    public static function test() {
26        static::who();
27    }
28    public static function who() {
29        echo "A\n";
30    }
31
32    public static function mycatch() {
33        try {
34            static::who();
35            B::throwException_after();
36        } catch(Exception $e) {
37            static::who();
38            A::test();
39            static::who();
40            B::test();
41            static::who();
42
43            self::simpleCatch();
44            static::who();
45        }
46    }
47
48    public static function simpleCatch() {
49        try {
50            static::who();
51            throw new Exception();
52        } catch (Exception $e) {
53            static::who();
54        }
55    }
56}
57
58class B extends A {
59    public static function who() {
60        echo "B\n";
61    }
62
63}
64
65echo "via A:\n";
66A::myCatch();
67echo "via B:\n";
68B::myCatch();
69?>
70==DONE==
71--EXPECTF--
72via A:
73A
74A
75A
76A
77B
78A
79A
80A
81A
82via B:
83B
84B
85A
86B
87B
88B
89B
90B
91B
92==DONE==
93