2007-09-29 15:28:34 +08:00
|
|
|
--TEST--
|
2018-10-15 00:03:31 +08:00
|
|
|
ZE2 Late Static Binding with exceptions
|
2007-09-29 15:28:34 +08:00
|
|
|
--FILE--
|
|
|
|
<?php
|
|
|
|
function foo() {
|
|
|
|
B::throwException();
|
|
|
|
}
|
|
|
|
class C {
|
|
|
|
public static function bla() {
|
|
|
|
B::throwException();
|
|
|
|
}
|
|
|
|
public static function getException() {
|
|
|
|
return new Exception();
|
2018-09-17 01:16:42 +08:00
|
|
|
|
2007-09-29 15:28:34 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
class A {
|
|
|
|
|
|
|
|
public static function throwException_after() {
|
|
|
|
C::bla();
|
|
|
|
}
|
|
|
|
public static function throwException() {
|
|
|
|
throw C::getException();
|
|
|
|
}
|
|
|
|
public static function test() {
|
|
|
|
static::who();
|
|
|
|
}
|
|
|
|
public static function who() {
|
|
|
|
echo "A\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function mycatch() {
|
|
|
|
try {
|
|
|
|
static::who();
|
|
|
|
B::throwException_after();
|
|
|
|
} catch(Exception $e) {
|
|
|
|
static::who();
|
|
|
|
A::test();
|
|
|
|
static::who();
|
|
|
|
B::test();
|
|
|
|
static::who();
|
|
|
|
|
|
|
|
self::simpleCatch();
|
|
|
|
static::who();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function simpleCatch() {
|
|
|
|
try {
|
|
|
|
static::who();
|
|
|
|
throw new Exception();
|
|
|
|
} catch (Exception $e) {
|
|
|
|
static::who();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class B extends A {
|
|
|
|
public static function who() {
|
|
|
|
echo "B\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
echo "via A:\n";
|
|
|
|
A::myCatch();
|
|
|
|
echo "via B:\n";
|
|
|
|
B::myCatch();
|
|
|
|
?>
|
2018-02-19 16:59:41 +08:00
|
|
|
--EXPECT--
|
2007-09-29 15:28:34 +08:00
|
|
|
via A:
|
|
|
|
A
|
|
|
|
A
|
|
|
|
A
|
|
|
|
A
|
|
|
|
B
|
|
|
|
A
|
|
|
|
A
|
|
|
|
A
|
|
|
|
A
|
|
|
|
via B:
|
|
|
|
B
|
|
|
|
B
|
|
|
|
A
|
|
|
|
B
|
|
|
|
B
|
|
|
|
B
|
2008-07-24 17:42:18 +08:00
|
|
|
B
|
|
|
|
B
|
2007-09-29 15:28:34 +08:00
|
|
|
B
|