Skip to content

Commit

Permalink
phpcs error on rule classes - must be of the type integer
Browse files Browse the repository at this point in the history
  • Loading branch information
Nazar65 committed May 22, 2019
1 parent 211dd25 commit 9884254
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,12 @@ public function process(File $phpcsFile, $stackPtr)
{
$tokens = $phpcsFile->getTokens();
$previousCommentClosePtr = $phpcsFile->findPrevious(T_DOC_COMMENT_CLOSE_TAG, $stackPtr - 1, 0);
$this->validateAnnotationBlockExists($phpcsFile, (int)$previousCommentClosePtr, (int)$stackPtr);
$commentStartPtr = (int)$phpcsFile->findPrevious(T_DOC_COMMENT_OPEN_TAG, $stackPtr - 1, 0);
if (!$previousCommentClosePtr) {
$phpcsFile->addError('Comment block is missing', $stackPtr -1, 'MethodArguments');
return;
}
$this->validateAnnotationBlockExists($phpcsFile, $previousCommentClosePtr, $stackPtr);
$commentStartPtr = $phpcsFile->findPrevious(T_DOC_COMMENT_OPEN_TAG, $stackPtr - 1, 0);
$commentCloserPtr = $tokens[$commentStartPtr]['comment_closer'];
$emptyTypeTokens = [
T_DOC_COMMENT_WHITESPACE,
Expand All @@ -111,7 +115,7 @@ public function process(File $phpcsFile, $stackPtr)
} else {
$this->annotationFormatValidator->validateDescriptionFormatStructure(
$phpcsFile,
(int)$commentStartPtr,
$commentStartPtr,
(int) $shortPtr,
$previousCommentClosePtr,
$emptyTypeTokens
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ public function process(File $phpcsFile, $stackPtr)
$tokens = $phpcsFile->getTokens();
$commentStartPtr = $phpcsFile->findPrevious(T_DOC_COMMENT_OPEN_TAG, ($stackPtr), 0);
$commentEndPtr = $phpcsFile->findPrevious(T_DOC_COMMENT_CLOSE_TAG, ($stackPtr), 0);
if (!$commentStartPtr) {
$phpcsFile->addError('Comment block is missing', $stackPtr, 'MethodArguments');
return;
}
$commentCloserPtr = $tokens[$commentStartPtr]['comment_closer'];
$functionPtrContent = $tokens[$stackPtr+2]['content'] ;
if (preg_match('/(?i)__construct/', $functionPtrContent)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,8 +550,12 @@ public function process(File $phpcsFile, $stackPtr)
$numTokens = count($tokens);
$previousCommentOpenPtr = $phpcsFile->findPrevious(T_DOC_COMMENT_OPEN_TAG, $stackPtr - 1, 0);
$previousCommentClosePtr = $phpcsFile->findPrevious(T_DOC_COMMENT_CLOSE_TAG, $stackPtr - 1, 0);
if (!$this->validateCommentBlockExists($phpcsFile, $previousCommentClosePtr, $stackPtr)) {
$phpcsFile->addError('Comment block is missing', $stackPtr, 'MethodArguments');
if ($previousCommentClosePtr && $previousCommentOpenPtr) {
if (!$this->validateCommentBlockExists($phpcsFile, $previousCommentClosePtr, $stackPtr)) {
$phpcsFile->addError('Comment block is missing', $stackPtr, 'MethodArguments');
return;
}
} else {
return;
}
$openParenthesisPtr = $phpcsFile->findNext(T_OPEN_PARENTHESIS, $stackPtr + 1, $numTokens);
Expand Down Expand Up @@ -663,6 +667,9 @@ private function noneParamsAligned(array $argumentPositions, array $commentPosit
foreach ($argumentPositions as $index => $argumentPosition) {
$commentPosition = $commentPositions[$index];
$type = $paramDefinitions[$index]['type'];
if ($type === null) {
continue;
}
$paramName = $paramDefinitions[$index]['paramName'];
if (($argumentPosition !== strlen($type) + 1) ||
(isset($commentPosition) && ($commentPosition !== $argumentPosition + strlen($paramName) + 1))) {
Expand Down

0 comments on commit 9884254

Please sign in to comment.