Skip to content

Commit 0766263

Browse files
dereuromarkclaude
andauthored
Skip docblock requirement for constructors with fully typed parameters (#41)
When a constructor has all parameters fully typed (including promoted properties like `public function __construct(protected bool $xhtml = false)`), a docblock is redundant since the types are self-documenting. This change skips the ConstructDesctructMissingDocBlock error when all constructor parameters have type hints. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com>
1 parent 0220202 commit 0766263

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

PhpCollective/Sniffs/Commenting/DocBlockSniff.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,20 @@ protected function checkConstructorAndDestructor(File $phpcsFile, int $stackPtr)
134134
return;
135135
}
136136

137+
// If all parameters are fully typed (including promoted properties), no docblock is needed
138+
$allTyped = true;
139+
foreach ($methodSignature as $param) {
140+
if (empty($param['typehint'])) {
141+
$allTyped = false;
142+
143+
break;
144+
}
145+
}
146+
147+
if ($allTyped) {
148+
return;
149+
}
150+
137151
$phpcsFile->addError('Missing doc block for method', $stackPtr, 'ConstructDesctructMissingDocBlock');
138152
}
139153

0 commit comments

Comments
 (0)