recovery.test 34 KB

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