tryCatch.test 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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: Stmt_Expression(
  24. expr: Expr_FuncCall(
  25. name: Name(
  26. parts: array(
  27. 0: doTry
  28. )
  29. )
  30. args: array(
  31. )
  32. )
  33. )
  34. )
  35. catches: array(
  36. 0: Stmt_Catch(
  37. types: array(
  38. 0: Name(
  39. parts: array(
  40. 0: A
  41. )
  42. )
  43. )
  44. var: Expr_Variable(
  45. name: b
  46. )
  47. stmts: array(
  48. 0: Stmt_Expression(
  49. expr: Expr_FuncCall(
  50. name: Name(
  51. parts: array(
  52. 0: doCatchA
  53. )
  54. )
  55. args: array(
  56. )
  57. )
  58. )
  59. )
  60. )
  61. 1: Stmt_Catch(
  62. types: array(
  63. 0: Name(
  64. parts: array(
  65. 0: B
  66. )
  67. )
  68. )
  69. var: Expr_Variable(
  70. name: c
  71. )
  72. stmts: array(
  73. 0: Stmt_Expression(
  74. expr: Expr_FuncCall(
  75. name: Name(
  76. parts: array(
  77. 0: doCatchB
  78. )
  79. )
  80. args: array(
  81. )
  82. )
  83. )
  84. )
  85. )
  86. )
  87. finally: Stmt_Finally(
  88. stmts: array(
  89. 0: Stmt_Expression(
  90. expr: Expr_FuncCall(
  91. name: Name(
  92. parts: array(
  93. 0: doFinally
  94. )
  95. )
  96. args: array(
  97. )
  98. )
  99. )
  100. )
  101. )
  102. )
  103. 1: Stmt_TryCatch(
  104. stmts: array(
  105. )
  106. catches: array(
  107. 0: Stmt_Catch(
  108. types: array(
  109. 0: Name(
  110. parts: array(
  111. 0: A
  112. )
  113. )
  114. )
  115. var: Expr_Variable(
  116. name: b
  117. )
  118. stmts: array(
  119. )
  120. )
  121. )
  122. finally: null
  123. comments: array(
  124. 0: // no finally
  125. )
  126. )
  127. 2: Stmt_TryCatch(
  128. stmts: array(
  129. )
  130. catches: array(
  131. )
  132. finally: Stmt_Finally(
  133. stmts: array(
  134. )
  135. )
  136. comments: array(
  137. 0: // no catch
  138. )
  139. )
  140. )