Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ public function process( File $phpcsFile, $stackPtr ) {
$existingParams = array();

if ( $hasDocblock ) {
// Skip if docblock contains {@inheritdoc}.
if ( $this->hasInheritdoc( $phpcsFile, $docblock ) ) {
return;
}

// Get existing @param tags with their types.
$existingParams = $this->getExistingParamTags( $phpcsFile, $docblock );
}
Expand Down Expand Up @@ -207,6 +212,36 @@ private function findDocblock( File $phpcsFile, $stackPtr ) {
return false;
}

/**
* Check if a docblock contains {@inheritdoc}.
*
* @param File $phpcsFile The file being scanned.
* @param int $docblock The docblock opener position.
*
* @return bool
*/
private function hasInheritdoc( File $phpcsFile, $docblock ) {
$tokens = $phpcsFile->getTokens();

if ( ! isset( $tokens[ $docblock ]['comment_closer'] ) ) {
return false;
}

$closer = $tokens[ $docblock ]['comment_closer'];

for ( $i = $docblock; $i < $closer; $i++ ) {
if ( $tokens[ $i ]['code'] === T_DOC_COMMENT_TAG && stripos( $tokens[ $i ]['content'], '@inheritdoc' ) !== false ) {
return true;
}

if ( $tokens[ $i ]['code'] === T_DOC_COMMENT_STRING && stripos( $tokens[ $i ]['content'], '{@inheritdoc}' ) !== false ) {
return true;
}
}

return false;
}

/**
* Get function parameters.
*
Expand Down
Loading