* Dariusz RumiƄski * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace PhpCsFixer\Tests\Fixer\Phpdoc; use PhpCsFixer\Tests\Test\AbstractFixerTestCase; /** * @author Ceeram * * @internal * * @covers \PhpCsFixer\Fixer\Phpdoc\PhpdocToCommentFixer */ final class PhpdocToCommentFixerTest extends AbstractFixerTestCase { /** * @dataProvider provideDocblocksCases */ public function testFix(string $expected, ?string $input = null): void { $this->doTest($expected, $input); } /** * @dataProvider provideTraitsCases */ public function testFixTraits(string $expected, ?string $input = null): void { $this->doTest($expected, $input); } public function provideDocblocksCases() { $cases = []; $cases[] = [ 'open($path); }', ]; $cases[] = [ ' $sqlite) { $sqlite->open($path); }', ]; $cases[] = [ ' $sqlite) { $sqlite->open($path); }', ]; $cases[] = [ ' $sqlite) { $sqlite->open($path); }', ' $sqlite) { $sqlite->open($path); }', ]; $cases[] = [ 'open($path); ', 'open($path); ', ]; $cases[] = [ 'getPairs($c->bar(), $bar) as $index => list($a, $b)) { // Do something with $index, $a and $b } /** @var \Closure $value */ if (!$value = $this->getValue()) { return false; } /** @var string $name */ switch ($name = $this->getName()) { case "John": return false; case "Jane": return true; } /** @var string $content */ while ($content = $this->getContent()) { $name .= $content; } /** @var int $size */ for($i = 0, $size = count($people); $i < $size; ++$i) { $people[$i][\'salt\'] = mt_rand(000000, 999999); }', ]; $cases[] = [ 'getPairs($c->bar(), $bar) as $index => list($a, $b)) { // Do something with $index, $a and $b } /* @var \Closure $notValue */ if (!$value = $this->getValue()) { return false; } /* @var string $notName */ switch ($name = $this->getName()) { case "John": return false; case "Jane": return true; } /* @var string $notContent */ while ($content = $this->getContent()) { $name .= $content; } /* @var int $notSize */ for($i = 0, $size = count($people); $i < $size; ++$i) { $people[$i][\'salt\'] = mt_rand(000000, 999999); }', 'getPairs($c->bar(), $bar) as $index => list($a, $b)) { // Do something with $index, $a and $b } /** @var \Closure $notValue */ if (!$value = $this->getValue()) { return false; } /** @var string $notName */ switch ($name = $this->getName()) { case "John": return false; case "Jane": return true; } /** @var string $notContent */ while ($content = $this->getContent()) { $name .= $content; } /** @var int $notSize */ for($i = 0, $size = count($people); $i < $size; ++$i) { $people[$i][\'salt\'] = mt_rand(000000, 999999); }', ]; $cases[] = [ 'doTest($expected, $input); } public function provideFix70Cases() { return [ [ 'doSomething(); /** @var Session $session */ # test $session = new Session(); ', ], ]; } /** * @dataProvider provideFix71Cases * @requires PHP 7.1 */ public function testFix71(string $expected, ?string $input = null): void { $this->doTest($expected, $input); } public function provideFix71Cases() { return [ [ 'doTest($expected, $input); } public function provideFix74Cases() { return [ [ 'doTest($expected, $input); } public function provideFix80Cases() { return [ [ '