Skip to content

Commit e8fceeb

Browse files
DerManoMannclaude
andcommitted
Add CS phpdoc_line_span rule for class/method docblocks
Enforces multi-line docblocks on class/interface/trait/enum and method declarations while preserving existing style for properties and constants. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1afb8fb commit e8fceeb

7 files changed

Lines changed: 31 additions & 10 deletions

File tree

.php-cs-fixer.dist.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
'phpdoc_no_alias_tag' => true,
9999
'phpdoc_param_order' => true,
100100
'multiline_comment_opening_closing' => true,
101+
'phpdoc_line_span' => ['class' => 'multi', 'method' => 'multi', 'property' => null, 'const' => null, 'case' => null, 'function' => null],
101102

102103
'php_unit_attributes' => true,
103104
])

docs/snippets/guide/cookbook/enums_an.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@
44

55
use OpenApi\Annotations as OA;
66

7-
/** @OA\Schema() */
7+
/**
8+
* @OA\Schema()
9+
*/
810
enum State
911
{
1012
case OPEN;
1113
case MERGED;
1214
case DECLINED;
1315
}
1416

15-
/** @OA\Schema */
17+
/**
18+
* @OA\Schema
19+
*/
1620
class PullRequest
1721
{
1822
/** @OA\Property */

src/Generator.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ public function __construct(?LoggerInterface $logger = null)
7373
$this->setNamespaces(self::DEFAULT_NAMESPACES);
7474
}
7575

76-
/** @deprecated Use {@see Undefined::isDefault()} instead. */
76+
/**
77+
* @deprecated Use {@see Undefined::isDefault()} instead.
78+
*/
7779
public static function isDefault(...$value): bool
7880
{
7981
return Undefined::isDefault(...$value);

src/Type/LegacyTypeResolver.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
*/
1818
class LegacyTypeResolver extends AbstractTypeResolver
1919
{
20-
/** @inheritdoc */
20+
/**
21+
* @inheritdoc
22+
*/
2123
protected function doAugment(Analysis $analysis, OA\Schema $schema, \Reflector $reflector, string $sourceClass = OA\Schema::class): void
2224
{
2325
$docblockDetails = $this->getDocblockTypeDetails($reflector, $schema->_context);

src/Type/TypeInfoTypeResolver.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@
3737

3838
class TypeInfoTypeResolver extends AbstractTypeResolver
3939
{
40-
/** @inheritdoc */
40+
/**
41+
* @inheritdoc
42+
*/
4143
protected function doAugment(Analysis $analysis, OA\Schema $schema, \Reflector $reflector, string $sourceClass = OA\Schema::class): void
4244
{
4345
$docblockType = $this->getDocblockType($reflector);

tests/Fixtures/Scratch/ComplexCustomAttributes.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ public function __construct(
6666
)]
6767
class Collection extends OAT\Property
6868
{
69-
/** @param class-string $of */
69+
/**
70+
* @param class-string $of
71+
*/
7072
public function __construct(
7173
string $of,
7274
?string $description = null
@@ -90,7 +92,9 @@ public function __construct(
9092
)]
9193
class Item extends OAT\Property
9294
{
93-
/** @param class-string $of */
95+
/**
96+
* @param class-string $of
97+
*/
9498
public function __construct(
9599
string $of,
96100
?string $description = null
@@ -128,7 +132,9 @@ public function __construct(
128132
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
129133
class Successful extends OAT\Response
130134
{
131-
/** @param ?class-string $of */
135+
/**
136+
* @param ?class-string $of
137+
*/
132138
public function __construct(
133139
?string $of = null,
134140
) {

tests/Fixtures/Scratch/CustomAttributes.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ class CustomProperty extends OAT\Property
2828
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY | \Attribute::TARGET_PARAMETER | \Attribute::TARGET_CLASS_CONSTANT | \Attribute::IS_REPEATABLE)]
2929
class CustomItem extends OAT\Property
3030
{
31-
/** @param class-string $of */
31+
/**
32+
* @param class-string $of
33+
*/
3234
public function __construct(
3335
string $of,
3436
?string $description = null
@@ -44,7 +46,9 @@ public function __construct(
4446
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY | \Attribute::TARGET_PARAMETER | \Attribute::TARGET_CLASS_CONSTANT | \Attribute::IS_REPEATABLE)]
4547
class CustomList extends OAT\Property
4648
{
47-
/** @param class-string $of */
49+
/**
50+
* @param class-string $of
51+
*/
4852
public function __construct(string $of, ?string $description = null)
4953
{
5054
parent::__construct(

0 commit comments

Comments
 (0)