|
@@ -1103,6 +1103,138 @@ EOF;
|
|
|
$this->doTest($expected, $input);
|
|
|
}
|
|
|
|
|
|
+ public function testAlignsStaticAndNonStaticMethods(): void
|
|
|
+ {
|
|
|
+ $this->fixer->configure(['tags' => ['method', 'property']]);
|
|
|
+
|
|
|
+ $expected = <<<'EOF'
|
|
|
+<?php
|
|
|
+ /**
|
|
|
+ * @property string $foo Desc1
|
|
|
+ * @property int $bar Desc2
|
|
|
+ * @method foo(string $foo) DescriptionFoo
|
|
|
+ * @method static bar(string $foo) DescriptionBar
|
|
|
+ * @method string|null baz(bool $baz) DescriptionBaz
|
|
|
+ * @method static int|false qux(float $qux) DescriptionQux
|
|
|
+ * @method static static quux(int $quux) DescriptionQuux
|
|
|
+ * @method static $this quuz(bool $quuz) DescriptionQuuz
|
|
|
+ */
|
|
|
+EOF;
|
|
|
+
|
|
|
+ $input = <<<'EOF'
|
|
|
+<?php
|
|
|
+ /**
|
|
|
+ * @property string $foo Desc1
|
|
|
+ * @property int $bar Desc2
|
|
|
+ * @method foo(string $foo) DescriptionFoo
|
|
|
+ * @method static bar(string $foo) DescriptionBar
|
|
|
+ * @method string|null baz(bool $baz) DescriptionBaz
|
|
|
+ * @method static int|false qux(float $qux) DescriptionQux
|
|
|
+ * @method static static quux(int $quux) DescriptionQuux
|
|
|
+ * @method static $this quuz(bool $quuz) DescriptionQuuz
|
|
|
+ */
|
|
|
+EOF;
|
|
|
+
|
|
|
+ $this->doTest($expected, $input);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function testAlignsStaticAndNonStaticMethodsLeftAlign(): void
|
|
|
+ {
|
|
|
+ $this->fixer->configure(['tags' => ['method', 'property'], 'align' => PhpdocAlignFixer::ALIGN_LEFT]);
|
|
|
+
|
|
|
+ $expected = <<<'EOF'
|
|
|
+<?php
|
|
|
+ /**
|
|
|
+ * @property string $foo Desc1
|
|
|
+ * @property int $bar Desc2
|
|
|
+ * @method foo(string $foo) DescriptionFoo
|
|
|
+ * @method static bar(string $foo) DescriptionBar
|
|
|
+ * @method string|null baz(bool $baz) DescriptionBaz
|
|
|
+ * @method static int|false qux(float $qux) DescriptionQux
|
|
|
+ * @method static static quux(int $quux) DescriptionQuux
|
|
|
+ * @method static $this quuz(bool $quuz) DescriptionQuuz
|
|
|
+ */
|
|
|
+EOF;
|
|
|
+
|
|
|
+ $input = <<<'EOF'
|
|
|
+<?php
|
|
|
+ /**
|
|
|
+ * @property string $foo Desc1
|
|
|
+ * @property int $bar Desc2
|
|
|
+ * @method foo(string $foo) DescriptionFoo
|
|
|
+ * @method static bar(string $foo) DescriptionBar
|
|
|
+ * @method string|null baz(bool $baz) DescriptionBaz
|
|
|
+ * @method static int|false qux(float $qux) DescriptionQux
|
|
|
+ * @method static static quux(int $quux) DescriptionQuux
|
|
|
+ * @method static $this quuz(bool $quuz) DescriptionQuuz
|
|
|
+ */
|
|
|
+EOF;
|
|
|
+
|
|
|
+ $this->doTest($expected, $input);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function testAlignsReturnStatic(): void
|
|
|
+ {
|
|
|
+ $this->fixer->configure(['tags' => ['param', 'return', 'throws']]);
|
|
|
+
|
|
|
+ $expected = <<<'EOF'
|
|
|
+<?php
|
|
|
+ /**
|
|
|
+ * @param string $foobar Desc1
|
|
|
+ * @param int &$baz Desc2
|
|
|
+ * @param ?Qux $qux Desc3
|
|
|
+ * @param int|float $quux Desc4
|
|
|
+ * @return static DescriptionReturn
|
|
|
+ * @throws Exception DescriptionException
|
|
|
+ */
|
|
|
+EOF;
|
|
|
+
|
|
|
+ $input = <<<'EOF'
|
|
|
+<?php
|
|
|
+ /**
|
|
|
+ * @param string $foobar Desc1
|
|
|
+ * @param int &$baz Desc2
|
|
|
+ * @param ?Qux $qux Desc3
|
|
|
+ * @param int|float $quux Desc4
|
|
|
+ * @return static DescriptionReturn
|
|
|
+ * @throws Exception DescriptionException
|
|
|
+ */
|
|
|
+EOF;
|
|
|
+
|
|
|
+ $this->doTest($expected, $input);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function testAlignsReturnStaticLeftAlign(): void
|
|
|
+ {
|
|
|
+ $this->fixer->configure(['tags' => ['param', 'return', 'throws'], 'align' => PhpdocAlignFixer::ALIGN_LEFT]);
|
|
|
+
|
|
|
+ $expected = <<<'EOF'
|
|
|
+<?php
|
|
|
+ /**
|
|
|
+ * @param string $foobar Desc1
|
|
|
+ * @param int &$baz Desc2
|
|
|
+ * @param ?Qux $qux Desc3
|
|
|
+ * @param int|float $quux Desc4
|
|
|
+ * @return static DescriptionReturn
|
|
|
+ * @throws Exception DescriptionException
|
|
|
+ */
|
|
|
+EOF;
|
|
|
+
|
|
|
+ $input = <<<'EOF'
|
|
|
+<?php
|
|
|
+ /**
|
|
|
+ * @param string $foobar Desc1
|
|
|
+ * @param int &$baz Desc2
|
|
|
+ * @param ?Qux $qux Desc3
|
|
|
+ * @param int|float $quux Desc4
|
|
|
+ * @return static DescriptionReturn
|
|
|
+ * @throws Exception DescriptionException
|
|
|
+ */
|
|
|
+EOF;
|
|
|
+
|
|
|
+ $this->doTest($expected, $input);
|
|
|
+ }
|
|
|
+
|
|
|
public function testDoesNotAlignWithEmptyConfig(): void
|
|
|
{
|
|
|
$this->fixer->configure(['tags' => []]);
|