Browse Source

Merge branch '2.2' into 2.11

Dariusz Ruminski 7 years ago
parent
commit
5c5de791ab

+ 1 - 2
src/Fixer/Phpdoc/PhpdocVarWithoutNameFixer.php

@@ -42,10 +42,9 @@ final class Foo
     public $bar;
     public $bar;
 
 
     /**
     /**
-     * @var $baz float
+     * @type $baz float
      */
      */
     public $baz;
     public $baz;
-
 }
 }
 ')]
 ')]
         );
         );

+ 88 - 84
tests/Fixer/Phpdoc/PhpdocVarWithoutNameFixerTest.php

@@ -23,64 +23,83 @@ use PhpCsFixer\Tests\Test\AbstractFixerTestCase;
  */
  */
 final class PhpdocVarWithoutNameFixerTest extends AbstractFixerTestCase
 final class PhpdocVarWithoutNameFixerTest extends AbstractFixerTestCase
 {
 {
-    public function testFixVar()
+    /**
+     * @dataProvider provideFixVarCases
+     *
+     * @param string      $expected
+     * @param null|string $input
+     */
+    public function testFixVar($expected, $input = null)
+    {
+        $this->doTest($expected, $input);
+    }
+
+    /**
+     * @dataProvider provideFixVarCases
+     *
+     * @param string      $expected
+     * @param null|string $input
+     */
+    public function testFixType($expected, $input = null)
+    {
+        $expected = str_replace('@var', '@type', $expected);
+        if (null !== $input) {
+            $input = str_replace('@var', '@type', $input);
+        }
+
+        $this->doTest($expected, $input);
+    }
+
+    public function provideFixVarCases()
     {
     {
-        $expected = <<<'EOF'
+        return [
+            'testFixVar' => [
+                <<<'EOF'
 <?php
 <?php
     /**
     /**
      * @var string Hello!
      * @var string Hello!
      */
      */
 
 
-EOF;
-
-        $input = <<<'EOF'
+EOF
+                ,
+                <<<'EOF'
 <?php
 <?php
     /**
     /**
      * @var string $foo Hello!
      * @var string $foo Hello!
      */
      */
 
 
-EOF;
-
-        $this->doTest($expected, $input);
-    }
-
-    public function testFixType()
-    {
-        $expected = <<<'EOF'
+EOF
+                ,
+            ],
+            'testFixType' => [
+                <<<'EOF'
 <?php
 <?php
     /**
     /**
      * @var int|null
      * @var int|null
      */
      */
 
 
-EOF;
-
-        $input = <<<'EOF'
+EOF
+                ,
+                <<<'EOF'
 <?php
 <?php
     /**
     /**
      * @var int|null $bar
      * @var int|null $bar
      */
      */
 
 
-EOF;
-
-        $this->doTest($expected, $input);
-    }
-
-    public function testDoNothing()
-    {
-        $expected = <<<'EOF'
+EOF
+                ,
+            ],
+            'testDoNothing' => [
+                <<<'EOF'
 <?php
 <?php
     /**
     /**
      * @var Foo\Bar This is a variable.
      * @var Foo\Bar This is a variable.
      */
      */
 
 
-EOF;
-
-        $this->doTest($expected);
-    }
-
-    public function testFixVarWithOtherAnnotation()
-    {
-        $expected = <<<'EOF'
+EOF
+            ],
+            'testFixVarWithOtherAnnotation' => [
+                <<<'EOF'
 <?php
 <?php
     /**
     /**
      * @var string Hello!
      * @var string Hello!
@@ -88,9 +107,9 @@ EOF;
      * @deprecated
      * @deprecated
      */
      */
 
 
-EOF;
-
-        $input = <<<'EOF'
+EOF
+                ,
+                <<<'EOF'
 <?php
 <?php
     /**
     /**
      * @var string $foo Hello!
      * @var string $foo Hello!
@@ -98,14 +117,11 @@ EOF;
      * @deprecated
      * @deprecated
      */
      */
 
 
-EOF;
-
-        $this->doTest($expected, $input);
-    }
-
-    public function testFixVarWithNestedKeys()
-    {
-        $expected = <<<'EOF'
+EOF
+                ,
+            ],
+            'testFixVarWithNestedKeys' => [
+                <<<'EOF'
 <?php
 <?php
     /**
     /**
      * @var array {
      * @var array {
@@ -114,9 +130,9 @@ EOF;
      * }
      * }
      */
      */
 
 
-EOF;
-
-        $input = <<<'EOF'
+EOF
+                ,
+                <<<'EOF'
 <?php
 <?php
     /**
     /**
      * @var array $options {
      * @var array $options {
@@ -125,39 +141,29 @@ EOF;
      * }
      * }
      */
      */
 
 
-EOF;
-
-        $this->doTest($expected, $input);
-    }
-
-    public function testSingleLine()
-    {
-        $expected = <<<'EOF'
-<?php
+EOF
+            ],
+            'testSingleLine' => [
+                <<<'EOF'
+                <?php
     /** @var Foo\Bar $bar */
     /** @var Foo\Bar $bar */
     $bar;
     $bar;
-EOF;
-
-        $this->doTest($expected);
-    }
-
-    public function testEmpty()
-    {
-        $expected = <<<'EOF'
-<?php
+EOF
+                ,
+            ],
+            'testEmpty' => [
+                <<<'EOF'
+                <?php
     /**
     /**
      *
      *
      */
      */
 
 
-EOF;
-
-        $this->doTest($expected);
-    }
-
-    public function testInlineDoc()
-    {
-        $expected = <<<'EOF'
-<?php
+EOF
+                ,
+            ],
+            'testInlineDoc' => [
+                <<<'EOF'
+                <?php
     /**
     /**
      * Initializes this class with the given options.
      * Initializes this class with the given options.
      *
      *
@@ -167,14 +173,11 @@ EOF;
      * }
      * }
      */
      */
 
 
-EOF;
-
-        $this->doTest($expected);
-    }
-
-    public function testInlineDocAgain()
-    {
-        $expected = <<<'EOF'
+EOF
+                ,
+            ],
+            'testInlineDocAgain' => [
+                <<<'EOF'
 <?php
 <?php
     /**
     /**
      * @param int[] $stuff {
      * @param int[] $stuff {
@@ -184,8 +187,9 @@ EOF;
      * @return void
      * @return void
      */
      */
 
 
-EOF;
-
-        $this->doTest($expected);
+EOF
+                ,
+            ],
+        ];
     }
     }
 }
 }