Skip to content

Commit 121d47f

Browse files
committed
Feat: Add PhpdocToCommentFixer (part of #94)
1 parent cde08b1 commit 121d47f

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

Diff for: ecs-internal.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Symplify\CodingStandard\Fixer\LineLength\LineLengthFixer;
66
use Symplify\EasyCodingStandard\Config\ECSConfig;
77

8-
/**
8+
/*
99
* Internal rules configuration for the lmc/coding-standard project itself
1010
*/
1111
return ECSConfig::configure()

Diff for: ecs.php

+3
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
use PhpCsFixer\Fixer\Phpdoc\PhpdocReturnSelfReferenceFixer;
107107
use PhpCsFixer\Fixer\Phpdoc\PhpdocScalarFixer;
108108
use PhpCsFixer\Fixer\Phpdoc\PhpdocSingleLineVarSpacingFixer;
109+
use PhpCsFixer\Fixer\Phpdoc\PhpdocToCommentFixer;
109110
use PhpCsFixer\Fixer\Phpdoc\PhpdocTrimFixer;
110111
use PhpCsFixer\Fixer\Phpdoc\PhpdocTypesFixer;
111112
use PhpCsFixer\Fixer\Phpdoc\PhpdocVarAnnotationCorrectOrderFixer;
@@ -331,6 +332,8 @@
331332
PhpdocSingleLineVarSpacingFixer::class,
332333
// PHPDoc should start and end with content
333334
PhpdocTrimFixer::class,
335+
// Docblocks should only be used on structural elements.
336+
PhpdocToCommentFixer::class,
334337
// The correct case must be used for standard PHP types in PHPDoc.
335338
PhpdocTypesFixer::class,
336339
// `@var` and `@type` annotations must have type and name in the correct order

Diff for: tests/Integration/Fixtures/Basic.correct.php.inc

+7
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ class Basic
2424

2525
public function fooBar(mixed $foo): mixed
2626
{
27+
// PhpdocToCommentFixer
28+
/*
29+
* Phpdoc used instead of plain comment
30+
*/
31+
if ($foo === 'bar') {
32+
$baz = 'bat';
33+
}
2734
// TernaryToElvisOperatorFixer
2835
return ($foo ?: 'not true');
2936
}

Diff for: tests/Integration/Fixtures/Basic.wrong.php.inc

+7
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ class Basic
2020

2121
public function fooBar(mixed $foo): mixed
2222
{
23+
// PhpdocToCommentFixer
24+
/**
25+
* Phpdoc used instead of plain comment
26+
*/
27+
if ($foo === 'bar') {
28+
$baz = 'bat';
29+
}
2330
// TernaryToElvisOperatorFixer
2431
return ($foo ? $foo : 'not true');
2532
}

0 commit comments

Comments
 (0)