recovery.test 32 KB

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