semiReserved.test 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. Valid usages of reserved keywords as identifiers
  2. -----
  3. <?php
  4. class Test {
  5. function array() {}
  6. function public() {}
  7. static function list() {}
  8. static function protected() {}
  9. public $class;
  10. public $private;
  11. const TRAIT = 3, FINAL = 4;
  12. const __CLASS__ = 1, __TRAIT__ = 2, __FUNCTION__ = 3, __METHOD__ = 4, __LINE__ = 5,
  13. __FILE__ = 6, __DIR__ = 7, __NAMESPACE__ = 8;
  14. // __halt_compiler does not work
  15. }
  16. $t = new Test;
  17. $t->array();
  18. $t->public();
  19. Test::list();
  20. Test::protected();
  21. $t->class;
  22. $t->private;
  23. Test::TRAIT;
  24. Test::FINAL;
  25. class Foo {
  26. use TraitA, TraitB {
  27. TraitA::catch insteadof namespace\TraitB;
  28. TraitA::list as foreach;
  29. TraitB::throw as protected public;
  30. TraitB::self as protected;
  31. exit as die;
  32. \TraitC::exit as bye;
  33. namespace\TraitC::exit as byebye;
  34. TraitA::
  35. //
  36. /** doc comment */
  37. #
  38. catch /* comment */
  39. // comment
  40. # comment
  41. insteadof TraitB;
  42. }
  43. }
  44. -----
  45. array(
  46. 0: Stmt_Class(
  47. type: 0
  48. name: Test
  49. extends: null
  50. implements: array(
  51. )
  52. stmts: array(
  53. 0: Stmt_ClassMethod(
  54. type: 0
  55. byRef: false
  56. name: array
  57. params: array(
  58. )
  59. returnType: null
  60. stmts: array(
  61. )
  62. )
  63. 1: Stmt_ClassMethod(
  64. type: 0
  65. byRef: false
  66. name: public
  67. params: array(
  68. )
  69. returnType: null
  70. stmts: array(
  71. )
  72. )
  73. 2: Stmt_ClassMethod(
  74. type: 8
  75. byRef: false
  76. name: list
  77. params: array(
  78. )
  79. returnType: null
  80. stmts: array(
  81. )
  82. )
  83. 3: Stmt_ClassMethod(
  84. type: 8
  85. byRef: false
  86. name: protected
  87. params: array(
  88. )
  89. returnType: null
  90. stmts: array(
  91. )
  92. )
  93. 4: Stmt_Property(
  94. type: 1
  95. props: array(
  96. 0: Stmt_PropertyProperty(
  97. name: class
  98. default: null
  99. )
  100. )
  101. )
  102. 5: Stmt_Property(
  103. type: 1
  104. props: array(
  105. 0: Stmt_PropertyProperty(
  106. name: private
  107. default: null
  108. )
  109. )
  110. )
  111. 6: Stmt_ClassConst(
  112. consts: array(
  113. 0: Const(
  114. name: TRAIT
  115. value: Scalar_LNumber(
  116. value: 3
  117. )
  118. )
  119. 1: Const(
  120. name: FINAL
  121. value: Scalar_LNumber(
  122. value: 4
  123. )
  124. )
  125. )
  126. )
  127. 7: Stmt_ClassConst(
  128. consts: array(
  129. 0: Const(
  130. name: __CLASS__
  131. value: Scalar_LNumber(
  132. value: 1
  133. )
  134. )
  135. 1: Const(
  136. name: __TRAIT__
  137. value: Scalar_LNumber(
  138. value: 2
  139. )
  140. )
  141. 2: Const(
  142. name: __FUNCTION__
  143. value: Scalar_LNumber(
  144. value: 3
  145. )
  146. )
  147. 3: Const(
  148. name: __METHOD__
  149. value: Scalar_LNumber(
  150. value: 4
  151. )
  152. )
  153. 4: Const(
  154. name: __LINE__
  155. value: Scalar_LNumber(
  156. value: 5
  157. )
  158. )
  159. 5: Const(
  160. name: __FILE__
  161. value: Scalar_LNumber(
  162. value: 6
  163. )
  164. )
  165. 6: Const(
  166. name: __DIR__
  167. value: Scalar_LNumber(
  168. value: 7
  169. )
  170. )
  171. 7: Const(
  172. name: __NAMESPACE__
  173. value: Scalar_LNumber(
  174. value: 8
  175. )
  176. )
  177. )
  178. )
  179. )
  180. )
  181. 1: Expr_Assign(
  182. var: Expr_Variable(
  183. name: t
  184. )
  185. expr: Expr_New(
  186. class: Name(
  187. parts: array(
  188. 0: Test
  189. )
  190. )
  191. args: array(
  192. )
  193. )
  194. )
  195. 2: Expr_MethodCall(
  196. var: Expr_Variable(
  197. name: t
  198. )
  199. name: array
  200. args: array(
  201. )
  202. )
  203. 3: Expr_MethodCall(
  204. var: Expr_Variable(
  205. name: t
  206. )
  207. name: public
  208. args: array(
  209. )
  210. )
  211. 4: Expr_StaticCall(
  212. class: Name(
  213. parts: array(
  214. 0: Test
  215. )
  216. )
  217. name: list
  218. args: array(
  219. )
  220. )
  221. 5: Expr_StaticCall(
  222. class: Name(
  223. parts: array(
  224. 0: Test
  225. )
  226. )
  227. name: protected
  228. args: array(
  229. )
  230. )
  231. 6: Expr_PropertyFetch(
  232. var: Expr_Variable(
  233. name: t
  234. )
  235. name: class
  236. )
  237. 7: Expr_PropertyFetch(
  238. var: Expr_Variable(
  239. name: t
  240. )
  241. name: private
  242. )
  243. 8: Expr_ClassConstFetch(
  244. class: Name(
  245. parts: array(
  246. 0: Test
  247. )
  248. )
  249. name: TRAIT
  250. )
  251. 9: Expr_ClassConstFetch(
  252. class: Name(
  253. parts: array(
  254. 0: Test
  255. )
  256. )
  257. name: FINAL
  258. )
  259. 10: Stmt_Class(
  260. type: 0
  261. name: Foo
  262. extends: null
  263. implements: array(
  264. )
  265. stmts: array(
  266. 0: Stmt_TraitUse(
  267. traits: array(
  268. 0: Name(
  269. parts: array(
  270. 0: TraitA
  271. )
  272. )
  273. 1: Name(
  274. parts: array(
  275. 0: TraitB
  276. )
  277. )
  278. )
  279. adaptations: array(
  280. 0: Stmt_TraitUseAdaptation_Precedence(
  281. trait: Name(
  282. parts: array(
  283. 0: TraitA
  284. )
  285. )
  286. method: catch
  287. insteadof: array(
  288. 0: Name_Relative(
  289. parts: array(
  290. 0: TraitB
  291. )
  292. )
  293. )
  294. )
  295. 1: Stmt_TraitUseAdaptation_Alias(
  296. trait: Name(
  297. parts: array(
  298. 0: TraitA
  299. )
  300. )
  301. method: list
  302. newModifier: null
  303. newName: foreach
  304. )
  305. 2: Stmt_TraitUseAdaptation_Alias(
  306. trait: Name(
  307. parts: array(
  308. 0: TraitB
  309. )
  310. )
  311. method: throw
  312. newModifier: 2
  313. newName: public
  314. )
  315. 3: Stmt_TraitUseAdaptation_Alias(
  316. trait: Name(
  317. parts: array(
  318. 0: TraitB
  319. )
  320. )
  321. method: self
  322. newModifier: 2
  323. newName: null
  324. )
  325. 4: Stmt_TraitUseAdaptation_Alias(
  326. trait: null
  327. method: exit
  328. newModifier: null
  329. newName: die
  330. )
  331. 5: Stmt_TraitUseAdaptation_Alias(
  332. trait: Name_FullyQualified(
  333. parts: array(
  334. 0: TraitC
  335. )
  336. )
  337. method: exit
  338. newModifier: null
  339. newName: bye
  340. )
  341. 6: Stmt_TraitUseAdaptation_Alias(
  342. trait: Name_Relative(
  343. parts: array(
  344. 0: TraitC
  345. )
  346. )
  347. method: exit
  348. newModifier: null
  349. newName: byebye
  350. )
  351. 7: Stmt_TraitUseAdaptation_Precedence(
  352. trait: Name(
  353. parts: array(
  354. 0: TraitA
  355. )
  356. )
  357. method: catch
  358. insteadof: array(
  359. 0: Name(
  360. parts: array(
  361. 0: TraitB
  362. )
  363. )
  364. )
  365. )
  366. )
  367. )
  368. )
  369. )
  370. )