tryCatch.test 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. Try/catch
  2. -----
  3. <?php
  4. try {
  5. doTry();
  6. } catch (A $b) {
  7. doCatchA();
  8. } catch (B $c) {
  9. doCatchB();
  10. } finally {
  11. doFinally();
  12. }
  13. // no finally
  14. try { }
  15. catch (A $b) { }
  16. // no catch
  17. try { }
  18. finally { }
  19. -----
  20. array(
  21. 0: Stmt_TryCatch(
  22. stmts: array(
  23. 0: Expr_FuncCall(
  24. name: Name(
  25. parts: array(
  26. 0: doTry
  27. )
  28. )
  29. args: array(
  30. )
  31. )
  32. )
  33. catches: array(
  34. 0: Stmt_Catch(
  35. type: Name(
  36. parts: array(
  37. 0: A
  38. )
  39. )
  40. var: b
  41. stmts: array(
  42. 0: Expr_FuncCall(
  43. name: Name(
  44. parts: array(
  45. 0: doCatchA
  46. )
  47. )
  48. args: array(
  49. )
  50. )
  51. )
  52. )
  53. 1: Stmt_Catch(
  54. type: Name(
  55. parts: array(
  56. 0: B
  57. )
  58. )
  59. var: c
  60. stmts: array(
  61. 0: Expr_FuncCall(
  62. name: Name(
  63. parts: array(
  64. 0: doCatchB
  65. )
  66. )
  67. args: array(
  68. )
  69. )
  70. )
  71. )
  72. )
  73. finallyStmts: array(
  74. 0: Expr_FuncCall(
  75. name: Name(
  76. parts: array(
  77. 0: doFinally
  78. )
  79. )
  80. args: array(
  81. )
  82. )
  83. )
  84. )
  85. 1: Stmt_TryCatch(
  86. stmts: array(
  87. )
  88. catches: array(
  89. 0: Stmt_Catch(
  90. type: Name(
  91. parts: array(
  92. 0: A
  93. )
  94. )
  95. var: b
  96. stmts: array(
  97. )
  98. )
  99. )
  100. finallyStmts: null
  101. )
  102. 2: Stmt_TryCatch(
  103. stmts: array(
  104. )
  105. catches: array(
  106. )
  107. finallyStmts: array(
  108. )
  109. )
  110. )