123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- <?php
- declare(strict_types=1);
- /*
- * This file is part of PHP CS Fixer.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- * Dariusz Rumiński <dariusz.ruminski@gmail.com>
- *
- * 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;
- /**
- * @internal
- *
- * @author Kuba Werłos <werlos@gmail.com>
- *
- * @covers \PhpCsFixer\Fixer\Phpdoc\PhpdocVarAnnotationCorrectOrderFixer
- *
- * @extends AbstractFixerTestCase<\PhpCsFixer\Fixer\Phpdoc\PhpdocVarAnnotationCorrectOrderFixer>
- */
- final class PhpdocVarAnnotationCorrectOrderFixerTest extends AbstractFixerTestCase
- {
- /**
- * @dataProvider provideFixCases
- */
- public function testFix(string $expected, ?string $input = null): void
- {
- $this->doTest($expected, $input);
- }
- /**
- * @return iterable<array{0: string, 1?: string}>
- */
- public static function provideFixCases(): iterable
- {
- yield [ // It's @param, we care only about @var
- '<?php /** @param $foo Foo */',
- ];
- yield [ // This is already fine
- '<?php /** @var Foo $foo */ ',
- ];
- yield [ // What? Two variables, I'm not touching this
- '<?php /** @var $foo $bar */',
- ];
- yield [ // Two classes are not to touch either
- '<?php /** @var Foo Bar */',
- ];
- yield ['<?php /** @var */'];
- yield ['<?php /** @var $foo */'];
- yield ['<?php /** @var Bar */'];
- yield [
- '<?php
- /**
- * @var Foo $foo
- * @var Bar $bar
- */
- ',
- '<?php
- /**
- * @var $foo Foo
- * @var $bar Bar
- */
- ',
- ];
- yield [
- '<?php
- /**
- * @var Foo $foo Some description
- */
- ',
- '<?php
- /**
- * @var $foo Foo Some description
- */
- ',
- ];
- yield [
- '<?php /** @var Foo $foo */',
- '<?php /** @var $foo Foo */',
- ];
- yield [
- '<?php /** @type Foo $foo */',
- '<?php /** @type $foo Foo */',
- ];
- yield [
- '<?php /** @var Foo $foo*/',
- '<?php /** @var $foo Foo*/',
- ];
- yield [
- '<?php /** @var Foo[] $foos */',
- '<?php /** @var $foos Foo[] */',
- ];
- yield [
- '<?php /** @Var Foo $foo */',
- '<?php /** @Var $foo Foo */',
- ];
- yield [
- '<?php
- /** @var Foo|Bar|mixed|int $someWeirdLongNAME__123 */
- ',
- '<?php
- /** @var $someWeirdLongNAME__123 Foo|Bar|mixed|int */
- ',
- ];
- yield [
- '<?php
- /**
- * @var Foo $bar long description
- * goes here
- */
- ',
- '<?php
- /**
- * @var $bar Foo long description
- * goes here
- */
- ',
- ];
- yield [
- '<?php
- /** @var array<int, int> $foo */
- ',
- '<?php
- /** @var $foo array<int, int> */
- ',
- ];
- yield [
- '<?php
- /** @var array<int, int> $foo Array of something */
- ',
- '<?php
- /** @var $foo array<int, int> Array of something */
- ',
- ];
- yield [
- '<?php
- /** @var Foo|array<int, int>|null $foo */
- ',
- '<?php
- /** @var $foo Foo|array<int, int>|null */
- ',
- ];
- yield [
- '<?php
- class Foo
- {
- /**
- * @var $bar
- */
- private $bar;
- }
- ',
- ];
- }
- }
|