disable the Squiz\VariableCommentSniff "missing" code, to fix union types
All checks were successful
ci/woodpecker/push/code-style Pipeline was successful
ci/woodpecker/push/test Pipeline was successful

This commit is contained in:
Ferdinand Kuhl 2023-02-10 17:35:18 +01:00
parent 7063c47d64
commit f2fde71ef7
2 changed files with 17 additions and 1 deletions

View file

@ -16,6 +16,7 @@ class VariableCommentSniff extends \PHP_CodeSniffer\Standards\Squiz\Sniffs\Comme
\T_PROTECTED => \T_PROTECTED,
\T_VAR => \T_VAR,
\T_STATIC => \T_STATIC,
\T_TYPE_UNION => \T_TYPE_UNION,
\T_WHITESPACE => \T_WHITESPACE,
\T_STRING => \T_STRING,
\T_NS_SEPARATOR => \T_NS_SEPARATOR,
@ -50,7 +51,15 @@ class VariableCommentSniff extends \PHP_CodeSniffer\Standards\Squiz\Sniffs\Comme
$phpcsFile->addWarning($error, $commentEnd, 'MissingVarOrInheritDoc');
return;
}
// remove the error reporting from base class, as it does not accept union types
// https://github.com/squizlabs/PHP_CodeSniffer/pull/3757
$oldSeverity = $phpcsFile->ruleset->ruleset['DigiComp.Commenting.VariableComment.Missing']['severity'] ?? null;
$phpcsFile->ruleset->ruleset['DigiComp.Commenting.VariableComment.Missing']['severity'] = 0;
parent::processMemberVar($phpcsFile, $stackPtr);
if ($oldSeverity) {
$phpcsFile->ruleset->ruleset['DigiComp.Commenting.VariableComment.Missing']['severity'] = $oldSeverity;
} else {
unset($phpcsFile->ruleset->ruleset['DigiComp.Commenting.VariableComment.Missing']['severity']);
}
}
}

View file

@ -37,3 +37,10 @@ class E extends A {
#[\OwnAttribute]
protected $myVar;
}
class F extends A {
/**
* @var A|E
*/
protected A|E $myVar;
}