Skip to content

Commit

Permalink
Added attribute support
Browse files Browse the repository at this point in the history
  • Loading branch information
gsherwood committed Mar 30, 2021
1 parent 6da6d82 commit c132dc5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/Standards/PEAR/Sniffs/Commenting/ClassCommentSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,24 @@ public function process(File $phpcsFile, $stackPtr)
$type = strtolower($tokens[$stackPtr]['content']);
$errorData = [$type];

$find = Tokens::$methodPrefixes;
$find[] = T_WHITESPACE;
$find = Tokens::$methodPrefixes;
$find[T_WHITESPACE] = T_WHITESPACE;

for ($commentEnd = ($stackPtr - 1); $commentEnd >= 0; $commentEnd--) {
if (isset($find[$tokens[$commentEnd]['code']]) === true) {
continue;
}

if ($tokens[$commentEnd]['code'] === T_ATTRIBUTE_END
&& isset($tokens[$commentEnd]['attribute_opener']) === true
) {
$commentEnd = $tokens[$commentEnd]['attribute_opener'];
continue;
}

break;
}

$commentEnd = $phpcsFile->findPrevious($find, ($stackPtr - 1), null, true);
if ($tokens[$commentEnd]['code'] !== T_DOC_COMMENT_CLOSE_TAG
&& $tokens[$commentEnd]['code'] !== T_COMMENT
) {
Expand Down
15 changes: 15 additions & 0 deletions src/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,18 @@ trait Empty_Trait_Doc
{

}//end trait


/**
* Sample class comment
*
* @category PHP
* @package PHP_CodeSniffer
* @author Greg Sherwood <[email protected]>
* @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
#[Authenticate('admin_logged_in')]
class TodoController extends AbstractController implements MustBeLoggedInInterface
{
}

0 comments on commit c132dc5

Please sign in to comment.