disable the Squiz\VariableCommentSniff "missing" code, to fix union types
This commit is contained in:
parent
7063c47d64
commit
f2fde71ef7
2 changed files with 17 additions and 1 deletions
|
@ -16,6 +16,7 @@ class VariableCommentSniff extends \PHP_CodeSniffer\Standards\Squiz\Sniffs\Comme
|
||||||
\T_PROTECTED => \T_PROTECTED,
|
\T_PROTECTED => \T_PROTECTED,
|
||||||
\T_VAR => \T_VAR,
|
\T_VAR => \T_VAR,
|
||||||
\T_STATIC => \T_STATIC,
|
\T_STATIC => \T_STATIC,
|
||||||
|
\T_TYPE_UNION => \T_TYPE_UNION,
|
||||||
\T_WHITESPACE => \T_WHITESPACE,
|
\T_WHITESPACE => \T_WHITESPACE,
|
||||||
\T_STRING => \T_STRING,
|
\T_STRING => \T_STRING,
|
||||||
\T_NS_SEPARATOR => \T_NS_SEPARATOR,
|
\T_NS_SEPARATOR => \T_NS_SEPARATOR,
|
||||||
|
@ -50,7 +51,15 @@ class VariableCommentSniff extends \PHP_CodeSniffer\Standards\Squiz\Sniffs\Comme
|
||||||
$phpcsFile->addWarning($error, $commentEnd, 'MissingVarOrInheritDoc');
|
$phpcsFile->addWarning($error, $commentEnd, 'MissingVarOrInheritDoc');
|
||||||
return;
|
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);
|
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']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,3 +37,10 @@ class E extends A {
|
||||||
#[\OwnAttribute]
|
#[\OwnAttribute]
|
||||||
protected $myVar;
|
protected $myVar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class F extends A {
|
||||||
|
/**
|
||||||
|
* @var A|E
|
||||||
|
*/
|
||||||
|
protected A|E $myVar;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue