Skip to content

Commit 0fe0f17

Browse files
committed
Feat: Add PhpdocAlignFixer (part of #94)
1 parent fd8d1f8 commit 0fe0f17

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

ecs.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
use PhpCsFixer\Fixer\Phpdoc\NoEmptyPhpdocFixer;
103103
use PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer;
104104
use PhpCsFixer\Fixer\Phpdoc\PhpdocAddMissingParamAnnotationFixer;
105+
use PhpCsFixer\Fixer\Phpdoc\PhpdocAlignFixer;
105106
use PhpCsFixer\Fixer\Phpdoc\PhpdocIndentFixer;
106107
use PhpCsFixer\Fixer\Phpdoc\PhpdocNoAccessFixer;
107108
use PhpCsFixer\Fixer\Phpdoc\PhpdocNoEmptyReturnFixer;
@@ -499,6 +500,8 @@
499500
'allow_unused_params' => false, // whether param annotation without actual signature is allowed
500501
'remove_inheritdoc' => true, // remove @inheritDoc tags
501502
])
503+
// All items of the given PHPDoc tags must be left-aligned.
504+
->withConfiguredRule(PhpdocAlignFixer::class, ['align' => 'left'])
502505
// Order phpdoc tags by value.
503506
->withConfiguredRule(PhpdocOrderByValueFixer::class, ['annotations' => ['covers', 'group', 'throws']])
504507
// Calls to `PHPUnit\Framework\TestCase` static methods must all be of the same type (`$this->...`)

tests/Integration/Fixtures/Basic.correct.php.inc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,17 @@ class Basic
7777
'third' => 'bat',
7878
];
7979
}
80+
81+
/**
82+
* Very well documented method.
83+
* It tests PhpdocAlignFixer, NoSuperfluousPhpdocTagsFixer and possibly other Phpdoc rules.
84+
* @param int|float $second Second parameter does have a comment, unlike the first one.
85+
* @param string|null $third Third parameter is optional and has a default value.
86+
* @throws \Exception
87+
* @return mixed There is also information about return type.
88+
*/
89+
public function veryWellDocumented(string $first, int|float $second, ?string $third = '3rd'): mixed
90+
{
91+
return $first . $third;
92+
}
8093
}

tests/Integration/Fixtures/Basic.wrong.php.inc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,18 @@ class Basic
7474
'third' => 'bat',
7575
];
7676
}
77+
78+
/**
79+
* Very well documented method.
80+
* It tests PhpdocAlignFixer, NoSuperfluousPhpdocTagsFixer and possibly other Phpdoc rules.
81+
* @param string $first
82+
* @throws \Exception
83+
* @param int|float $second Second parameter does have a comment, unlike the first one.
84+
* @param string|null $third Third parameter is optional and has a default value.
85+
* @return mixed There is also information about return type.
86+
*/
87+
public function veryWellDocumented(string $first, int|float $second, ?string $third = '3rd'): mixed
88+
{
89+
return $first . $third;
90+
}
7791
}

0 commit comments

Comments
 (0)