Skip to content

Commit

Permalink
Merge pull request #13 from sd-tm/master
Browse files Browse the repository at this point in the history
Don't test in Interfaces body function of a return Statement.
  • Loading branch information
sauliusstasiukaitis authored Jul 22, 2016
2 parents fb4544e + 5962ae6 commit a98f5c2
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Oxid/Sniffs/Commenting/FunctionCommentSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@
*/
class Oxid_Sniffs_Commenting_FunctionCommentSniff extends PEAR_Sniffs_Commenting_FunctionCommentSniff
{
/**
* Check it is a PHP Interface, but one time.
*
* @var array
*/
protected $isFileInterface = array();

/**
* Process the return comment of this function comment.
*
Expand Down Expand Up @@ -65,6 +72,10 @@ protected function processReturn(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $co
}
}

if ($this->isInterface($phpcsFile)) {
return;
}

if ($isSpecialMethod === true) {
return;
}
Expand Down Expand Up @@ -117,4 +128,23 @@ protected function functionHasReturnStatement(PHP_CodeSniffer_File $phpcsFile, $

return false;
}//end functionHasReturnStatement()

/**
* Test if this a PHP Interface File
*
* @param PHP_CodeSniffer_File $phpcsFile
*
* @return bool
*/
protected function isInterface(PHP_CodeSniffer_File $phpcsFile) {
$checkFile = "". $phpcsFile->getFilename();
if (isset($this->isFileInterface[$checkFile])) {
return (bool) $this->isFileInterface[$checkFile];
}

$interface = $phpcsFile->findNext(T_INTERFACE, 0);

return $this->isFileInterface[$checkFile] = (bool)(empty($interface) == false);
}//end isInterfaceClass()

}//end class

0 comments on commit a98f5c2

Please sign in to comment.