NoUselessElseFixerTest.php 26 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001
  1. <?php
  2. /*
  3. * This file is part of PHP CS Fixer.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. * Dariusz Rumiński <dariusz.ruminski@gmail.com>
  7. *
  8. * This source file is subject to the MIT license that is bundled
  9. * with this source code in the file LICENSE.
  10. */
  11. namespace PhpCsFixer\Tests\Fixer\ControlStructure;
  12. use PhpCsFixer\Tests\Test\AbstractFixerTestCase;
  13. use PhpCsFixer\Tokenizer\Tokens;
  14. /**
  15. * @author SpacePossum
  16. *
  17. * @internal
  18. *
  19. * @covers \PhpCsFixer\Fixer\ControlStructure\NoUselessElseFixer
  20. */
  21. final class NoUselessElseFixerTest extends AbstractFixerTestCase
  22. {
  23. /**
  24. * @param string $expected
  25. * @param null|string $input
  26. *
  27. * @dataProvider providePHPCloseTagCases
  28. */
  29. public function testCloseTagCases($expected, $input = null)
  30. {
  31. $this->doTest($expected, $input);
  32. }
  33. public function providePHPCloseTagCases()
  34. {
  35. return [
  36. [
  37. '<?php
  38. if (true) {
  39. $b = $a > 2 ? "" : die
  40. ?>
  41. <?php
  42. } else {
  43. echo 798;
  44. }',
  45. ],
  46. [
  47. '<?php
  48. if (true) {
  49. $b = $a > 2 ? "" : die
  50. ?>
  51. <?php ; // useless semicolon case
  52. } else {
  53. echo 798;
  54. }',
  55. ],
  56. [
  57. '<?php
  58. if (true) {
  59. if($a) die
  60. ?>
  61. <?php ; // useless semicolon case
  62. } else {
  63. echo 798;
  64. }',
  65. ],
  66. [
  67. '<?php
  68. if (true) {
  69. echo 1;
  70. ?>
  71. <?php ; // useless semicolon case
  72. } else {
  73. echo 798;
  74. }',
  75. ],
  76. [
  77. '<?php
  78. if (true) {
  79. echo 777;
  80. if(false) die ?>
  81. <?php
  82. } else {
  83. echo 778;
  84. }',
  85. ],
  86. [
  87. '<?php
  88. if (true)
  89. echo 3;
  90. else {
  91. ?><?php
  92. echo 4;
  93. }
  94. ',
  95. ],
  96. [
  97. '<?php
  98. if (true)
  99. echo 3;
  100. '.'
  101. ?><?php
  102. echo 4;
  103. ',
  104. '<?php
  105. if (true)
  106. echo 3;
  107. else
  108. ?><?php
  109. echo 4;
  110. ',
  111. ],
  112. [
  113. '<?php
  114. if (true)
  115. echo 4;
  116. ?><?php echo 5;',
  117. '<?php
  118. if (true)
  119. echo 4;
  120. else?><?php echo 5;',
  121. ],
  122. ];
  123. }
  124. /**
  125. * @param string $expected
  126. * @param null|string $input
  127. *
  128. * @dataProvider provideFixIfElseIfElseCases
  129. */
  130. public function testFixIfElseIfElse($expected, $input = null)
  131. {
  132. $this->doTest($expected, $input);
  133. }
  134. public function provideFixIfElseIfElseCases()
  135. {
  136. $expected =
  137. '<?php
  138. while(true) {
  139. while(true) {
  140. if ($provideFixIfElseIfElseCases) {
  141. return;
  142. } elseif($a1) {
  143. if ($b) {echo 1; die;} echo 552;
  144. return 1;
  145. } elseif($b) {
  146. %s
  147. } '.'
  148. echo 662;
  149. '.'
  150. }
  151. }
  152. ';
  153. $input =
  154. '<?php
  155. while(true) {
  156. while(true) {
  157. if ($provideFixIfElseIfElseCases) {
  158. return;
  159. } elseif($a1) {
  160. if ($b) {echo 1; die;} else {echo 552;}
  161. return 1;
  162. } elseif($b) {
  163. %s
  164. } else {
  165. echo 662;
  166. }
  167. }
  168. }
  169. ';
  170. $cases = $this->generateCases($expected, $input);
  171. $expected =
  172. '<?php
  173. while(true) {
  174. while(true) {
  175. if($a) {
  176. echo 100;
  177. } elseif($b) {
  178. %s
  179. } else {
  180. echo 3;
  181. }
  182. }
  183. }
  184. ';
  185. $cases = array_merge($cases, $this->generateCases($expected));
  186. $expected =
  187. '<?php
  188. while(true) {
  189. while(true) {
  190. if ($a) {
  191. echo 100;
  192. } elseif ($a1) {
  193. echo 99887;
  194. } elseif ($b) {
  195. echo $b+1; //
  196. /* test */
  197. %s
  198. } else {
  199. echo 321;
  200. }
  201. }
  202. }
  203. ';
  204. $cases = array_merge($cases, $this->generateCases($expected));
  205. $cases[] = [
  206. '<?php
  207. if ($a)
  208. echo 1789;
  209. else if($b)
  210. echo 256;
  211. elseif($c)
  212. echo 3;
  213. if ($a) {
  214. }elseif($d) {
  215. return 1;
  216. }
  217. else
  218. echo 4;
  219. ', ];
  220. $cases[] = [
  221. '<?php
  222. if ($a)
  223. echo 1789;
  224. else if($b) {
  225. echo 256;
  226. } elseif($c) {
  227. echo 3;
  228. if ($d) {
  229. echo 4;
  230. } elseif($e)
  231. return 1;
  232. } else
  233. echo 4;
  234. ', ];
  235. return $cases;
  236. }
  237. /**
  238. * @param string $expected
  239. * @param null|string $input
  240. *
  241. * @dataProvider provideFixIfElseCases
  242. */
  243. public function testFixIfElse($expected, $input = null)
  244. {
  245. $this->doTest($expected, $input);
  246. }
  247. public function provideFixIfElseCases()
  248. {
  249. $expected =
  250. '<?php
  251. while(true) {
  252. while(true) {
  253. if ($a) {
  254. %s
  255. } '.'
  256. echo 1;
  257. '.'
  258. }
  259. }
  260. ';
  261. $input =
  262. '<?php
  263. while(true) {
  264. while(true) {
  265. if ($a) {
  266. %s
  267. } else {
  268. echo 1;
  269. }
  270. }
  271. }
  272. ';
  273. $cases = $this->generateCases($expected, $input);
  274. $cases[] = [
  275. '<?php
  276. if ($a) {
  277. GOTO jump;
  278. } '.'
  279. echo 1789;
  280. '.'
  281. jump:
  282. ',
  283. '<?php
  284. if ($a) {
  285. GOTO jump;
  286. } else {
  287. echo 1789;
  288. }
  289. jump:
  290. ',
  291. ];
  292. return $cases;
  293. }
  294. /**
  295. * @param string $expected
  296. * @param null|string $input
  297. *
  298. * @dataProvider provideFixNestedIfCases
  299. */
  300. public function testFixNestedIf($expected, $input = null)
  301. {
  302. $this->doTest($expected, $input);
  303. }
  304. public function provideFixNestedIfCases()
  305. {
  306. return [
  307. [
  308. '<?php
  309. if ($x) {
  310. if ($y) {
  311. return 1;
  312. } '.'
  313. return 2;
  314. '.'
  315. } '.'
  316. return 3;
  317. '.'
  318. ',
  319. '<?php
  320. if ($x) {
  321. if ($y) {
  322. return 1;
  323. } else {
  324. return 2;
  325. }
  326. } else {
  327. return 3;
  328. }
  329. ',
  330. ],
  331. ];
  332. }
  333. /**
  334. * @param string $expected
  335. * @param null|string $input
  336. *
  337. * @dataProvider provideFixEmptyElseCases
  338. */
  339. public function testFixEmptyElse($expected, $input = null)
  340. {
  341. $this->doTest($expected, $input);
  342. }
  343. public function provideFixEmptyElseCases()
  344. {
  345. return [
  346. [
  347. '<?php
  348. if (false)
  349. echo 1;
  350. '.'
  351. ',
  352. '<?php
  353. if (false)
  354. echo 1;
  355. else{}
  356. ',
  357. ],
  358. [
  359. '<?php if($a){}',
  360. '<?php if($a){}else{}',
  361. ],
  362. [
  363. '<?php if($a){ $a = ($b); } ',
  364. '<?php if($a){ $a = ($b); } else {}',
  365. ],
  366. [
  367. '<?php if ($a) {;} if ($a) {;} /**/ if($a){}',
  368. '<?php if ($a) {;} else {} if ($a) {;} else {/**/} if($a){}else{}',
  369. ],
  370. [
  371. '<?php
  372. if /**/($a) /**/{ //
  373. /**/
  374. /**/return/**/1/**/;
  375. //
  376. }/**/ /**/
  377. /**/
  378. //
  379. /**/
  380. ',
  381. '<?php
  382. if /**/($a) /**/{ //
  383. /**/
  384. /**/return/**/1/**/;
  385. //
  386. }/**/ else /**/{
  387. /**/
  388. //
  389. }/**/
  390. ',
  391. ],
  392. [
  393. '<?php
  394. if ($a) {
  395. if ($b) {
  396. if ($c) {
  397. } elseif ($d) {
  398. return;
  399. } //
  400. //
  401. return;
  402. } //
  403. //
  404. return;
  405. } //
  406. //
  407. ',
  408. '<?php
  409. if ($a) {
  410. if ($b) {
  411. if ($c) {
  412. } elseif ($d) {
  413. return;
  414. } else {//
  415. }//
  416. return;
  417. } else {//
  418. }//
  419. return;
  420. } else {//
  421. }//
  422. ',
  423. ],
  424. ];
  425. }
  426. /**
  427. * @param string $expected
  428. *
  429. * @dataProvider provideNegativeCases
  430. */
  431. public function testNegativeCases($expected)
  432. {
  433. $this->doTest($expected);
  434. }
  435. public function provideNegativeCases()
  436. {
  437. return [
  438. [
  439. '<?php
  440. if ($a0) {
  441. //
  442. } else {
  443. echo 0;
  444. }
  445. ',
  446. ],
  447. [
  448. '<?php
  449. if (false)
  450. echo "a";
  451. else
  452. echo "a";
  453. ',
  454. ],
  455. [
  456. '<?php if($a2){;} else {echo 27;}',
  457. ],
  458. [
  459. '<?php if ($a3) {test();} else {echo 3;}',
  460. ],
  461. [
  462. '<?php if ($a4) {$b = function () {};} else {echo 4;}',
  463. ],
  464. [
  465. '<?php if ($a5) {$b = function () use ($a){};} else {echo 5;}',
  466. ],
  467. [
  468. '<?php
  469. if ($a) {
  470. if ($b) return;
  471. } else {
  472. echo 1;
  473. }
  474. ',
  475. ],
  476. [
  477. '<?php
  478. if ($a) {
  479. if ($b) throw new \Exception();
  480. } else {
  481. echo 1;
  482. }
  483. ',
  484. ],
  485. [
  486. '<?php
  487. if ($a) {
  488. if ($b) { throw new \Exception(); }
  489. } else {
  490. echo 1;
  491. }
  492. ',
  493. ],
  494. [
  495. '<?php
  496. $a = true; // 6
  497. if (true === $a)
  498. $b = true === $a ? 1 : die;
  499. else
  500. echo 40;
  501. echo "end";
  502. ',
  503. ],
  504. [
  505. '<?php
  506. $a = true; // 6
  507. if (true === $a)
  508. $b = true === $a ? 1 : exit(1);
  509. else
  510. echo 40;
  511. echo "end";
  512. ',
  513. ],
  514. [
  515. '<?php
  516. $a = true; // 6
  517. if (true === $a)
  518. $b = true === $a ? 1 : exit(1);
  519. else
  520. echo 4;
  521. echo "end";
  522. ',
  523. ],
  524. [
  525. '<?php
  526. if (false)
  527. die;
  528. elseif (true)
  529. if(true)echo 777;else die;
  530. else if (true)
  531. die;
  532. elseif (false)
  533. die;
  534. else
  535. echo 7;
  536. ',
  537. ],
  538. [
  539. '<?php
  540. $tmp = function($b){$b();};
  541. $a =1;
  542. return $tmp(function () use ($a) {
  543. if ($a) {
  544. $a++;
  545. } else {
  546. $a--;
  547. }
  548. });
  549. ',
  550. ],
  551. [
  552. '<?php
  553. $tmp = function($b){$b();};
  554. $a =1;
  555. return $tmp(function () use ($a) {
  556. if ($a) {
  557. $a++;
  558. } elseif($a > 2) {
  559. return 1;
  560. } else {
  561. $a--;
  562. }
  563. });
  564. ',
  565. ],
  566. [
  567. '<?php
  568. return function() {
  569. if (false) {
  570. } elseif (3 > 2) {
  571. } else {
  572. echo 1;
  573. }
  574. };',
  575. ],
  576. [
  577. '<?php
  578. return function() {
  579. if (false) {
  580. return 1;
  581. } elseif (3 > 2) {
  582. } else {
  583. echo 1;
  584. }
  585. };',
  586. ],
  587. ];
  588. }
  589. /**
  590. * @param string $source
  591. * @param int $index
  592. *
  593. * @dataProvider provideBlockDetectionCases
  594. */
  595. public function testBlockDetection(array $expected, $source, $index)
  596. {
  597. Tokens::clearCache();
  598. $tokens = Tokens::fromCode($source);
  599. $method = new \ReflectionMethod($this->fixer, 'getPreviousBlock');
  600. $method->setAccessible(true);
  601. $result = $method->invoke($this->fixer, $tokens, $index);
  602. $this->assertSame($expected, $result);
  603. }
  604. public function provideBlockDetectionCases()
  605. {
  606. $cases = [];
  607. $source = '<?php
  608. if ($a)
  609. echo 1;
  610. elseif ($a) ///
  611. echo 2;
  612. else if ($b) /**/ echo 3;
  613. else
  614. echo 4;
  615. ';
  616. $cases[] = [[2, 11], $source, 13];
  617. $cases[] = [[13, 24], $source, 26];
  618. $cases[] = [[13, 24], $source, 26];
  619. $cases[] = [[26, 39], $source, 41];
  620. $source = '<?php
  621. if ($a) {
  622. if ($b) {
  623. }
  624. echo 1;
  625. } elseif (true) {
  626. echo 2;
  627. } else if (false) {
  628. echo 3;
  629. } elseif ($c) {
  630. echo 4;
  631. } else
  632. echo 1;
  633. ';
  634. $cases[] = [[2, 25], $source, 27];
  635. $cases[] = [[27, 40], $source, 42];
  636. $cases[] = [[59, 72], $source, 74];
  637. return $cases;
  638. }
  639. /**
  640. * @param string $expected
  641. * @param null|string $input
  642. *
  643. * @dataProvider provideConditionsWithoutBracesCases
  644. */
  645. public function testConditionsWithoutBraces($expected, $input = null)
  646. {
  647. $this->doTest($expected, $input);
  648. }
  649. public function provideConditionsWithoutBracesCases()
  650. {
  651. $cases = [];
  652. $statements = [
  653. 'die;',
  654. 'throw new Exception($i);',
  655. 'while($i < 1) throw/*{}*/new Exception($i);',
  656. 'while($i < 1){throw new Exception($i);}',
  657. 'do{throw new Exception($i);}while($i < 1);',
  658. 'foreach($a as $b)throw new Exception($i);',
  659. 'foreach($a as $b){throw new Exception($i);}',
  660. ];
  661. $ifTemplate = '<?php
  662. if ($a === false)
  663. {
  664. if ($v) %s
  665. }
  666. else
  667. $ret .= $value;
  668. return $ret;'
  669. ;
  670. $ifElseIfTemplate = '<?php
  671. if ($a === false)
  672. {
  673. if ($v) { $ret = "foo"; }
  674. elseif($a)
  675. %s
  676. }
  677. else
  678. $ret .= $value;
  679. return $ret;'
  680. ;
  681. $ifElseTemplate = '<?php
  682. if ($a === false)
  683. {
  684. if ($v) { $ret = "foo"; }
  685. else
  686. %s
  687. }
  688. else
  689. $ret .= $value;
  690. return $ret;'
  691. ;
  692. foreach ($statements as $statement) {
  693. $cases[] = [sprintf($ifTemplate, $statement)];
  694. $cases[] = [sprintf($ifElseTemplate, $statement)];
  695. $cases[] = [sprintf($ifElseIfTemplate, $statement)];
  696. }
  697. $cases[] = [
  698. '<?php
  699. if ($a === false)
  700. {
  701. if ($v) { $ret = "foo"; if($d){return 1;}echo $a;}
  702. }
  703. else
  704. $ret .= $value;
  705. return $ret;',
  706. '<?php
  707. if ($a === false)
  708. {
  709. if ($v) { $ret = "foo"; if($d){return 1;}else{echo $a;}}
  710. }
  711. else
  712. $ret .= $value;
  713. return $ret;',
  714. ];
  715. return $cases;
  716. }
  717. /**
  718. * @param string $input
  719. * @param string<int, bool> $indexes
  720. *
  721. * @dataProvider provideIsInConditionWithoutBracesCases
  722. */
  723. public function testIsInConditionWithoutBraces($indexes, $input)
  724. {
  725. $reflection = new \ReflectionObject($this->fixer);
  726. $method = $reflection->getMethod('isInConditionWithoutBraces');
  727. $method->setAccessible(true);
  728. $tokens = Tokens::fromCode($input);
  729. foreach ($indexes as $index => $expected) {
  730. $this->assertSame(
  731. $expected,
  732. $method->invoke($this->fixer, $tokens, $index, 0),
  733. sprintf('Failed in condition without braces check for index %d', $index)
  734. );
  735. }
  736. }
  737. public function provideIsInConditionWithoutBracesCases()
  738. {
  739. return [
  740. [
  741. [
  742. 18 => false, // return
  743. 25 => false, // return
  744. 36 => false, // return
  745. ],
  746. '<?php
  747. if ($x) {
  748. if ($y) {
  749. return 1;
  750. }
  751. return 2;
  752. } else {
  753. return 3;
  754. }
  755. ',
  756. ],
  757. [
  758. [
  759. 0 => false,
  760. 29 => false, // throw
  761. ],
  762. '<?php
  763. if ($v) { $ret = "foo"; }
  764. else
  765. if($a){}else{throw new Exception($i);}
  766. ',
  767. ],
  768. [
  769. [
  770. 0 => false,
  771. 38 => true, // throw
  772. ],
  773. '<?php
  774. if ($v) { $ret = "foo"; }
  775. else
  776. for($i =0;$i < 1;++$i) throw new Exception($i);
  777. ',
  778. ],
  779. [
  780. [
  781. 0 => false,
  782. 26 => true, // throw
  783. 28 => true, // new
  784. 30 => true, // Exception
  785. ],
  786. '<?php
  787. if ($v) { $ret = "foo"; }
  788. else
  789. while(false){throw new Exception($i);}
  790. ',
  791. ],
  792. [
  793. [
  794. 0 => false,
  795. 30 => true, // throw
  796. 32 => true, // new
  797. 34 => true, // Exception
  798. ],
  799. '<?php
  800. if ($v) { $ret = "foo"; }
  801. else
  802. foreach($a as $b){throw new Exception($i);}
  803. ',
  804. ],
  805. [
  806. [
  807. 0 => false,
  808. 25 => true, // throw
  809. 27 => true, // new
  810. 29 => true, // Exception
  811. ],
  812. '<?php
  813. if ($v) { $ret = "foo"; }
  814. else
  815. while(false)throw new Exception($i);
  816. ',
  817. ],
  818. [
  819. [
  820. 26 => true, // throw
  821. ],
  822. '<?php
  823. if ($v) { $ret = "foo"; }
  824. elseif($a)
  825. do{throw new Exception($i);}while(false);
  826. ',
  827. ],
  828. [
  829. [
  830. 4 => false, // 1
  831. 13 => true, // if (2nd)
  832. 21 => true, // true
  833. 33 => true, // while
  834. 43 => false, // echo
  835. 45 => false, // 2
  836. 46 => false, // ;
  837. 51 => false, // echo (123)
  838. ],
  839. '<?php
  840. echo 1;
  841. if ($a) if ($a) while(true)echo 1;
  842. elseif($c) while(true){if($d){echo 2;}};
  843. echo 123;
  844. ',
  845. ],
  846. [
  847. [
  848. 2 => false, // echo
  849. 13 => true, // echo
  850. 15 => true, // 2
  851. 20 => true, // die
  852. 23 => false, // echo
  853. ],
  854. '<?php
  855. echo 1;
  856. if ($a) echo 2;
  857. else die; echo 3;
  858. ',
  859. ],
  860. [
  861. [
  862. 8 => true, // die
  863. 9 => true, // /**/
  864. 15 => true, // die
  865. ],
  866. '<?php
  867. if ($a)
  868. die/**/;
  869. else
  870. /**/die/**/;#
  871. ',
  872. ],
  873. [
  874. [
  875. 8 => true, // die
  876. 9 => true, // /**/
  877. 15 => true, // die
  878. ],
  879. '<?php
  880. if ($a)
  881. die/**/;
  882. else
  883. /**/die/**/?>
  884. ',
  885. ],
  886. ];
  887. }
  888. /**
  889. * @param string $expected
  890. * @param null|string $input
  891. *
  892. * @return array<string, string>
  893. */
  894. private function generateCases($expected, $input = null)
  895. {
  896. $cases = [];
  897. foreach ([
  898. 'exit;',
  899. 'exit();',
  900. 'exit(1);',
  901. 'die;',
  902. 'die();',
  903. 'die(1);',
  904. 'break;',
  905. 'break 2;',
  906. 'break (2);',
  907. 'continue;',
  908. 'continue 2;',
  909. 'continue (2);',
  910. 'return;',
  911. 'return 1;',
  912. 'return (1);',
  913. 'return "a";',
  914. 'return 8+2;',
  915. 'return null;',
  916. 'return sum(1+8*6, 2);',
  917. 'throw $e;',
  918. 'throw ($e);',
  919. 'throw new \Exception;',
  920. 'throw new \Exception();',
  921. 'throw new \Exception((string)12+1);',
  922. ] as $case) {
  923. if (null === $input) {
  924. $cases[] = [sprintf($expected, $case)];
  925. $cases[] = [sprintf($expected, strtoupper($case))];
  926. $cases[] = [sprintf($expected, strtolower($case))];
  927. } else {
  928. $cases[] = [sprintf($expected, $case), sprintf($input, $case)];
  929. $cases[] = [sprintf($expected, strtoupper($case)), sprintf($input, strtoupper($case))];
  930. $cases[] = [sprintf($expected, strtolower($case)), sprintf($input, strtolower($case))];
  931. }
  932. }
  933. return $cases;
  934. }
  935. }