2011-11-27 11:20:35 +01:00
|
|
|
Try/catch
|
|
|
|
-----
|
|
|
|
<?php
|
|
|
|
|
2012-09-07 18:06:11 +02:00
|
|
|
try {
|
|
|
|
doTry();
|
2011-11-27 11:20:35 +01:00
|
|
|
} catch (A $b) {
|
2012-09-07 18:06:11 +02:00
|
|
|
doCatchA();
|
2011-11-27 11:20:35 +01:00
|
|
|
} catch (B $c) {
|
2012-09-07 18:06:11 +02:00
|
|
|
doCatchB();
|
|
|
|
} finally {
|
|
|
|
doFinally();
|
2011-11-27 11:20:35 +01:00
|
|
|
}
|
2012-09-07 18:06:11 +02:00
|
|
|
|
|
|
|
// no finally
|
|
|
|
try { }
|
|
|
|
catch (A $b) { }
|
|
|
|
|
|
|
|
// no catch
|
|
|
|
try { }
|
|
|
|
finally { }
|
|
|
|
|
2011-11-27 11:20:35 +01:00
|
|
|
-----
|
|
|
|
array(
|
|
|
|
0: Stmt_TryCatch(
|
|
|
|
stmts: array(
|
2012-09-07 18:06:11 +02:00
|
|
|
0: Expr_FuncCall(
|
|
|
|
name: Name(
|
|
|
|
parts: array(
|
|
|
|
0: doTry
|
|
|
|
)
|
|
|
|
)
|
|
|
|
args: array(
|
|
|
|
)
|
|
|
|
)
|
2011-11-27 11:20:35 +01:00
|
|
|
)
|
|
|
|
catches: array(
|
|
|
|
0: Stmt_Catch(
|
2016-07-22 15:40:00 +02:00
|
|
|
types: array(
|
|
|
|
0: Name(
|
|
|
|
parts: array(
|
|
|
|
0: A
|
|
|
|
)
|
2011-11-27 11:20:35 +01:00
|
|
|
)
|
|
|
|
)
|
|
|
|
var: b
|
|
|
|
stmts: array(
|
2012-09-07 18:06:11 +02:00
|
|
|
0: Expr_FuncCall(
|
|
|
|
name: Name(
|
|
|
|
parts: array(
|
|
|
|
0: doCatchA
|
|
|
|
)
|
|
|
|
)
|
|
|
|
args: array(
|
|
|
|
)
|
|
|
|
)
|
2011-11-27 11:20:35 +01:00
|
|
|
)
|
|
|
|
)
|
|
|
|
1: Stmt_Catch(
|
2016-07-22 15:40:00 +02:00
|
|
|
types: array(
|
|
|
|
0: Name(
|
|
|
|
parts: array(
|
|
|
|
0: B
|
|
|
|
)
|
2011-11-27 11:20:35 +01:00
|
|
|
)
|
|
|
|
)
|
|
|
|
var: c
|
|
|
|
stmts: array(
|
2012-09-07 18:06:11 +02:00
|
|
|
0: Expr_FuncCall(
|
|
|
|
name: Name(
|
|
|
|
parts: array(
|
|
|
|
0: doCatchB
|
|
|
|
)
|
|
|
|
)
|
|
|
|
args: array(
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
2016-07-25 14:25:04 +02:00
|
|
|
finally: Stmt_Finally(
|
|
|
|
stmts: array(
|
|
|
|
0: Expr_FuncCall(
|
|
|
|
name: Name(
|
|
|
|
parts: array(
|
|
|
|
0: doFinally
|
|
|
|
)
|
|
|
|
)
|
|
|
|
args: array(
|
2012-09-07 18:06:11 +02:00
|
|
|
)
|
2011-11-27 11:20:35 +01:00
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
2012-09-07 18:06:11 +02:00
|
|
|
1: Stmt_TryCatch(
|
|
|
|
stmts: array(
|
|
|
|
)
|
|
|
|
catches: array(
|
|
|
|
0: Stmt_Catch(
|
2016-07-22 15:40:00 +02:00
|
|
|
types: array(
|
|
|
|
0: Name(
|
|
|
|
parts: array(
|
|
|
|
0: A
|
|
|
|
)
|
2012-09-07 18:06:11 +02:00
|
|
|
)
|
|
|
|
)
|
|
|
|
var: b
|
|
|
|
stmts: array(
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
2016-07-25 14:25:04 +02:00
|
|
|
finally: null
|
2016-03-09 18:57:16 +01:00
|
|
|
comments: array(
|
|
|
|
0: // no finally
|
|
|
|
)
|
2012-09-07 18:06:11 +02:00
|
|
|
)
|
|
|
|
2: Stmt_TryCatch(
|
|
|
|
stmts: array(
|
|
|
|
)
|
|
|
|
catches: array(
|
|
|
|
)
|
2016-07-25 14:25:04 +02:00
|
|
|
finally: Stmt_Finally(
|
|
|
|
stmts: array(
|
|
|
|
)
|
2012-09-07 18:06:11 +02:00
|
|
|
)
|
2016-03-09 18:57:16 +01:00
|
|
|
comments: array(
|
|
|
|
0: // no catch
|
|
|
|
)
|
2012-09-07 18:06:11 +02:00
|
|
|
)
|
2011-11-27 11:20:35 +01:00
|
|
|
)
|