菜谱项目

semiReserved.test 10KB

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