recovery.test 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411
  1. Error recovery
  2. -----
  3. <?php
  4. foo()
  5. bar()
  6. baz()
  7. -----
  8. Syntax error, unexpected T_STRING from 4:1 to 4:3
  9. Syntax error, unexpected T_STRING from 5:1 to 5:3
  10. Syntax error, unexpected EOF from 5:6 to 5:6
  11. array(
  12. 0: Stmt_Expression(
  13. expr: Expr_FuncCall(
  14. name: Name(
  15. parts: array(
  16. 0: foo
  17. )
  18. )
  19. args: array(
  20. )
  21. )
  22. )
  23. 1: Stmt_Expression(
  24. expr: Expr_FuncCall(
  25. name: Name(
  26. parts: array(
  27. 0: bar
  28. )
  29. )
  30. args: array(
  31. )
  32. )
  33. )
  34. 2: Stmt_Expression(
  35. expr: Expr_FuncCall(
  36. name: Name(
  37. parts: array(
  38. 0: baz
  39. )
  40. )
  41. args: array(
  42. )
  43. )
  44. )
  45. )
  46. -----
  47. <?php
  48. foo()
  49. bar();
  50. baz();
  51. -----
  52. Syntax error, unexpected T_STRING from 4:1 to 4:3
  53. array(
  54. 0: Stmt_Expression(
  55. expr: Expr_FuncCall(
  56. name: Name(
  57. parts: array(
  58. 0: foo
  59. )
  60. )
  61. args: array(
  62. )
  63. )
  64. )
  65. 1: Stmt_Expression(
  66. expr: Expr_FuncCall(
  67. name: Name(
  68. parts: array(
  69. 0: bar
  70. )
  71. )
  72. args: array(
  73. )
  74. )
  75. )
  76. 2: Stmt_Expression(
  77. expr: Expr_FuncCall(
  78. name: Name(
  79. parts: array(
  80. 0: baz
  81. )
  82. )
  83. args: array(
  84. )
  85. )
  86. )
  87. )
  88. -----
  89. <?php
  90. foo();
  91. bar()
  92. baz();
  93. -----
  94. Syntax error, unexpected T_STRING from 5:1 to 5:3
  95. array(
  96. 0: Stmt_Expression(
  97. expr: Expr_FuncCall(
  98. name: Name(
  99. parts: array(
  100. 0: foo
  101. )
  102. )
  103. args: array(
  104. )
  105. )
  106. )
  107. 1: Stmt_Expression(
  108. expr: Expr_FuncCall(
  109. name: Name(
  110. parts: array(
  111. 0: bar
  112. )
  113. )
  114. args: array(
  115. )
  116. )
  117. )
  118. 2: Stmt_Expression(
  119. expr: Expr_FuncCall(
  120. name: Name(
  121. parts: array(
  122. 0: baz
  123. )
  124. )
  125. args: array(
  126. )
  127. )
  128. )
  129. )
  130. -----
  131. <?php
  132. abc;
  133. 1 + ;
  134. -----
  135. Syntax error, unexpected ';' from 3:5 to 3:5
  136. array(
  137. 0: Stmt_Expression(
  138. expr: Expr_ConstFetch(
  139. name: Name(
  140. parts: array(
  141. 0: abc
  142. )
  143. )
  144. )
  145. )
  146. 1: Stmt_Expression(
  147. expr: Scalar_LNumber(
  148. value: 1
  149. )
  150. )
  151. )
  152. -----
  153. <?php
  154. function test() {
  155. 1 +
  156. }
  157. -----
  158. Syntax error, unexpected '}' from 4:1 to 4:1
  159. array(
  160. 0: Stmt_Function(
  161. byRef: false
  162. name: Identifier(
  163. name: test
  164. )
  165. params: array(
  166. )
  167. returnType: null
  168. stmts: array(
  169. 0: Stmt_Expression(
  170. expr: Scalar_LNumber(
  171. value: 1
  172. )
  173. )
  174. )
  175. )
  176. )
  177. -----
  178. <?php
  179. $i = 0;
  180. while
  181. $j = 1;
  182. $k = 2;
  183. -----
  184. Syntax error, unexpected T_VARIABLE, expecting '(' from 6:1 to 6:2
  185. array(
  186. 0: Stmt_Expression(
  187. expr: Expr_Assign(
  188. var: Expr_Variable(
  189. name: i
  190. )
  191. expr: Scalar_LNumber(
  192. value: 0
  193. )
  194. )
  195. )
  196. 1: Stmt_Expression(
  197. expr: Expr_Assign(
  198. var: Expr_Variable(
  199. name: j
  200. )
  201. expr: Scalar_LNumber(
  202. value: 1
  203. )
  204. )
  205. )
  206. 2: Stmt_Expression(
  207. expr: Expr_Assign(
  208. var: Expr_Variable(
  209. name: k
  210. )
  211. expr: Scalar_LNumber(
  212. value: 2
  213. )
  214. )
  215. )
  216. )
  217. -----
  218. <?php
  219. $i = 0;
  220. while () {
  221. $j = 1;
  222. }
  223. $k = 2;
  224. // The output here drops the loop - would require Error node to handle this
  225. -----
  226. Syntax error, unexpected ')' from 4:8 to 4:8
  227. array(
  228. 0: Stmt_Expression(
  229. expr: Expr_Assign(
  230. var: Expr_Variable(
  231. name: i
  232. )
  233. expr: Scalar_LNumber(
  234. value: 0
  235. )
  236. )
  237. )
  238. 1: Stmt_Expression(
  239. expr: Expr_Assign(
  240. var: Expr_Variable(
  241. name: j
  242. )
  243. expr: Scalar_LNumber(
  244. value: 1
  245. )
  246. )
  247. )
  248. 2: Stmt_Expression(
  249. expr: Expr_Assign(
  250. var: Expr_Variable(
  251. name: k
  252. )
  253. expr: Scalar_LNumber(
  254. value: 2
  255. )
  256. )
  257. )
  258. 3: Stmt_Nop(
  259. comments: array(
  260. 0: // The output here drops the loop - would require Error node to handle this
  261. )
  262. )
  263. )
  264. -----
  265. <?php
  266. // Can't recover this yet, as the '}' for the inner_statement_list
  267. // is always required.
  268. $i = 0;
  269. while (true) {
  270. $i = 1;
  271. $i = 2;
  272. -----
  273. Syntax error, unexpected EOF from 8:12 to 8:12
  274. -----
  275. <?php
  276. $foo->
  277. ;
  278. -----
  279. !!positions
  280. Syntax error, unexpected ';', expecting T_STRING or T_VARIABLE or '{' or '$' from 3:1 to 3:1
  281. array(
  282. 0: Stmt_Expression[2:1 - 3:1](
  283. expr: Expr_PropertyFetch[2:1 - 2:6](
  284. var: Expr_Variable[2:1 - 2:4](
  285. name: foo
  286. )
  287. name: Expr_Error[3:1 - 2:6](
  288. )
  289. )
  290. )
  291. )
  292. -----
  293. <?php
  294. function foo() {
  295. $bar->
  296. }
  297. -----
  298. !!positions
  299. Syntax error, unexpected '}', expecting T_STRING or T_VARIABLE or '{' or '$' from 4:1 to 4:1
  300. array(
  301. 0: Stmt_Function[2:1 - 4:1](
  302. byRef: false
  303. name: Identifier[2:10 - 2:12](
  304. name: foo
  305. )
  306. params: array(
  307. )
  308. returnType: null
  309. stmts: array(
  310. 0: Stmt_Expression[3:5 - 3:10](
  311. expr: Expr_PropertyFetch[3:5 - 3:10](
  312. var: Expr_Variable[3:5 - 3:8](
  313. name: bar
  314. )
  315. name: Expr_Error[4:1 - 3:10](
  316. )
  317. )
  318. )
  319. )
  320. )
  321. )
  322. -----
  323. <?php
  324. new T
  325. -----
  326. Syntax error, unexpected EOF from 2:6 to 2:6
  327. array(
  328. 0: Stmt_Expression(
  329. expr: Expr_New(
  330. class: Name(
  331. parts: array(
  332. 0: T
  333. )
  334. )
  335. args: array(
  336. )
  337. )
  338. )
  339. )
  340. -----
  341. <?php
  342. new
  343. -----
  344. !!php7,positions
  345. Syntax error, unexpected EOF from 2:4 to 2:4
  346. array(
  347. 0: Stmt_Expression[2:1 - 2:3](
  348. expr: Expr_New[2:1 - 2:3](
  349. class: Expr_Error[2:4 - 2:3](
  350. )
  351. args: array(
  352. )
  353. )
  354. )
  355. )
  356. -----
  357. <?php
  358. $foo instanceof
  359. -----
  360. !!php7
  361. Syntax error, unexpected EOF from 2:16 to 2:16
  362. array(
  363. 0: Stmt_Expression(
  364. expr: Expr_Instanceof(
  365. expr: Expr_Variable(
  366. name: foo
  367. )
  368. class: Expr_Error(
  369. )
  370. )
  371. )
  372. )
  373. -----
  374. <?php
  375. $
  376. -----
  377. !!php7
  378. Syntax error, unexpected EOF, expecting T_VARIABLE or '{' or '$' from 2:2 to 2:2
  379. array(
  380. 0: Stmt_Expression(
  381. expr: Expr_Variable(
  382. name: Expr_Error(
  383. )
  384. )
  385. )
  386. )
  387. -----
  388. <?php
  389. Foo::$
  390. -----
  391. !!php7
  392. Syntax error, unexpected EOF, expecting T_VARIABLE or '{' or '$' from 2:7 to 2:7
  393. array(
  394. 0: Stmt_Expression(
  395. expr: Expr_StaticPropertyFetch(
  396. class: Name(
  397. parts: array(
  398. 0: Foo
  399. )
  400. )
  401. name: Expr_Error(
  402. )
  403. )
  404. )
  405. )
  406. -----
  407. <?php
  408. Foo::
  409. -----
  410. !!php7
  411. Syntax error, unexpected EOF from 2:6 to 2:6
  412. array(
  413. 0: Stmt_Expression(
  414. expr: Expr_ClassConstFetch(
  415. class: Name(
  416. parts: array(
  417. 0: Foo
  418. )
  419. )
  420. name: Expr_Error(
  421. )
  422. )
  423. )
  424. )
  425. -----
  426. <?php
  427. namespace Foo
  428. use A
  429. use function a
  430. use A\{B}
  431. const A = 1
  432. break
  433. break 2
  434. continue
  435. continue 2
  436. return
  437. return 2
  438. echo $a
  439. unset($a)
  440. throw $x
  441. goto label
  442. -----
  443. !!php7
  444. Syntax error, unexpected T_USE, expecting ';' or '{' from 3:1 to 3:3
  445. Syntax error, unexpected T_USE, expecting ';' from 5:1 to 5:3
  446. Syntax error, unexpected T_CONST, expecting ';' from 6:1 to 6:5
  447. Syntax error, unexpected T_BREAK, expecting ';' from 7:1 to 7:5
  448. Syntax error, unexpected T_THROW, expecting ';' from 15:1 to 15:5
  449. array(
  450. 0: Stmt_Namespace(
  451. name: Name(
  452. parts: array(
  453. 0: Foo
  454. )
  455. )
  456. stmts: array(
  457. 0: Stmt_Use(
  458. type: TYPE_NORMAL (1)
  459. uses: array(
  460. 0: Stmt_UseUse(
  461. type: TYPE_UNKNOWN (0)
  462. name: Name(
  463. parts: array(
  464. 0: A
  465. )
  466. )
  467. alias: null
  468. )
  469. )
  470. )
  471. 1: Stmt_Use(
  472. type: TYPE_FUNCTION (2)
  473. uses: array(
  474. 0: Stmt_UseUse(
  475. type: TYPE_UNKNOWN (0)
  476. name: Name(
  477. parts: array(
  478. 0: a
  479. )
  480. )
  481. alias: null
  482. )
  483. )
  484. )
  485. 2: Stmt_GroupUse(
  486. type: TYPE_UNKNOWN (0)
  487. prefix: Name(
  488. parts: array(
  489. 0: A
  490. )
  491. )
  492. uses: array(
  493. 0: Stmt_UseUse(
  494. type: TYPE_NORMAL (1)
  495. name: Name(
  496. parts: array(
  497. 0: B
  498. )
  499. )
  500. alias: null
  501. )
  502. )
  503. )
  504. 3: Stmt_Const(
  505. consts: array(
  506. 0: Const(
  507. name: Identifier(
  508. name: A
  509. )
  510. value: Scalar_LNumber(
  511. value: 1
  512. )
  513. )
  514. )
  515. )
  516. 4: Stmt_Break(
  517. num: null
  518. )
  519. 5: Stmt_Break(
  520. num: Scalar_LNumber(
  521. value: 2
  522. )
  523. )
  524. 6: Stmt_Continue(
  525. num: null
  526. )
  527. 7: Stmt_Continue(
  528. num: Scalar_LNumber(
  529. value: 2
  530. )
  531. )
  532. 8: Stmt_Return(
  533. expr: null
  534. )
  535. 9: Stmt_Return(
  536. expr: Scalar_LNumber(
  537. value: 2
  538. )
  539. )
  540. 10: Stmt_Echo(
  541. exprs: array(
  542. 0: Expr_Variable(
  543. name: a
  544. )
  545. )
  546. )
  547. 11: Stmt_Unset(
  548. vars: array(
  549. 0: Expr_Variable(
  550. name: a
  551. )
  552. )
  553. )
  554. 12: Stmt_Throw(
  555. expr: Expr_Variable(
  556. name: x
  557. )
  558. )
  559. 13: Stmt_Goto(
  560. name: Identifier(
  561. name: label
  562. )
  563. )
  564. )
  565. )
  566. )
  567. -----
  568. <?php
  569. use A\{B, };
  570. use function A\{b, };
  571. use A, ;
  572. const A = 42, ;
  573. class X implements Y, {
  574. use A, ;
  575. use A, {
  576. A::b insteadof C, ;
  577. }
  578. const A = 42, ;
  579. public $x, ;
  580. }
  581. interface I extends J, {}
  582. unset($x, );
  583. isset($x, );
  584. declare(a=42, );
  585. function foo($a, ) {}
  586. foo($a, );
  587. global $a, ;
  588. static $a, ;
  589. echo $a, ;
  590. for ($a, ; $b, ; $c, );
  591. function ($a, ) use ($b, ) {};
  592. -----
  593. !!php7
  594. A trailing comma is not allowed here from 5:6 to 5:6
  595. A trailing comma is not allowed here from 6:13 to 6:13
  596. A trailing comma is not allowed here from 8:21 to 8:21
  597. A trailing comma is not allowed here from 9:10 to 9:10
  598. A trailing comma is not allowed here from 10:10 to 10:10
  599. A trailing comma is not allowed here from 11:25 to 11:25
  600. A trailing comma is not allowed here from 13:17 to 13:17
  601. A trailing comma is not allowed here from 14:14 to 14:14
  602. A trailing comma is not allowed here from 16:22 to 16:22
  603. A trailing comma is not allowed here from 21:13 to 21:13
  604. A trailing comma is not allowed here from 23:16 to 23:16
  605. A trailing comma is not allowed here from 25:10 to 25:10
  606. A trailing comma is not allowed here from 26:10 to 26:10
  607. A trailing comma is not allowed here from 27:8 to 27:8
  608. A trailing comma is not allowed here from 29:8 to 29:8
  609. A trailing comma is not allowed here from 29:14 to 29:14
  610. A trailing comma is not allowed here from 29:20 to 29:20
  611. A trailing comma is not allowed here from 30:13 to 30:13
  612. A trailing comma is not allowed here from 30:24 to 30:24
  613. array(
  614. 0: Stmt_GroupUse(
  615. type: TYPE_UNKNOWN (0)
  616. prefix: Name(
  617. parts: array(
  618. 0: A
  619. )
  620. )
  621. uses: array(
  622. 0: Stmt_UseUse(
  623. type: TYPE_NORMAL (1)
  624. name: Name(
  625. parts: array(
  626. 0: B
  627. )
  628. )
  629. alias: null
  630. )
  631. )
  632. )
  633. 1: Stmt_GroupUse(
  634. type: TYPE_FUNCTION (2)
  635. prefix: Name(
  636. parts: array(
  637. 0: A
  638. )
  639. )
  640. uses: array(
  641. 0: Stmt_UseUse(
  642. type: TYPE_UNKNOWN (0)
  643. name: Name(
  644. parts: array(
  645. 0: b
  646. )
  647. )
  648. alias: null
  649. )
  650. )
  651. )
  652. 2: Stmt_Use(
  653. type: TYPE_NORMAL (1)
  654. uses: array(
  655. 0: Stmt_UseUse(
  656. type: TYPE_UNKNOWN (0)
  657. name: Name(
  658. parts: array(
  659. 0: A
  660. )
  661. )
  662. alias: null
  663. )
  664. )
  665. )
  666. 3: Stmt_Const(
  667. consts: array(
  668. 0: Const(
  669. name: Identifier(
  670. name: A
  671. )
  672. value: Scalar_LNumber(
  673. value: 42
  674. )
  675. )
  676. )
  677. )
  678. 4: Stmt_Class(
  679. flags: 0
  680. name: Identifier(
  681. name: X
  682. )
  683. extends: null
  684. implements: array(
  685. 0: Name(
  686. parts: array(
  687. 0: Y
  688. )
  689. )
  690. )
  691. stmts: array(
  692. 0: Stmt_TraitUse(
  693. traits: array(
  694. 0: Name(
  695. parts: array(
  696. 0: A
  697. )
  698. )
  699. )
  700. adaptations: array(
  701. )
  702. )
  703. 1: Stmt_TraitUse(
  704. traits: array(
  705. 0: Name(
  706. parts: array(
  707. 0: A
  708. )
  709. )
  710. )
  711. adaptations: array(
  712. 0: Stmt_TraitUseAdaptation_Precedence(
  713. trait: Name(
  714. parts: array(
  715. 0: A
  716. )
  717. )
  718. method: Identifier(
  719. name: b
  720. )
  721. insteadof: array(
  722. 0: Name(
  723. parts: array(
  724. 0: C
  725. )
  726. )
  727. )
  728. )
  729. )
  730. )
  731. 2: Stmt_ClassConst(
  732. flags: 0
  733. consts: array(
  734. 0: Const(
  735. name: Identifier(
  736. name: A
  737. )
  738. value: Scalar_LNumber(
  739. value: 42
  740. )
  741. )
  742. )
  743. )
  744. 3: Stmt_Property(
  745. flags: MODIFIER_PUBLIC (1)
  746. type: null
  747. props: array(
  748. 0: Stmt_PropertyProperty(
  749. name: VarLikeIdentifier(
  750. name: x
  751. )
  752. default: null
  753. )
  754. )
  755. )
  756. )
  757. )
  758. 5: Stmt_Interface(
  759. name: Identifier(
  760. name: I
  761. )
  762. extends: array(
  763. 0: Name(
  764. parts: array(
  765. 0: J
  766. )
  767. )
  768. )
  769. stmts: array(
  770. )
  771. )
  772. 6: Stmt_Unset(
  773. vars: array(
  774. 0: Expr_Variable(
  775. name: x
  776. )
  777. )
  778. )
  779. 7: Stmt_Expression(
  780. expr: Expr_Isset(
  781. vars: array(
  782. 0: Expr_Variable(
  783. name: x
  784. )
  785. )
  786. )
  787. )
  788. 8: Stmt_Declare(
  789. declares: array(
  790. 0: Stmt_DeclareDeclare(
  791. key: Identifier(
  792. name: a
  793. )
  794. value: Scalar_LNumber(
  795. value: 42
  796. )
  797. )
  798. )
  799. stmts: null
  800. )
  801. 9: Stmt_Function(
  802. byRef: false
  803. name: Identifier(
  804. name: foo
  805. )
  806. params: array(
  807. 0: Param(
  808. type: null
  809. byRef: false
  810. variadic: false
  811. var: Expr_Variable(
  812. name: a
  813. )
  814. default: null
  815. )
  816. )
  817. returnType: null
  818. stmts: array(
  819. )
  820. )
  821. 10: Stmt_Expression(
  822. expr: Expr_FuncCall(
  823. name: Name(
  824. parts: array(
  825. 0: foo
  826. )
  827. )
  828. args: array(
  829. 0: Arg(
  830. value: Expr_Variable(
  831. name: a
  832. )
  833. byRef: false
  834. unpack: false
  835. )
  836. )
  837. )
  838. )
  839. 11: Stmt_Global(
  840. vars: array(
  841. 0: Expr_Variable(
  842. name: a
  843. )
  844. )
  845. )
  846. 12: Stmt_Static(
  847. vars: array(
  848. 0: Stmt_StaticVar(
  849. var: Expr_Variable(
  850. name: a
  851. )
  852. default: null
  853. )
  854. )
  855. )
  856. 13: Stmt_Echo(
  857. exprs: array(
  858. 0: Expr_Variable(
  859. name: a
  860. )
  861. )
  862. )
  863. 14: Stmt_For(
  864. init: array(
  865. 0: Expr_Variable(
  866. name: a
  867. )
  868. )
  869. cond: array(
  870. 0: Expr_Variable(
  871. name: b
  872. )
  873. )
  874. loop: array(
  875. 0: Expr_Variable(
  876. name: c
  877. )
  878. )
  879. stmts: array(
  880. )
  881. )
  882. 15: Stmt_Expression(
  883. expr: Expr_Closure(
  884. static: false
  885. byRef: false
  886. params: array(
  887. 0: Param(
  888. type: null
  889. byRef: false
  890. variadic: false
  891. var: Expr_Variable(
  892. name: a
  893. )
  894. default: null
  895. )
  896. )
  897. uses: array(
  898. 0: Expr_ClosureUse(
  899. var: Expr_Variable(
  900. name: b
  901. )
  902. byRef: false
  903. )
  904. )
  905. returnType: null
  906. stmts: array(
  907. )
  908. )
  909. )
  910. )
  911. -----
  912. <?php
  913. foo(Bar::);
  914. -----
  915. !!php7,positions
  916. Syntax error, unexpected ')' from 3:10 to 3:10
  917. array(
  918. 0: Stmt_Expression[3:1 - 3:11](
  919. expr: Expr_FuncCall[3:1 - 3:10](
  920. name: Name[3:1 - 3:3](
  921. parts: array(
  922. 0: foo
  923. )
  924. )
  925. args: array(
  926. 0: Arg[3:5 - 3:9](
  927. value: Expr_ClassConstFetch[3:5 - 3:9](
  928. class: Name[3:5 - 3:7](
  929. parts: array(
  930. 0: Bar
  931. )
  932. )
  933. name: Expr_Error[3:10 - 3:9](
  934. )
  935. )
  936. byRef: false
  937. unpack: false
  938. )
  939. )
  940. )
  941. )
  942. )
  943. -----
  944. <?php
  945. class Foo {
  946. publi $foo;
  947. public $bar;
  948. }
  949. -----
  950. !!php7
  951. Syntax error, unexpected T_STRING from 4:5 to 4:9
  952. array(
  953. 0: Stmt_Class(
  954. flags: 0
  955. name: Identifier(
  956. name: Foo
  957. )
  958. extends: null
  959. implements: array(
  960. )
  961. stmts: array(
  962. 0: Stmt_Property(
  963. flags: MODIFIER_PUBLIC (1)
  964. type: null
  965. props: array(
  966. 0: Stmt_PropertyProperty(
  967. name: VarLikeIdentifier(
  968. name: bar
  969. )
  970. default: null
  971. )
  972. )
  973. )
  974. )
  975. )
  976. )
  977. -----
  978. <?php
  979. foreach ($foo) { $bar; }
  980. foreach ($foo as ) { $bar; }
  981. -----
  982. !!php7
  983. Syntax error, unexpected ')' from 3:14 to 3:14
  984. Syntax error, unexpected ')' from 4:18 to 4:18
  985. array(
  986. 0: Stmt_Foreach(
  987. expr: Expr_Variable(
  988. name: foo
  989. )
  990. keyVar: null
  991. byRef: false
  992. valueVar: Expr_Error(
  993. )
  994. stmts: array(
  995. 0: Stmt_Expression(
  996. expr: Expr_Variable(
  997. name: bar
  998. )
  999. )
  1000. )
  1001. )
  1002. 1: Stmt_Foreach(
  1003. expr: Expr_Variable(
  1004. name: foo
  1005. )
  1006. keyVar: null
  1007. byRef: false
  1008. valueVar: Expr_Error(
  1009. )
  1010. stmts: array(
  1011. 0: Stmt_Expression(
  1012. expr: Expr_Variable(
  1013. name: bar
  1014. )
  1015. )
  1016. )
  1017. )
  1018. )
  1019. -----
  1020. <?php
  1021. function foo(Type) {
  1022. $foo;
  1023. }
  1024. function foo(Type1 $foo, Type2) {
  1025. $bar;
  1026. }
  1027. function foo(...) {
  1028. $baz;
  1029. }
  1030. function foo(&) {
  1031. $qux;
  1032. }
  1033. function foo(Bar)
  1034. class Bar {
  1035. function foo(Baz)
  1036. }
  1037. function(Foo);
  1038. -----
  1039. !!php7
  1040. Syntax error, unexpected ')', expecting T_VARIABLE from 3:18 to 3:18
  1041. Syntax error, unexpected ')', expecting T_VARIABLE from 7:31 to 7:31
  1042. Syntax error, unexpected ')', expecting T_VARIABLE from 11:17 to 11:17
  1043. Syntax error, unexpected ')', expecting T_VARIABLE from 15:15 to 15:15
  1044. Syntax error, unexpected ')', expecting T_VARIABLE from 19:17 to 19:17
  1045. Syntax error, unexpected ')', expecting T_VARIABLE from 22:21 to 22:21
  1046. Syntax error, unexpected ')', expecting T_VARIABLE from 25:13 to 25:13
  1047. array(
  1048. 0: Stmt_Function(
  1049. byRef: false
  1050. name: Identifier(
  1051. name: foo
  1052. )
  1053. params: array(
  1054. 0: Param(
  1055. type: Name(
  1056. parts: array(
  1057. 0: Type
  1058. )
  1059. )
  1060. byRef: false
  1061. variadic: false
  1062. var: Expr_Error(
  1063. )
  1064. default: null
  1065. )
  1066. )
  1067. returnType: null
  1068. stmts: array(
  1069. 0: Stmt_Expression(
  1070. expr: Expr_Variable(
  1071. name: foo
  1072. )
  1073. )
  1074. )
  1075. )
  1076. 1: Stmt_Function(
  1077. byRef: false
  1078. name: Identifier(
  1079. name: foo
  1080. )
  1081. params: array(
  1082. 0: Param(
  1083. type: Name(
  1084. parts: array(
  1085. 0: Type1
  1086. )
  1087. )
  1088. byRef: false
  1089. variadic: false
  1090. var: Expr_Variable(
  1091. name: foo
  1092. )
  1093. default: null
  1094. )
  1095. 1: Param(
  1096. type: Name(
  1097. parts: array(
  1098. 0: Type2
  1099. )
  1100. )
  1101. byRef: false
  1102. variadic: false
  1103. var: Expr_Error(
  1104. )
  1105. default: null
  1106. )
  1107. )
  1108. returnType: null
  1109. stmts: array(
  1110. 0: Stmt_Expression(
  1111. expr: Expr_Variable(
  1112. name: bar
  1113. )
  1114. )
  1115. )
  1116. )
  1117. 2: Stmt_Function(
  1118. byRef: false
  1119. name: Identifier(
  1120. name: foo
  1121. )
  1122. params: array(
  1123. 0: Param(
  1124. type: null
  1125. byRef: false
  1126. variadic: true
  1127. var: Expr_Error(
  1128. )
  1129. default: null
  1130. )
  1131. )
  1132. returnType: null
  1133. stmts: array(
  1134. 0: Stmt_Expression(
  1135. expr: Expr_Variable(
  1136. name: baz
  1137. )
  1138. )
  1139. )
  1140. )
  1141. 3: Stmt_Function(
  1142. byRef: false
  1143. name: Identifier(
  1144. name: foo
  1145. )
  1146. params: array(
  1147. 0: Param(
  1148. type: null
  1149. byRef: true
  1150. variadic: false
  1151. var: Expr_Error(
  1152. )
  1153. default: null
  1154. )
  1155. )
  1156. returnType: null
  1157. stmts: array(
  1158. 0: Stmt_Expression(
  1159. expr: Expr_Variable(
  1160. name: qux
  1161. )
  1162. )
  1163. )
  1164. )
  1165. 4: Stmt_Function(
  1166. byRef: false
  1167. name: Identifier(
  1168. name: foo
  1169. )
  1170. params: array(
  1171. 0: Param(
  1172. type: Name(
  1173. parts: array(
  1174. 0: Bar
  1175. )
  1176. )
  1177. byRef: false
  1178. variadic: false
  1179. var: Expr_Error(
  1180. )
  1181. default: null
  1182. )
  1183. )
  1184. returnType: null
  1185. stmts: array(
  1186. )
  1187. )
  1188. 5: Stmt_Class(
  1189. flags: 0
  1190. name: Identifier(
  1191. name: Bar
  1192. )
  1193. extends: null
  1194. implements: array(
  1195. )
  1196. stmts: array(
  1197. 0: Stmt_ClassMethod(
  1198. flags: 0
  1199. byRef: false
  1200. name: Identifier(
  1201. name: foo
  1202. )
  1203. params: array(
  1204. 0: Param(
  1205. type: Name(
  1206. parts: array(
  1207. 0: Baz
  1208. )
  1209. )
  1210. byRef: false
  1211. variadic: false
  1212. var: Expr_Error(
  1213. )
  1214. default: null
  1215. )
  1216. )
  1217. returnType: null
  1218. stmts: array(
  1219. )
  1220. )
  1221. )
  1222. )
  1223. 6: Stmt_Expression(
  1224. expr: Expr_Closure(
  1225. static: false
  1226. byRef: false
  1227. params: array(
  1228. 0: Param(
  1229. type: Name(
  1230. parts: array(
  1231. 0: Foo
  1232. )
  1233. )
  1234. byRef: false
  1235. variadic: false
  1236. var: Expr_Error(
  1237. )
  1238. default: null
  1239. )
  1240. )
  1241. uses: array(
  1242. )
  1243. returnType: null
  1244. stmts: array(
  1245. )
  1246. )
  1247. )
  1248. )
  1249. -----
  1250. <?php
  1251. $array = [
  1252. $this->value $oopsAnotherValue->get()
  1253. ];
  1254. $array = [
  1255. $value $oopsAnotherValue
  1256. ];
  1257. $array = [
  1258. 'key' => $value $oopsAnotherValue
  1259. ];
  1260. -----
  1261. !!php7
  1262. Syntax error, unexpected T_VARIABLE, expecting ',' or ')' or ']' from 3:18 to 3:34
  1263. Syntax error, unexpected T_VARIABLE, expecting ',' or ')' or ']' from 6:12 to 6:28
  1264. Syntax error, unexpected T_VARIABLE, expecting ',' or ')' or ']' from 9:21 to 9:37
  1265. array(
  1266. 0: Stmt_Expression(
  1267. expr: Expr_Assign(
  1268. var: Expr_Variable(
  1269. name: array
  1270. )
  1271. expr: Expr_Array(
  1272. items: array(
  1273. 0: Expr_ArrayItem(
  1274. key: null
  1275. value: Expr_PropertyFetch(
  1276. var: Expr_Variable(
  1277. name: this
  1278. )
  1279. name: Identifier(
  1280. name: value
  1281. )
  1282. )
  1283. byRef: false
  1284. )
  1285. 1: Expr_ArrayItem(
  1286. key: null
  1287. value: Expr_MethodCall(
  1288. var: Expr_Variable(
  1289. name: oopsAnotherValue
  1290. )
  1291. name: Identifier(
  1292. name: get
  1293. )
  1294. args: array(
  1295. )
  1296. )
  1297. byRef: false
  1298. )
  1299. )
  1300. )
  1301. )
  1302. )
  1303. 1: Stmt_Expression(
  1304. expr: Expr_Assign(
  1305. var: Expr_Variable(
  1306. name: array
  1307. )
  1308. expr: Expr_Array(
  1309. items: array(
  1310. 0: Expr_ArrayItem(
  1311. key: null
  1312. value: Expr_Variable(
  1313. name: value
  1314. )
  1315. byRef: false
  1316. )
  1317. 1: Expr_ArrayItem(
  1318. key: null
  1319. value: Expr_Variable(
  1320. name: oopsAnotherValue
  1321. )
  1322. byRef: false
  1323. )
  1324. )
  1325. )
  1326. )
  1327. )
  1328. 2: Stmt_Expression(
  1329. expr: Expr_Assign(
  1330. var: Expr_Variable(
  1331. name: array
  1332. )
  1333. expr: Expr_Array(
  1334. items: array(
  1335. 0: Expr_ArrayItem(
  1336. key: Scalar_String(
  1337. value: key
  1338. )
  1339. value: Expr_Variable(
  1340. name: value
  1341. )
  1342. byRef: false
  1343. )
  1344. 1: Expr_ArrayItem(
  1345. key: null
  1346. value: Expr_Variable(
  1347. name: oopsAnotherValue
  1348. )
  1349. byRef: false
  1350. )
  1351. )
  1352. )
  1353. )
  1354. )
  1355. )
  1356. -----
  1357. <?php
  1358. function foo() :
  1359. {
  1360. return $a;
  1361. }
  1362. -----
  1363. !!php7
  1364. Syntax error, unexpected '{' from 3:1 to 3:1
  1365. array(
  1366. 0: Stmt_Function(
  1367. byRef: false
  1368. name: Identifier(
  1369. name: foo
  1370. )
  1371. params: array(
  1372. )
  1373. returnType: null
  1374. stmts: array(
  1375. 0: Stmt_Return(
  1376. expr: Expr_Variable(
  1377. name: a
  1378. )
  1379. )
  1380. )
  1381. )
  1382. )
  1383. -----
  1384. <?php
  1385. $a = ["a "thing"];
  1386. -----
  1387. !!php7
  1388. Syntax error, unexpected T_STRING, expecting ',' or ')' or ']' from 2:11 to 2:15