SingleClassElementPerStatementFixerTest.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4. * This file is part of PHP CS Fixer.
  5. *
  6. * (c) Fabien Potencier <fabien@symfony.com>
  7. * Dariusz Rumiński <dariusz.ruminski@gmail.com>
  8. *
  9. * This source file is subject to the MIT license that is bundled
  10. * with this source code in the file LICENSE.
  11. */
  12. namespace PhpCsFixer\Tests\Fixer\ClassNotation;
  13. use PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException;
  14. use PhpCsFixer\Tests\Test\AbstractFixerTestCase;
  15. use PhpCsFixer\WhitespacesFixerConfig;
  16. /**
  17. * @author Javier Spagnoletti <phansys@gmail.com>
  18. *
  19. * @internal
  20. *
  21. * @covers \PhpCsFixer\Fixer\ClassNotation\SingleClassElementPerStatementFixer
  22. */
  23. final class SingleClassElementPerStatementFixerTest extends AbstractFixerTestCase
  24. {
  25. /**
  26. * @param array<string, string> $configuration
  27. *
  28. * @dataProvider provideFixCases
  29. */
  30. public function testFix(string $expected, ?string $input = null, array $configuration = []): void
  31. {
  32. $this->fixer->configure($configuration);
  33. $this->doTest($expected, $input);
  34. }
  35. public static function provideFixCases(): iterable
  36. {
  37. yield [
  38. '<?php
  39. class Foo
  40. {
  41. private static $bar1 = array(1,2,3);
  42. private static $bar2 = [1,2,3];
  43. private static $baz1 = array(array(1,2), array(3, 4));
  44. private static $baz2 = array(1,2,3);
  45. private static $aaa1 = 1;
  46. private static $aaa2 = array(2, 2);
  47. private static $aaa3 = 3;
  48. }',
  49. '<?php
  50. class Foo
  51. {
  52. private static $bar1 = array(1,2,3), $bar2 = [1,2,3];
  53. private static $baz1 = array(array(1,2), array(3, 4)), $baz2 = array(1,2,3);
  54. private static $aaa1 = 1, $aaa2 = array(2, 2), $aaa3 = 3;
  55. }',
  56. ];
  57. yield [
  58. '<?php
  59. class Foo
  60. {
  61. const A = 1;
  62. const B = 2;
  63. }
  64. echo Foo::A, Foo::B;
  65. ',
  66. '<?php
  67. class Foo
  68. {
  69. const A = 1, B = 2;
  70. }
  71. echo Foo::A, Foo::B;
  72. ',
  73. ];
  74. yield [
  75. <<<'EOT'
  76. <?php
  77. class Foo { protected static $foo = 1; protected static $bar; protected static $baz=2 ; }
  78. EOT
  79. , <<<'EOT'
  80. <?php
  81. class Foo { protected static $foo = 1,$bar,$baz=2 ; }
  82. EOT
  83. ];
  84. yield [
  85. <<<'EOT'
  86. <?php
  87. class Foo {}
  88. class Bar
  89. {
  90. }
  91. EOT
  92. ];
  93. yield [
  94. <<<'EOT'
  95. <?php
  96. class Foo { protected static $foo = 1; protected static $bar; protected static $baz=2 ; }
  97. EOT
  98. , <<<'EOT'
  99. <?php
  100. class Foo { protected static $foo = 1, $bar, $baz=2 ; }
  101. EOT
  102. ];
  103. yield [
  104. <<<'EOT'
  105. <?php
  106. class Foo { const ONE = 1; const TWO = 2; protected static $foo = 1; protected static $bar; protected static $baz=2 ; const THREE = 3; }
  107. EOT
  108. , <<<'EOT'
  109. <?php
  110. class Foo { const ONE = 1, TWO = 2; protected static $foo = 1, $bar, $baz=2 ; const THREE = 3; }
  111. EOT
  112. ];
  113. yield [
  114. <<<'EOT'
  115. <?php
  116. class Foo {
  117. protected static $foo = 1;
  118. protected static $bar;
  119. protected static $baz=2;
  120. }
  121. EOT
  122. , <<<'EOT'
  123. <?php
  124. class Foo {
  125. protected static $foo = 1,
  126. $bar,
  127. $baz=2;
  128. }
  129. EOT
  130. ];
  131. yield [
  132. <<<'EOT'
  133. <?php
  134. class Foo {
  135. /**
  136. * Some great docblock
  137. */
  138. protected static $foo = 1;
  139. protected static $bar;
  140. protected static $baz=2;
  141. }
  142. EOT
  143. , <<<'EOT'
  144. <?php
  145. class Foo {
  146. /**
  147. * Some great docblock
  148. */
  149. protected static $foo = 1,
  150. $bar,
  151. $baz=2;
  152. }
  153. EOT
  154. ];
  155. yield [
  156. <<<'EOT'
  157. <?php
  158. class Foo {
  159. /**
  160. * @int
  161. */
  162. protected static $foo = 1;
  163. protected static $bar;
  164. protected static $baz=2;
  165. // this is an inline comment, not a docblock
  166. private $var = false;
  167. }
  168. EOT
  169. , <<<'EOT'
  170. <?php
  171. class Foo {
  172. /**
  173. * @int
  174. */
  175. protected static $foo = 1,
  176. $bar,
  177. $baz=2;
  178. // this is an inline comment, not a docblock
  179. private $var = false;
  180. }
  181. EOT
  182. ];
  183. yield [
  184. <<<'EOT'
  185. <?php
  186. class Foo {
  187. /**
  188. * @int
  189. */
  190. protected static $foo = 1;
  191. protected static $bar;
  192. protected static $baz=2;
  193. function doSomething()
  194. {
  195. }
  196. }
  197. EOT
  198. , <<<'EOT'
  199. <?php
  200. class Foo {
  201. /**
  202. * @int
  203. */
  204. protected static $foo = 1,
  205. $bar,
  206. $baz=2;
  207. function doSomething()
  208. {
  209. }
  210. }
  211. EOT
  212. ];
  213. yield 'line_breaks_1' => [
  214. <<<'EOT'
  215. <?php
  216. class Foo
  217. {
  218. public $bar = null;
  219. public $initialized = false;
  220. public $configured = false;
  221. public $called = false;
  222. public $arguments = array();
  223. public $baz = null;
  224. public $drop = false;
  225. function doSomething()
  226. {
  227. }
  228. }
  229. EOT
  230. , <<<'EOT'
  231. <?php
  232. class Foo
  233. {
  234. public $bar = null, $initialized = false, $configured = false, $called = false, $arguments = array();
  235. public $baz = null, $drop = false;
  236. function doSomething()
  237. {
  238. }
  239. }
  240. EOT
  241. ];
  242. yield 'line_breaks_2' => [
  243. <<<'EOT'
  244. <?php
  245. class Foo
  246. {
  247. const TWO = '2';
  248. public $bar = null;
  249. public $initialized = false;
  250. function doSomething()
  251. {
  252. }
  253. }
  254. EOT
  255. , <<<'EOT'
  256. <?php
  257. class Foo
  258. {
  259. const TWO = '2';
  260. public $bar = null, $initialized = false;
  261. function doSomething()
  262. {
  263. }
  264. }
  265. EOT
  266. ];
  267. yield 'line_breaks_3' => [
  268. <<<'EOT'
  269. <?php
  270. class Foo
  271. {
  272. const TWO = '2';
  273. public $bar = null;
  274. public $initialized = false;
  275. function doSomething()
  276. {
  277. }
  278. }
  279. EOT
  280. , <<<'EOT'
  281. <?php
  282. class Foo
  283. {
  284. const TWO = '2';
  285. public $bar = null, $initialized = false;
  286. function doSomething()
  287. {
  288. }
  289. }
  290. EOT
  291. ];
  292. yield 'line_breaks_4' => [
  293. <<<'EOT'
  294. <?php
  295. class Foo
  296. {
  297. public $one = 1;
  298. public $bar = null;
  299. public $initialized = false;
  300. public $configured = false;
  301. public $called = false;
  302. public $arguments = array();
  303. function doSomething()
  304. {
  305. }
  306. }
  307. EOT
  308. , <<<'EOT'
  309. <?php
  310. class Foo
  311. {
  312. public $one = 1;
  313. public $bar = null, $initialized = false, $configured = false, $called = false, $arguments = array();
  314. function doSomething()
  315. {
  316. }
  317. }
  318. EOT
  319. ];
  320. yield 'line_breaks_5' => [
  321. <<<'EOT'
  322. <?php
  323. class Foo
  324. {
  325. public $one = 1; public $bar = null; public $initialized = false; public $configured = false; public $called = false; public $arguments = array();
  326. function doSomething()
  327. {
  328. }
  329. }
  330. EOT
  331. , <<<'EOT'
  332. <?php
  333. class Foo
  334. {
  335. public $one = 1; public $bar = null, $initialized = false, $configured = false, $called = false, $arguments = array();
  336. function doSomething()
  337. {
  338. }
  339. }
  340. EOT
  341. ];
  342. yield 'line_breaks_6' => [
  343. <<<'EOT'
  344. <?php
  345. class Foo
  346. {
  347. public $one = 1;public $bar = null;public $initialized = false;public $configured = false;public $called = false;public $arguments = array();
  348. function doSomething()
  349. {
  350. }
  351. }
  352. EOT
  353. , <<<'EOT'
  354. <?php
  355. class Foo
  356. {
  357. public $one = 1;public $bar = null, $initialized = false, $configured = false, $called = false, $arguments = array();
  358. function doSomething()
  359. {
  360. }
  361. }
  362. EOT
  363. ];
  364. yield 'whitespace_1' => [
  365. <<<'EOT'
  366. <?php
  367. class Foo { public $one = 1; public $bar = null; public $initialized = false; public $configured = false; public $called = false; public $arguments = array();
  368. function doSomething()
  369. {
  370. }
  371. }
  372. EOT
  373. , <<<'EOT'
  374. <?php
  375. class Foo { public $one = 1; public $bar = null,$initialized = false,$configured = false,$called = false,$arguments = array();
  376. function doSomething()
  377. {
  378. }
  379. }
  380. EOT
  381. ];
  382. yield 'whitespace_2' => [
  383. <<<'EOT'
  384. <?php
  385. class Foo { public $one = 1; public $bar = null; public $initialized = false; public $configured = false; public $called=false; public $arguments = array();
  386. function doSomething()
  387. {
  388. }
  389. }
  390. EOT
  391. , <<<'EOT'
  392. <?php
  393. class Foo { public $one = 1; public $bar = null,$initialized = false,$configured = false,$called=false,$arguments = array();
  394. function doSomething()
  395. {
  396. }
  397. }
  398. EOT
  399. ];
  400. yield [
  401. <<<'EOT'
  402. <?php
  403. class Foo { protected static $foo = 1; protected static $bar; protected static $baz=1; }
  404. EOT
  405. , <<<'EOT'
  406. <?php
  407. class Foo { protected static $foo = 1, $bar, $baz=1; }
  408. EOT
  409. ];
  410. yield [
  411. <<<'EOT'
  412. <?php
  413. class Foo { protected static $foo = 1; protected static $bar; protected static $baz=1; }
  414. EOT
  415. , <<<'EOT'
  416. <?php
  417. class Foo { protected static $foo = 1, $bar, $baz=1; }
  418. EOT
  419. ];
  420. yield [
  421. <<<'EOT'
  422. <?php
  423. class Foo { protected $foo = 1; protected $bar; protected $baz=2; }
  424. EOT
  425. , <<<'EOT'
  426. <?php
  427. class Foo { protected $foo = 1, $bar, $baz=2; }
  428. EOT
  429. ];
  430. yield [
  431. <<<'EOT'
  432. <?php
  433. class Foo { var $foo = 1; var $bar; var $baz=2; }
  434. EOT
  435. , <<<'EOT'
  436. <?php
  437. class Foo { var $foo = 1, $bar, $baz=2; }
  438. EOT
  439. ];
  440. yield [
  441. <<<'EOT'
  442. <?php
  443. class Foo { var $foo = 1; var $bar; public function doSomething1() {} var $baz=2; }
  444. EOT
  445. , <<<'EOT'
  446. <?php
  447. class Foo { var $foo = 1, $bar; public function doSomething1() {} var $baz=2; }
  448. EOT
  449. ];
  450. yield [
  451. <<<'EOT'
  452. <?php
  453. class Foo { var $foo = 1; var $bar; public function doSomething2() { global $one, $two, $three; } var $baz=2; }
  454. EOT
  455. , <<<'EOT'
  456. <?php
  457. class Foo { var $foo = 1, $bar; public function doSomething2() { global $one, $two, $three; } var $baz=2; }
  458. EOT
  459. ];
  460. yield [
  461. <<<'EOT'
  462. <?php
  463. class Foo { public function doSomething3() {} protected $foo = 1; protected $bar; protected $baz=2; }
  464. EOT
  465. , <<<'EOT'
  466. <?php
  467. class Foo { public function doSomething3() {} protected $foo = 1, $bar, $baz=2; }
  468. EOT
  469. ];
  470. yield [
  471. <<<'EOT'
  472. <?php
  473. class Foo { public function doSomethingElse() {} protected $foo = 1; protected $bar; protected $baz=2; private $acme =array(); }
  474. EOT
  475. , <<<'EOT'
  476. <?php
  477. class Foo { public function doSomethingElse() {} protected $foo = 1, $bar, $baz=2; private $acme =array(); }
  478. EOT
  479. ];
  480. yield [
  481. <<<'EOT'
  482. <?php
  483. class Foo { public function doSomewhere() {} protected $foo = 1; protected $bar; protected $baz=2; private $acme1 =array(); }
  484. EOT
  485. , <<<'EOT'
  486. <?php
  487. class Foo { public function doSomewhere() {} protected $foo = 1, $bar, $baz=2; private $acme1 =array(); }
  488. EOT
  489. ];
  490. yield [
  491. <<<'EOT'
  492. <?php
  493. class Foo { public function doThis() { global $one1, $two2, $three3; } protected $foo = 1; protected $bar; protected $baz=2; private $acme2 =array(); }
  494. EOT
  495. , <<<'EOT'
  496. <?php
  497. class Foo { public function doThis() { global $one1, $two2, $three3; } protected $foo = 1, $bar, $baz=2; private $acme2 =array(); }
  498. EOT
  499. ];
  500. yield [
  501. '<?php
  502. class Foo
  503. {
  504. const A = 1;
  505. const #
  506. B#
  507. =#
  508. 2#
  509. ;#
  510. }
  511. echo Foo::A, Foo::B;
  512. ',
  513. '<?php
  514. class Foo
  515. {
  516. const A = 1,#
  517. B#
  518. =#
  519. 2#
  520. ;#
  521. }
  522. echo Foo::A, Foo::B;
  523. ',
  524. ];
  525. yield [
  526. '<?php
  527. class Token {
  528. const PUBLIC_CONST = 0;
  529. private const PRIVATE_CONST = 0;
  530. protected const PROTECTED_CONST = 0;
  531. public const PUBLIC_CONST_TWO = 0;
  532. public const TEST_71 = 0;
  533. }
  534. ',
  535. '<?php
  536. class Token {
  537. const PUBLIC_CONST = 0;
  538. private const PRIVATE_CONST = 0;
  539. protected const PROTECTED_CONST = 0;
  540. public const PUBLIC_CONST_TWO = 0, TEST_71 = 0;
  541. }
  542. ',
  543. ];
  544. yield [
  545. '<?php class Foo {
  546. private int $foo;
  547. private int $bar;
  548. }',
  549. '<?php class Foo {
  550. private int $foo, $bar;
  551. }',
  552. ];
  553. yield [
  554. '<?php class Foo {
  555. protected ?string $foo;
  556. protected ?string $bar;
  557. }',
  558. '<?php class Foo {
  559. protected ?string $foo, $bar;
  560. }',
  561. ];
  562. yield [
  563. '<?php class Foo {
  564. public ? string $foo;
  565. public ? string $bar;
  566. }',
  567. '<?php class Foo {
  568. public ? string $foo, $bar;
  569. }',
  570. ];
  571. yield [
  572. '<?php class Foo {
  573. var ? Foo\Bar $foo;
  574. var ? Foo\Bar $bar;
  575. }',
  576. '<?php class Foo {
  577. var ? Foo\Bar $foo, $bar;
  578. }',
  579. ];
  580. yield [
  581. '<?php class Foo {
  582. var array $foo;
  583. var array $bar;
  584. }',
  585. '<?php class Foo {
  586. var array $foo, $bar;
  587. }',
  588. ];
  589. yield [
  590. <<<'EOT'
  591. <?php
  592. class Foo
  593. {
  594. const SOME_CONST = 'a';
  595. const OTHER_CONST = 'b';
  596. protected static $foo = 1;
  597. protected static $bar = 2;
  598. }
  599. EOT,
  600. <<<'EOT'
  601. <?php
  602. class Foo
  603. {
  604. const SOME_CONST = 'a', OTHER_CONST = 'b';
  605. protected static $foo = 1, $bar = 2;
  606. }
  607. EOT,
  608. ['elements' => ['const', 'property']],
  609. ];
  610. yield [
  611. <<<'EOT'
  612. <?php
  613. class Foo
  614. {
  615. const SOME_CONST = 'a';
  616. const OTHER_CONST = 'b';
  617. protected static $foo = 1, $bar = 2;
  618. }
  619. EOT,
  620. <<<'EOT'
  621. <?php
  622. class Foo
  623. {
  624. const SOME_CONST = 'a', OTHER_CONST = 'b';
  625. protected static $foo = 1, $bar = 2;
  626. }
  627. EOT,
  628. ['elements' => ['const']],
  629. ];
  630. yield [
  631. <<<'EOT'
  632. <?php
  633. class Foo
  634. {
  635. const SOME_CONST = 'a', OTHER_CONST = 'b';
  636. protected static $foo = 1;
  637. protected static $bar = 2;
  638. }
  639. EOT,
  640. <<<'EOT'
  641. <?php
  642. class Foo
  643. {
  644. const SOME_CONST = 'a', OTHER_CONST = 'b';
  645. protected static $foo = 1, $bar = 2;
  646. }
  647. EOT,
  648. ['elements' => ['property']],
  649. ];
  650. yield 'anonymous class' => [
  651. '<?php
  652. $a = new class() {
  653. const PUBLIC_CONST_TWO = 0;
  654. const TEST_70 = 0;
  655. public function a() {
  656. }
  657. };
  658. class C
  659. {
  660. public function A()
  661. {
  662. $a = new class() {
  663. const PUBLIC_CONST_TWO = 0;
  664. const TEST_70 = 0;
  665. public function a() {}
  666. };
  667. }
  668. }
  669. ',
  670. '<?php
  671. $a = new class() {
  672. const PUBLIC_CONST_TWO = 0, TEST_70 = 0;
  673. public function a() {
  674. }
  675. };
  676. class C
  677. {
  678. public function A()
  679. {
  680. $a = new class() {
  681. const PUBLIC_CONST_TWO = 0, TEST_70 = 0;
  682. public function a() {}
  683. };
  684. }
  685. }
  686. ',
  687. ];
  688. }
  689. public function testWithWhitespacesConfig(): void
  690. {
  691. $this->fixer->setWhitespacesConfig(new WhitespacesFixerConfig("\t", "\r\n"));
  692. $this->doTest(
  693. "<?php\r\n\tclass Foo {\r\n\t\tconst AAA=0;\r\n\t\tconst BBB=1;\r\n\t}",
  694. "<?php\r\n\tclass Foo {\r\n\t\tconst AAA=0, BBB=1;\r\n\t}",
  695. );
  696. }
  697. /**
  698. * @dataProvider provideFix80Cases
  699. *
  700. * @requires PHP 8.0
  701. */
  702. public function testFix80(string $expected, string $input): void
  703. {
  704. $this->doTest($expected, $input);
  705. }
  706. public static function provideFix80Cases(): iterable
  707. {
  708. yield [
  709. '<?php
  710. class Foo
  711. {
  712. private string|int $prop1;
  713. private string|int $prop2;
  714. }
  715. ',
  716. '<?php
  717. class Foo
  718. {
  719. private string|int $prop1, $prop2;
  720. }
  721. ',
  722. ];
  723. }
  724. /**
  725. * @dataProvider provideFix81Cases
  726. *
  727. * @requires PHP 8.1
  728. */
  729. public function testFix81(string $expected, ?string $input = null): void
  730. {
  731. $this->doTest($expected, $input);
  732. }
  733. public static function provideFix81Cases(): iterable
  734. {
  735. yield [
  736. '<?php
  737. class Foo
  738. {
  739. readonly int $a;
  740. readonly int $b;
  741. public readonly int $c;
  742. public readonly int $d;
  743. readonly private string /*1*/$e;
  744. readonly private string /*2*/$f;
  745. readonly float $g;
  746. protected readonly float $h1;
  747. protected readonly float $h2;
  748. readonly float $z1;
  749. readonly float $z2;
  750. readonly float $z3;
  751. }',
  752. '<?php
  753. class Foo
  754. {
  755. readonly int $a, $b;
  756. public readonly int $c, $d;
  757. readonly private string /*1*/$e,/*2*/$f;
  758. readonly float $g;
  759. protected readonly float $h1, $h2;
  760. readonly float $z1, $z2, $z3;
  761. }',
  762. ];
  763. yield [
  764. '<?php
  765. class Foo
  766. {
  767. final public const B1 = "2";
  768. final public const B2 = "2";
  769. readonly float $z2;
  770. }
  771. ',
  772. ];
  773. yield [
  774. '<?php
  775. class Foo
  776. {
  777. private Foo&Bar $prop1;
  778. private Foo&Bar $prop2;
  779. }
  780. ',
  781. '<?php
  782. class Foo
  783. {
  784. private Foo&Bar $prop1, $prop2;
  785. }
  786. ',
  787. ];
  788. yield [
  789. "<?php
  790. enum Foo: string {
  791. public const A = 'A';
  792. public const B = 'B';
  793. case Hearts = 'H';
  794. case Spades = 'S';
  795. }
  796. var_dump(Foo::A.Foo::B);",
  797. "<?php
  798. enum Foo: string {
  799. public const A = 'A', B = 'B';
  800. case Hearts = 'H';
  801. case Spades = 'S';
  802. }
  803. var_dump(Foo::A.Foo::B);",
  804. ];
  805. }
  806. /**
  807. * @dataProvider provideFix82Cases
  808. *
  809. * @requires PHP 8.2
  810. */
  811. public function testFix82(string $expected, ?string $input = null): void
  812. {
  813. $this->doTest($expected, $input);
  814. }
  815. public static function provideFix82Cases(): iterable
  816. {
  817. yield [
  818. '<?php trait Foo { public const Bar = 1; public const Baz = 1; }',
  819. '<?php trait Foo { public const Bar = 1, Baz = 1; }',
  820. ];
  821. }
  822. public function testInvalidConfiguration(): void
  823. {
  824. $this->expectException(InvalidFixerConfigurationException::class);
  825. $this->expectExceptionMessageMatches('/^\[single_class_element_per_statement\] Invalid configuration: The option "elements" .*\.$/');
  826. $this->fixer->configure(['elements' => ['foo']]);
  827. }
  828. }