semiReserved.test 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  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: Identifier(
  49. name: Test
  50. )
  51. extends: null
  52. implements: array(
  53. )
  54. stmts: array(
  55. 0: Stmt_ClassMethod(
  56. flags: 0
  57. byRef: false
  58. name: Identifier(
  59. name: array
  60. )
  61. params: array(
  62. )
  63. returnType: null
  64. stmts: array(
  65. )
  66. )
  67. 1: Stmt_ClassMethod(
  68. flags: 0
  69. byRef: false
  70. name: Identifier(
  71. name: public
  72. )
  73. params: array(
  74. )
  75. returnType: null
  76. stmts: array(
  77. )
  78. )
  79. 2: Stmt_ClassMethod(
  80. flags: MODIFIER_STATIC (8)
  81. byRef: false
  82. name: Identifier(
  83. name: list
  84. )
  85. params: array(
  86. )
  87. returnType: null
  88. stmts: array(
  89. )
  90. )
  91. 3: Stmt_ClassMethod(
  92. flags: MODIFIER_STATIC (8)
  93. byRef: false
  94. name: Identifier(
  95. name: protected
  96. )
  97. params: array(
  98. )
  99. returnType: null
  100. stmts: array(
  101. )
  102. )
  103. 4: Stmt_Property(
  104. flags: MODIFIER_PUBLIC (1)
  105. type: null
  106. props: array(
  107. 0: Stmt_PropertyProperty(
  108. name: VarLikeIdentifier(
  109. name: class
  110. )
  111. default: null
  112. )
  113. )
  114. )
  115. 5: Stmt_Property(
  116. flags: MODIFIER_PUBLIC (1)
  117. type: null
  118. props: array(
  119. 0: Stmt_PropertyProperty(
  120. name: VarLikeIdentifier(
  121. name: private
  122. )
  123. default: null
  124. )
  125. )
  126. )
  127. 6: Stmt_ClassConst(
  128. flags: 0
  129. consts: array(
  130. 0: Const(
  131. name: Identifier(
  132. name: TRAIT
  133. )
  134. value: Scalar_LNumber(
  135. value: 3
  136. )
  137. )
  138. 1: Const(
  139. name: Identifier(
  140. name: FINAL
  141. )
  142. value: Scalar_LNumber(
  143. value: 4
  144. )
  145. )
  146. )
  147. )
  148. 7: Stmt_ClassConst(
  149. flags: 0
  150. consts: array(
  151. 0: Const(
  152. name: Identifier(
  153. name: __CLASS__
  154. )
  155. value: Scalar_LNumber(
  156. value: 1
  157. )
  158. )
  159. 1: Const(
  160. name: Identifier(
  161. name: __TRAIT__
  162. )
  163. value: Scalar_LNumber(
  164. value: 2
  165. )
  166. )
  167. 2: Const(
  168. name: Identifier(
  169. name: __FUNCTION__
  170. )
  171. value: Scalar_LNumber(
  172. value: 3
  173. )
  174. )
  175. 3: Const(
  176. name: Identifier(
  177. name: __METHOD__
  178. )
  179. value: Scalar_LNumber(
  180. value: 4
  181. )
  182. )
  183. 4: Const(
  184. name: Identifier(
  185. name: __LINE__
  186. )
  187. value: Scalar_LNumber(
  188. value: 5
  189. )
  190. )
  191. 5: Const(
  192. name: Identifier(
  193. name: __FILE__
  194. )
  195. value: Scalar_LNumber(
  196. value: 6
  197. )
  198. )
  199. 6: Const(
  200. name: Identifier(
  201. name: __DIR__
  202. )
  203. value: Scalar_LNumber(
  204. value: 7
  205. )
  206. )
  207. 7: Const(
  208. name: Identifier(
  209. name: __NAMESPACE__
  210. )
  211. value: Scalar_LNumber(
  212. value: 8
  213. )
  214. )
  215. )
  216. )
  217. 8: Stmt_Nop(
  218. comments: array(
  219. 0: // __halt_compiler does not work
  220. )
  221. )
  222. )
  223. )
  224. 1: Stmt_Expression(
  225. expr: Expr_Assign(
  226. var: Expr_Variable(
  227. name: t
  228. )
  229. expr: Expr_New(
  230. class: Name(
  231. parts: array(
  232. 0: Test
  233. )
  234. )
  235. args: array(
  236. )
  237. )
  238. )
  239. )
  240. 2: Stmt_Expression(
  241. expr: Expr_MethodCall(
  242. var: Expr_Variable(
  243. name: t
  244. )
  245. name: Identifier(
  246. name: array
  247. )
  248. args: array(
  249. )
  250. )
  251. )
  252. 3: Stmt_Expression(
  253. expr: Expr_MethodCall(
  254. var: Expr_Variable(
  255. name: t
  256. )
  257. name: Identifier(
  258. name: public
  259. )
  260. args: array(
  261. )
  262. )
  263. )
  264. 4: Stmt_Expression(
  265. expr: Expr_StaticCall(
  266. class: Name(
  267. parts: array(
  268. 0: Test
  269. )
  270. )
  271. name: Identifier(
  272. name: list
  273. )
  274. args: array(
  275. )
  276. )
  277. )
  278. 5: Stmt_Expression(
  279. expr: Expr_StaticCall(
  280. class: Name(
  281. parts: array(
  282. 0: Test
  283. )
  284. )
  285. name: Identifier(
  286. name: protected
  287. )
  288. args: array(
  289. )
  290. )
  291. )
  292. 6: Stmt_Expression(
  293. expr: Expr_PropertyFetch(
  294. var: Expr_Variable(
  295. name: t
  296. )
  297. name: Identifier(
  298. name: class
  299. )
  300. )
  301. )
  302. 7: Stmt_Expression(
  303. expr: Expr_PropertyFetch(
  304. var: Expr_Variable(
  305. name: t
  306. )
  307. name: Identifier(
  308. name: private
  309. )
  310. )
  311. )
  312. 8: Stmt_Expression(
  313. expr: Expr_ClassConstFetch(
  314. class: Name(
  315. parts: array(
  316. 0: Test
  317. )
  318. )
  319. name: Identifier(
  320. name: TRAIT
  321. )
  322. )
  323. )
  324. 9: Stmt_Expression(
  325. expr: Expr_ClassConstFetch(
  326. class: Name(
  327. parts: array(
  328. 0: Test
  329. )
  330. )
  331. name: Identifier(
  332. name: FINAL
  333. )
  334. )
  335. )
  336. 10: Stmt_Class(
  337. flags: 0
  338. name: Identifier(
  339. name: Foo
  340. )
  341. extends: null
  342. implements: array(
  343. )
  344. stmts: array(
  345. 0: Stmt_TraitUse(
  346. traits: array(
  347. 0: Name(
  348. parts: array(
  349. 0: TraitA
  350. )
  351. )
  352. 1: Name(
  353. parts: array(
  354. 0: TraitB
  355. )
  356. )
  357. )
  358. adaptations: array(
  359. 0: Stmt_TraitUseAdaptation_Precedence(
  360. trait: Name(
  361. parts: array(
  362. 0: TraitA
  363. )
  364. )
  365. method: Identifier(
  366. name: catch
  367. )
  368. insteadof: array(
  369. 0: Name_Relative(
  370. parts: array(
  371. 0: TraitB
  372. )
  373. )
  374. )
  375. )
  376. 1: Stmt_TraitUseAdaptation_Alias(
  377. trait: Name(
  378. parts: array(
  379. 0: TraitA
  380. )
  381. )
  382. method: Identifier(
  383. name: list
  384. )
  385. newModifier: null
  386. newName: Identifier(
  387. name: foreach
  388. )
  389. )
  390. 2: Stmt_TraitUseAdaptation_Alias(
  391. trait: Name(
  392. parts: array(
  393. 0: TraitB
  394. )
  395. )
  396. method: Identifier(
  397. name: throw
  398. )
  399. newModifier: MODIFIER_PROTECTED (2)
  400. newName: Identifier(
  401. name: public
  402. )
  403. )
  404. 3: Stmt_TraitUseAdaptation_Alias(
  405. trait: Name(
  406. parts: array(
  407. 0: TraitB
  408. )
  409. )
  410. method: Identifier(
  411. name: self
  412. )
  413. newModifier: MODIFIER_PROTECTED (2)
  414. newName: null
  415. )
  416. 4: Stmt_TraitUseAdaptation_Alias(
  417. trait: null
  418. method: Identifier(
  419. name: exit
  420. )
  421. newModifier: null
  422. newName: Identifier(
  423. name: die
  424. )
  425. )
  426. 5: Stmt_TraitUseAdaptation_Alias(
  427. trait: Name_FullyQualified(
  428. parts: array(
  429. 0: TraitC
  430. )
  431. )
  432. method: Identifier(
  433. name: exit
  434. )
  435. newModifier: null
  436. newName: Identifier(
  437. name: bye
  438. )
  439. )
  440. 6: Stmt_TraitUseAdaptation_Alias(
  441. trait: Name_Relative(
  442. parts: array(
  443. 0: TraitC
  444. )
  445. )
  446. method: Identifier(
  447. name: exit
  448. )
  449. newModifier: null
  450. newName: Identifier(
  451. name: byebye
  452. )
  453. )
  454. 7: Stmt_TraitUseAdaptation_Precedence(
  455. trait: Name(
  456. parts: array(
  457. 0: TraitA
  458. )
  459. )
  460. method: Identifier(
  461. name: catch
  462. comments: array(
  463. 0: //
  464. 1: /** doc comment */
  465. 2: #
  466. )
  467. )
  468. insteadof: array(
  469. 0: Name(
  470. parts: array(
  471. 0: TraitB
  472. )
  473. )
  474. )
  475. )
  476. )
  477. )
  478. )
  479. )
  480. )