From 9279287c0b439f07a3e87f0f7731c4e613095d93 Mon Sep 17 00:00:00 2001 From: mscherer Date: Thu, 27 Nov 2025 13:17:27 +0100 Subject: [PATCH] Skip docblock requirement for constructors with fully typed parameters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- PhpCollective/Sniffs/Commenting/DocBlockSniff.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/PhpCollective/Sniffs/Commenting/DocBlockSniff.php b/PhpCollective/Sniffs/Commenting/DocBlockSniff.php index bd73ead..92fb7bb 100644 --- a/PhpCollective/Sniffs/Commenting/DocBlockSniff.php +++ b/PhpCollective/Sniffs/Commenting/DocBlockSniff.php @@ -134,6 +134,20 @@ protected function checkConstructorAndDestructor(File $phpcsFile, int $stackPtr) return; } + // If all parameters are fully typed (including promoted properties), no docblock is needed + $allTyped = true; + foreach ($methodSignature as $param) { + if (empty($param['typehint'])) { + $allTyped = false; + + break; + } + } + + if ($allTyped) { + return; + } + $phpcsFile->addError('Missing doc block for method', $stackPtr, 'ConstructDesctructMissingDocBlock'); }