defaultValues.test 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. params: array(
  20. 0: Param(
  21. name: b
  22. default: Expr_ConstFetch(
  23. name: Name(
  24. parts: array(
  25. 0: null
  26. )
  27. )
  28. )
  29. type: null
  30. byRef: false
  31. )
  32. 1: Param(
  33. name: c
  34. default: Scalar_String(
  35. value: foo
  36. )
  37. type: null
  38. byRef: false
  39. )
  40. 2: Param(
  41. name: d
  42. default: Expr_ClassConstFetch(
  43. class: Name(
  44. parts: array(
  45. 0: A
  46. )
  47. )
  48. name: B
  49. )
  50. type: null
  51. byRef: false
  52. )
  53. 3: Param(
  54. name: f
  55. default: Expr_UnaryPlus(
  56. expr: Scalar_LNumber(
  57. value: 1
  58. )
  59. )
  60. type: null
  61. byRef: false
  62. )
  63. 4: Param(
  64. name: g
  65. default: Expr_UnaryMinus(
  66. expr: Scalar_DNumber(
  67. value: 1
  68. )
  69. )
  70. type: null
  71. byRef: false
  72. )
  73. 5: Param(
  74. name: h
  75. default: Expr_Array(
  76. items: array(
  77. )
  78. )
  79. type: null
  80. byRef: false
  81. )
  82. 6: Param(
  83. name: i
  84. default: Expr_Array(
  85. items: array(
  86. )
  87. )
  88. type: null
  89. byRef: false
  90. )
  91. 7: Param(
  92. name: j
  93. default: Expr_Array(
  94. items: array(
  95. 0: Expr_ArrayItem(
  96. key: null
  97. value: Scalar_String(
  98. value: foo
  99. )
  100. byRef: false
  101. )
  102. )
  103. )
  104. type: null
  105. byRef: false
  106. )
  107. 8: Param(
  108. name: k
  109. default: Expr_Array(
  110. items: array(
  111. 0: Expr_ArrayItem(
  112. key: null
  113. value: Scalar_String(
  114. value: foo
  115. )
  116. byRef: false
  117. )
  118. 1: Expr_ArrayItem(
  119. key: Scalar_String(
  120. value: bar
  121. )
  122. value: Scalar_String(
  123. value: baz
  124. )
  125. byRef: false
  126. )
  127. )
  128. )
  129. type: null
  130. byRef: false
  131. )
  132. )
  133. stmts: array(
  134. )
  135. name: a
  136. )
  137. )