菜谱项目

defaultValues.test 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. Default values (static scalar tests)
  2. -----
  3. <?php
  4. function a(
  5. $b = null,
  6. $c = 'foo',
  7. $d = A::B,
  8. $f = +1,
  9. $g = -1.0,
  10. $h = array(),
  11. $i = [],
  12. $j = ['foo'],
  13. $k = ['foo', 'bar' => 'baz']
  14. ) {}
  15. -----
  16. array(
  17. 0: Stmt_Function(
  18. byRef: false
  19. name: a
  20. params: array(
  21. 0: Param(
  22. type: null
  23. byRef: false
  24. variadic: false
  25. name: b
  26. default: Expr_ConstFetch(
  27. name: Name(
  28. parts: array(
  29. 0: null
  30. )
  31. )
  32. )
  33. )
  34. 1: Param(
  35. type: null
  36. byRef: false
  37. variadic: false
  38. name: c
  39. default: Scalar_String(
  40. value: foo
  41. )
  42. )
  43. 2: Param(
  44. type: null
  45. byRef: false
  46. variadic: false
  47. name: d
  48. default: Expr_ClassConstFetch(
  49. class: Name(
  50. parts: array(
  51. 0: A
  52. )
  53. )
  54. name: B
  55. )
  56. )
  57. 3: Param(
  58. type: null
  59. byRef: false
  60. variadic: false
  61. name: f
  62. default: Expr_UnaryPlus(
  63. expr: Scalar_LNumber(
  64. value: 1
  65. )
  66. )
  67. )
  68. 4: Param(
  69. type: null
  70. byRef: false
  71. variadic: false
  72. name: g
  73. default: Expr_UnaryMinus(
  74. expr: Scalar_DNumber(
  75. value: 1
  76. )
  77. )
  78. )
  79. 5: Param(
  80. type: null
  81. byRef: false
  82. variadic: false
  83. name: h
  84. default: Expr_Array(
  85. items: array(
  86. )
  87. )
  88. )
  89. 6: Param(
  90. type: null
  91. byRef: false
  92. variadic: false
  93. name: i
  94. default: Expr_Array(
  95. items: array(
  96. )
  97. )
  98. )
  99. 7: Param(
  100. type: null
  101. byRef: false
  102. variadic: false
  103. name: j
  104. default: Expr_Array(
  105. items: array(
  106. 0: Expr_ArrayItem(
  107. key: null
  108. value: Scalar_String(
  109. value: foo
  110. )
  111. byRef: false
  112. )
  113. )
  114. )
  115. )
  116. 8: Param(
  117. type: null
  118. byRef: false
  119. variadic: false
  120. name: k
  121. default: Expr_Array(
  122. items: array(
  123. 0: Expr_ArrayItem(
  124. key: null
  125. value: Scalar_String(
  126. value: foo
  127. )
  128. byRef: false
  129. )
  130. 1: Expr_ArrayItem(
  131. key: Scalar_String(
  132. value: bar
  133. )
  134. value: Scalar_String(
  135. value: baz
  136. )
  137. byRef: false
  138. )
  139. )
  140. )
  141. )
  142. )
  143. returnType: null
  144. stmts: array(
  145. )
  146. )
  147. )