/**
  * Process the var tag
  *
  * @param  integer $commentStart The position in the stack where the comment started
  * @param  integer $commentEnd   The position in the stack where the comment ended
  * @return void
  */
 public function processVar($commentStart, $commentEnd)
 {
     $var = $this->commentParser->getVar();
     if ($var !== null) {
         $errorPos = $commentStart + $var->getLine();
         $index = array_keys($this->commentParser->getTagOrders(), 'var');
         if (count($index) > 1) {
             $this->currentFile->addError("Le tag @version doit être présent une seule fois dans le commentaire de variable", $errorPos, 'OneVersionTagVariableComment');
             return;
         }
         if ($index[0] !== 1) {
             $this->currentFile->addError("Le tag @version doit être présent une seule fois dans le commentaire de variable", $errorPos, 'OneVersionTagVariableComment');
         }
         $content = $var->getContent();
         if (empty($content) === true) {
             $this->currentFile->addError("Le tag @type doit être suivi du type de variable", $errorPos, 'TypeMissingVarTagVariableComment');
             return;
         } else {
             $suggestedType = PHP_CodeSniffer::suggestType($content);
             if ($content !== $suggestedType) {
                 $this->currentFile->addError('Le tag @type devrait être suivi de "' . $suggestedType . '", "' . $content . '" trouvé', $errorPos, 'ExpectedFoundVarTagVariableComment');
             }
         }
         $spacing = substr_count($var->getWhitespaceBeforeContent(), ' ');
         if ($spacing !== $this->space) {
             $this->currentFile->addError($this->space . ' espace(s) attendu(s), ' . $spacing . ' trouvé(s)', $errorPos, 'ExpectedSpacesFoundVarTagVariableComment');
         }
     } else {
         $this->currentFile->addError('Le tag @var est manquant dans le commentaire de variable', $commentEnd, 'MissingVarTagVariableComment');
     }
 }
Esempio n. 2
0
 /**
  * License tag must be 'http://matrix.squiz.net/licence Squiz.Net Open Source Licence'.
  *
  * @param int $errorPos The line number where the error occurs.
  *
  * @return void
  */
 protected function processLicense($errorPos)
 {
     $license = $this->commentParser->getLicense();
     if ($license !== null) {
         $url = $license->getValue();
         $content = $license->getComment();
         if (empty($url) === true && empty($content) === true) {
             $error = 'Content missing for @license tag in file comment';
             $this->currentFile->addError($error, $errorPos);
         } else {
             // Check for license URL.
             if (empty($url) === true) {
                 $error = 'License URL missing for @license tag in file comment';
                 $this->currentFile->addError($error, $errorPos);
             } else {
                 if ($url !== 'http://matrix.squiz.net/licence') {
                     $error = 'Expected "http://matrix.squiz.net/licence" for license URL';
                     $this->currentFile->addError($error, $errorPos);
                 }
             }
             // Check for license name.
             if (empty($content) === true) {
                 $error = 'License name missing for @license tag in file comment';
                 $this->currentFile->addError($error, $errorPos);
             } else {
                 if ($content !== 'Squiz.Net Open Source Licence') {
                     $error = 'Expected "Squiz.Net Open Source Licence" for license name';
                     $this->currentFile->addError($error, $errorPos);
                 }
             }
         }
         //end if
     }
     //end if
 }
 /**
  * Copyright tag must be in the form '2006-YYYY Squiz Pty Ltd (ABN 77 084 670 600)'.
  *
  * @param int $errorPos The first token on the line where the error occurs.
  *
  * @return void
  */
 protected function processCopyrights($errorPos)
 {
     $copyrights = $this->commentParser->getCopyrights();
     $copyright = $copyrights[0];
     if ($copyright === null) {
         return;
     }
     $content = $copyright->getContent();
     if (empty($content) === true) {
         $error = 'Content missing for @copyright tag in file comment';
         $this->currentFile->addError($error, $errorPos, 'MissingCopyright');
     } else {
         if (preg_match('/^([0-9]{4})(-[0-9]{4})? (Squiz Pty Ltd \\(ABN 77 084 670 600\\))$/', $content) === 0) {
             $error = 'Expected "xxxx-xxxx Squiz Pty Ltd (ABN 77 084 670 600)" for copyright declaration';
             $fix = $this->currentFile->addFixableError($error, $errorPos, 'IncorrectCopyright');
             if ($fix === true && $this->currentFile->fixer->enabled === true) {
                 $tokens = $this->currentFile->getTokens();
                 $matches = array();
                 preg_match('/^(\\s*\\*\\s+@copyright\\s+)(([0-9]{4})(-[0-9]{4})?)?.*$/', $tokens[$errorPos]['content'], $matches);
                 if (isset($matches[2]) === false) {
                     $matches[2] = date('Y');
                 }
                 $expected = $matches[1] . $matches[2] . ' Squiz Pty Ltd (ABN 77 084 670 600)' . $this->currentFile->eolChar;
                 $this->currentFile->fixer->replaceToken($errorPos, $expected);
             }
         }
     }
     //end if
 }
Esempio n. 4
0
 /**
  * License tag must be 'http://matrix.squiz.net/licence Hotelsnl.Net Open Source Licence'.
  *
  * @param int $errorPos The line number where the error occurs.
  *
  * @return void
  */
 protected function processLicense($errorPos)
 {
     $license = $this->commentParser->getLicense();
     if ($license !== null) {
         $url = $license->getValue();
         $content = $license->getComment();
         if (empty($url) === true && empty($content) === true) {
             $error = 'Content missing for @license tag in file comment';
             $this->currentFile->addError($error, $errorPos, 'MissingLicense');
         } else {
             // Check for license URL.
             if (empty($url) === true) {
                 $error = 'License URL missing for @license tag in file comment';
                 $this->currentFile->addError($error, $errorPos, 'MissingLinceseURL');
             } else {
                 if ($url !== 'http://www.hotels.nl/') {
                     $error = 'Expected "http://www.hotels.nl/" for license URL';
                     $this->currentFile->addError($error, $errorPos, 'IncorrectLicenseURL');
                 }
             }
         }
         //end if
     }
     //end if
 }
 /**
  * License tag must be 'http://matrix.squiz.net/licence Squiz.Net Open Source Licence'.
  *
  * @param int $errorPos The line number where the error occurs.
  *
  * @return void
  */
 protected function processLicense($errorPos)
 {
     $license = $this->commentParser->getLicense();
     if ($license !== null) {
         $url = $license->getValue();
         $content = $license->getComment();
         if (empty($url) === true && empty($content) === true) {
             $error = 'Content missing for @license tag in file comment';
             $this->currentFile->addError($error, $errorPos, 'MissingLicense');
         } else {
             // Check for license URL.
             if (empty($url) === true) {
                 $error = 'License URL missing for @license tag in file comment';
                 $this->currentFile->addError($error, $errorPos, 'MissingLicenseURL');
             } else {
                 if ($url !== 'http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt') {
                     $error = 'Expected "http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt" for license URL';
                     $this->currentFile->addError($error, $errorPos, 'IncorrectLicenseURL');
                 }
             }
             // Check for license name.
             if (empty($content) === true) {
                 $error = 'License name missing for @license tag in file comment';
                 $this->currentFile->addError($error, $errorPos, 'MissingLicenseName');
             } else {
                 if ($content !== 'GPLv2') {
                     $error = 'Expected "GPLv2" for license name';
                     $this->currentFile->addError($error, $errorPos, 'IncorrectLicenseName');
                 }
             }
         }
         //end if
     }
     //end if
 }
 /**
  * Process the var tag
  *
  * @param  integer $commentStart The position in the stack where the comment started
  * @param  integer $commentEnd   The position in the stack where the comment ended
  * @return void
  */
 public function processVar($commentStart, $commentEnd)
 {
     $var = $this->commentParser->getVar();
     if ($var !== null) {
         $errorPos = $commentStart + $var->getLine();
         $index = array_keys($this->commentParser->getTagOrders(), 'var');
         if (count($index) > 1) {
             $this->currentFile->addEvent('ONE_VERSION_TAG_VARIABLE_COMMENT', array(), $errorPos);
             return;
         }
         if ($index[0] !== 1) {
             $this->currentFile->addEvent('ONE_VERSION_TAG_VARIABLE_COMMENT', array(), $errorPos);
         }
         $content = $var->getContent();
         if (empty($content) === true) {
             $this->currentFile->addEvent('TYPE_MISSING_VAR_TAG_VARIABLE_COMMENT', array(), $errorPos);
             return;
         } else {
             $suggestedType = PHP_CodeSniffer::suggestType($content);
             if ($content !== $suggestedType) {
                 $this->currentFile->addEvent('EXPECTED_FOUND_VAR_TAG_VARIABLE_COMMENT', array('suggestedyype' => $suggestedType, 'content' => $content), $errorPos);
             }
         }
         $spacing = substr_count($var->getWhitespaceBeforeContent(), ' ');
         if ($spacing !== $this->space) {
             $this->currentFile->addEvent('EXPECTED_SPACES_FOUND_VAR_TAG_VARIABLE_COMMENT', array('space' => $this->space, 'spacing' => $spacing), $errorPos);
         }
     } else {
         $this->currentFile->addEvent('MISSING_VAR_TAG_VARIABLE_COMMENT', array(), $commentEnd);
     }
 }
Esempio n. 7
0
 function checkAccess($stackPtr, $commentStart, $commentEnd)
 {
     $tokens = $this->currentFile->getTokens();
     $access = $this->commentParser->getAccess();
     $prevWS = $this->currentFile->findPrevious(T_WHITESPACE, $stackPtr - 1, null, false, "\n");
     $type = $this->currentFile->findNext(array(T_PRIVATE, T_PUBLIC, T_PROTECTED), $prevWS + 1, $stackPtr - 1);
     $code = $tokens[$type]['code'];
     if (!is_null($access) && ($code === T_PUBLIC && $access->getValue() !== 'public' || $code === T_PRIVATE && $access->getValue() !== 'private' || $code === T_PROTECTED && $access->getValue() !== 'protected')) {
         $cnt = substr_count(preg_replace('/@access.+$/Ss', '', $this->currentFile->getTokensAsString($commentStart, $commentEnd - $commentStart + 1)), "\n");
         $this->currentFile->addError($this->getReqPrefix('REQ.PHP.4.1.25') . 'Значение тэга @access не совпадает с декларацией (декларированно как ' . $tokens[$type]['content'] . ', а @access равен ' . $access->getValue() . ')', $commentStart + $cnt);
     }
 }
Esempio n. 8
0
	/**
	 * Process the version tag.
	 *
	 * @param int $errorPos The line number where the error occurs.
	 *
	 * @return void
	 */
	protected function processVersion($errorPos)
	{
		$version = $this->commentParser->getVersion();
		if ($version !== null) {
			$content = $version->getContent();
			$matches = array();
			if (empty($content) === true) {
				$error = 'Content missing for @version tag in file comment';
				$this->currentFile->addError($error, $errorPos);
			} else if (strstr($content, 'CVS:') === false && strstr($content, 'SVN:') === false) {
				$error = "Invalid version \"$content\" in file comment; consider \"CVS: <cvs_id>\" or \"SVN: <svn_id>\" instead";
				$this->currentFile->addWarning($error, $errorPos);
			}
		}

	}//end processVersion()
 /**
  * Process the version tag
  *
  * @param  integer $errorPos The line number where the error occurs
  * @return void
  */
 protected function _processVersion($errorPos)
 {
     $version = $this->_commentParser->getVersion();
     if ($version !== null) {
         $content = $version->getContent();
         $matches = array();
         if (empty($content) === true) {
             $error = 'Content missing for @version tag in file comment';
             $this->_currentFile->addError($error, $errorPos, 'VersionTagNotEmptyFileComment');
         } else {
             if (strstr($content, '$Id: ') === false) {
                 $error = "Invalid version \"{$content}\" in file comment; consider \"\$Id: \$\"";
                 $this->_currentFile->addWarning($error, $errorPos, 'VersionValidFileComment');
             }
         }
     }
 }
 /**
  * Copyright tag must be in the form '2006-YYYY Squiz Pty Ltd (ABN 77 084 670 600)'.
  *
  * @param int $errorPos The line number where the error occurs.
  *
  * @return void
  */
 protected function processCopyrights($errorPos)
 {
     $copyrights = $this->commentParser->getCopyrights();
     $copyright = $copyrights[0];
     if ($copyright !== null) {
         $content = $copyright->getContent();
         if (empty($content) === true) {
             $error = 'Content missing for @copyright tag in file comment';
             $this->currentFile->addError($error, $errorPos, 'MissingCopyright');
         } else {
             if (preg_match('/^([0-9]{4})(-[0-9]{4})? (Squiz Pty Ltd \\(ABN 77 084 670 600\\))$/', $content) === 0) {
                 $error = 'Expected "xxxx-xxxx Squiz Pty Ltd (ABN 77 084 670 600)" for copyright declaration';
                 $this->currentFile->addError($error, $errorPos, 'IncorrectCopyright');
             }
         }
     }
 }
Esempio n. 11
0
 /**
  * Process the version tag.
  *
  * @param int $errorPos The line number where the error occurs.
  *
  * @return void
  */
 private function _processVersion($errorPos)
 {
     $version = $this->commentParser->getVersion();
     if ($version !== null) {
         $content = $version->getContent();
         $matches = array();
         if (empty($content) === true) {
             $error = 'Content missing for @version tag in file comment';
             $this->currentFile->addError($error, $errorPos);
         } else {
             if (strstr($content, 'CVS:') === false) {
                 $error = "Invalid version \"{$content}\" in file comment; Consider \"CVS: <cvs_id>\" instead.";
                 $this->currentFile->addWarning($error, $errorPos);
             }
         }
     }
 }
Esempio n. 12
0
 /**
  * Process the version tag.
  *
  * @param int $errorPos The line number where the error occurs.
  *
  * @return void
  */
 protected function processVersion($errorPos)
 {
     $version = $this->commentParser->getVersion();
     if ($version !== null) {
         $content = $version->getContent();
         $matches = array();
         if (empty($content) === true) {
             $error = 'Content missing for @version tag in file comment';
             $this->currentFile->addError($error, $errorPos);
         } else {
             if (!is_numeric($content)) {
                 $error = "Invalid version \"{$content}\" in file comment; consider a numeric value instead (e.g. 0.3.5)";
                 $this->currentFile->addWarning($error, $errorPos);
             }
         }
     }
 }
 /**
  * Process the version tag.
  *
  * @param int $errorPos The line number where the error occurs.
  *
  * @return void
  */
 protected function processVersion($errorPos)
 {
     $version = $this->commentParser->getVersion();
     if ($version !== null) {
         $content = $version->getContent();
         $matches = array();
         if (empty($content) === true) {
             $error = 'Content missing for @version tag in file comment';
             $this->currentFile->addError($error, $errorPos, 'EmptyVersion');
         } else {
             if (strstr($content, 'CVS:') === false && strstr($content, 'SVN:') === false && strstr($content, 'GIT:') === false) {
                 $error = 'Invalid version "%s" in file comment; consider "CVS: <cvs_id>" or "SVN: <svn_id>" or "GIT: <git_id>" instead';
                 $data = array($content);
                 $this->currentFile->addWarning($error, $errorPos, 'InvalidVersion', $data);
             }
         }
     }
 }
Esempio n. 14
0
 /**
  * Copyright tag must be in the form "2009-xxxx Vanilla Forums Inc.".
  *
  * @param int $errorPos The line number where the error occurs.
  *
  * @return void
  */
 protected function processCopyrights($errorPos)
 {
     $copyrights = $this->commentParser->getCopyrights();
     if (count($copyrights) > 1) {
         $vanillaFound = false;
         foreach ($copyrights as $copyright) {
             $content = $copyright->getContent();
             if (empty($content) === true) {
                 $error = 'Content missing for @copyright tag in file comment';
                 $this->currentFile->addError($error, $errorPos, 'MissingCopyright');
             }
             date_default_timezone_set('UTC');
             preg_match('/^2009\\-(\\d{4}) Vanilla Forums Inc./', $content, $matches);
             if (!empty($matches) && $matches[1] == date('Y', time())) {
                 $vanillaFound = true;
             }
         }
         if (!$vanillaFound) {
             $error = 'Expected "2009-' . date('Y') . ' Vanilla Forums Inc." for copyright declaration';
             $this->currentFile->addError($error, $errorPos, 'IncorrectCopyright');
         }
     } elseif ($copyrights[0] !== null) {
         $copyright = $copyrights[0];
         $license = $this->commentParser->getLicense();
         if ($license === null) {
             $error = 'Content missing for @license tag in file comment';
             $this->currentFile->addError($error, $errorPos, 'MissingLicense');
         }
         $content = $copyright->getContent();
         if (empty($content) === true) {
             $error = 'Content missing for @copyright tag in file comment';
             $this->currentFile->addError($error, $errorPos, 'MissingCopyright');
         }
         date_default_timezone_set('UTC');
         preg_match('/^2009\\-(\\d{4}) Vanilla Forums Inc.$/', $content, $matches);
         if (empty($matches) || $matches[1] != date('Y', time())) {
             $error = 'Expected "2009-' . date('Y') . ' Vanilla Forums Inc." for copyright declaration';
             $this->currentFile->addError($error, $errorPos, 'IncorrectCopyright');
         }
     }
 }
 /**
  * Process the see tags.
  *
  * @param int $commentStart The position in the stack where the comment started.
  *
  * @return void
  */
 protected function processSees($commentStart)
 {
     $sees = $this->commentParser->getSees();
     if (empty($sees) === false) {
         foreach ($sees as $see) {
             $errorPos = $commentStart + $see->getLine();
             $content = $see->getContent();
             if (empty($content) === true) {
                 $error = 'Content missing for @see tag in variable comment';
                 $this->currentFile->addError($error, $errorPos, 'EmptySees');
                 continue;
             }
             $spacing = substr_count($see->getWhitespaceBeforeContent(), ' ');
             if ($spacing !== 1) {
                 $error = '@see tag indented incorrectly; expected 1 spaces but found %s';
                 $data = array($spacing);
                 $this->currentFile->addError($error, $errorPos, 'SeesIndent', $data);
             }
         }
     }
 }
 /**
  * Process the see tags.
  *
  * @param int $commentStart The position in the stack where the comment started.
  *
  * @return void
  */
 protected function processSees($commentStart)
 {
     $sees = $this->commentParser->getSees();
     if (empty($sees) === false) {
         foreach ($sees as $see) {
             $errorPos = $commentStart + $see->getLine();
             $content = $see->getContent();
             if (empty($content) === true) {
                 $error = 'Content missing for @see tag in variable comment';
                 $this->currentFile->addError($error, $errorPos);
                 continue;
             }
             $spacing = substr_count($see->getWhitespaceBeforeContent(), ' ');
             if ($spacing !== 3) {
                 $error = '@see tag indented incorrectly. ';
                 $error .= "Expected 3 spaces but found {$spacing}.";
                 $this->currentFile->addError($error, $errorPos);
             }
         }
     }
 }
Esempio n. 17
0
 /**
  * Processes this test, when one of its tokens is encountered.
  *
  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
  * @param int                  $stackPtr  The position of the current token
  *                                        in the stack passed in $tokens.
  *
  * @return void
  */
 public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
 {
     $this->currentFile = $phpcsFile;
     // We are only interested if this is the first open tag.
     if ($stackPtr !== 0) {
         if ($phpcsFile->findPrevious(T_OPEN_TAG, $stackPtr - 1) !== false) {
             return;
         }
     }
     $tokens = $phpcsFile->getTokens();
     // Find the next non whitespace token.
     $commentStart = $phpcsFile->findNext(T_WHITESPACE, $stackPtr + 1, null, true);
     if ($tokens[$commentStart]['code'] === T_CLOSE_TAG) {
         // We are only interested if this is the first open tag.
         return;
     } else {
         if ($tokens[$commentStart]['code'] !== T_COMMENT) {
             //$error = 'You must use "/*" style comments for a file comment';
             //$phpcsFile->addError($error, $commentStart);
             $phpcsFile->addEvent('XP_CLASS_HEADER_INVALID', $commentStart);
             return;
         } else {
             if ($commentStart === false || $tokens[$commentStart]['code'] !== T_COMMENT) {
                 //$phpcsFile->addError('Missing file doc comment', $errorToken);
                 $phpcsFile->addEvent('XP_CLASS_HEADER_MISSING', $commentStart);
                 return;
             } else {
                 // File header must directly follow opening tag
                 if ($tokens[$commentStart]['line'] !== $tokens[$stackPtr]['line'] + 1) {
                     //$error = 'File header not directly following open tag';
                     //$phpcsFile->addError($error, $commentStart);
                     $phpcsFile->addEvent('XP_CLASS_HEADER_NOT_AFTER_OPEN_TAG', $commentStart);
                 }
                 // Extract the header comment docblock.
                 $commentEnd = $phpcsFile->findNext(T_COMMENT, $commentStart + 1, null, true) - 1;
                 $comment = $phpcsFile->getTokensAsString($commentStart, $commentEnd - $commentStart + 1);
                 // Parse the header comment docblock.
                 try {
                     $this->commentParser = new PHP_CodeSniffer_CommentParser_ClassCommentParser($comment, $phpcsFile);
                     $this->commentParser->parse();
                 } catch (PHP_CodeSniffer_CommentParser_ParserException $e) {
                     $line = $e->getLineWithinComment() + $commentStart;
                     //$phpcsFile->addError($e->getMessage(), $line);
                     $phpcsFile->addEvent('XP_CLASS_HEADER_EXCEPTION', array('message' => $e->getMessage()), $line);
                     return;
                 }
                 $comment = $this->commentParser->getComment();
                 // No extra newline before short description.
                 $short = $comment->getShortComment();
                 $newlineCount = 0;
                 $newlineSpan = strspn($short, $phpcsFile->eolChar);
                 if ($short !== '' && $newlineSpan > 0) {
                     $line = $newlineSpan > 1 ? 'newlines' : 'newline';
                     //$error = "Extra $line found before file comment short description";
                     //$phpcsFile->addError($error, ($commentStart + 1));
                     $phpcsFile->addEvent('XP_CLASS_HEADER_NEWLINE_BEFORE_SHORT_DESCRIPTION', array(), $commentStart + 1);
                 }
                 $found = FALSE;
                 if (strstr(trim($short), '$Id')) {
                     //$error = "There must be an empty line between SVN ID tag and the description";
                     //$phpcsFile->addError($error, ($commentStart));
                     $phpcsFile->addEvent('XP_CLASS_HEADER_EMPTYLINE_BETWEEN_SHORT_DESCRIPTION_AND_SVNID', array(), $commentStart + 1);
                     $found = TRUE;
                 }
                 $newlineCount = substr_count($short, $phpcsFile->eolChar) + 1;
                 // Exactly one blank line between short and long description.
                 $long = $comment->getLongComment();
                 if (empty($long) === false) {
                     $between = $comment->getWhiteSpaceBetween();
                     $newlineBetween = substr_count($between, $phpcsFile->eolChar);
                     if ($newlineBetween !== 2) {
                         //$error = 'There must be exactly one blank line between description and the ID Tag';
                         //$phpcsFile->addError($error, ($commentStart + $newlineCount + 1));
                         $phpcsFile->addEvent('XP_CLASS_HEADER_EMPTYLINE_BETWEEN_DESCRIPTION_AND_ID', array(), $commentStart + $newlineCount + 1);
                     }
                     if (!strstr(trim($long), '$Id')) {
                         //$error = 'SVN Id tag is corrupt';
                         //$phpcsFile->addError($error, ($commentStart + $newlineCount + 1));
                         $phpcsFile->addEvent('XP_CLASS_HEADER_SVNID_CORRUPT', array(), $commentStart + $newlineCount + 1);
                     }
                     $newlineCount += $newlineBetween;
                 } elseif (!$found) {
                     //$error = 'SVN Id tag is missing';
                     //$phpcsFile->addError($error, ($commentStart + $newlineCount + 1));
                     $phpcsFile->addEvent('XP_CLASS_HEADER_SVNID_MISSING', array(), $commentStart + $newlineCount + 1);
                 }
                 if (2 < $comment->getNewlineAfter()) {
                     //$error = 'Extra content after SVN ID Tag';
                     //$phpcsFile->addError($error, ($commentStart + $newlineCount));
                     $phpcsFile->addEvent('XP_CLASS_HEADER_CONTENT_AFTER_SVNID', array(), $commentStart + $newlineCount);
                 }
             }
         }
     }
     //end if
 }
 /**
  * Processes this test, when one of its tokens is encountered.
  *
  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
  * @param int                  $stackPtr  The position of the current token
  *                                        in the stack passed in $tokens.
  *
  * @return void
  */
 public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
 {
     $this->currentFile = $phpcsFile;
     // We are only interested if this is the first open tag.
     if ($stackPtr !== 0) {
         if ($phpcsFile->findPrevious(T_OPEN_TAG, $stackPtr - 1) !== false) {
             return;
         }
     }
     $tokens = $phpcsFile->getTokens();
     // Find the next non whitespace token.
     $commentStart = $phpcsFile->findNext(T_WHITESPACE, $stackPtr + 1, null, true);
     // Ignore vim header.
     if ($tokens[$commentStart]['code'] === T_COMMENT) {
         if (strstr($tokens[$commentStart]['content'], 'vim:') !== false) {
             $commentStart = $phpcsFile->findNext(T_WHITESPACE, $commentStart + 1, null, true);
         }
     }
     if ($tokens[$commentStart]['code'] === T_CLOSE_TAG) {
         // We are only interested if this is the first open tag.
         return;
     } else {
         if ($tokens[$commentStart]['code'] === T_COMMENT) {
             $phpcsFile->addError('You must use "/**" style comments for a file comment', $stackPtr + 1);
             return;
         } else {
             if ($commentStart === false || $tokens[$commentStart]['code'] !== T_DOC_COMMENT) {
                 $phpcsFile->addError('Missing file doc comment', $stackPtr + 1);
                 return;
             } else {
                 // Extract the header comment docblock.
                 $commentEnd = $phpcsFile->findNext(T_DOC_COMMENT, $commentStart + 1, null, true) - 1;
                 // Check if there is only 1 doc comment between the open tag and class token.
                 $nextToken = array(T_ABSTRACT, T_CLASS, T_FUNCTION, T_DOC_COMMENT);
                 $commentNext = $phpcsFile->findNext($nextToken, $commentEnd + 1);
                 if ($commentNext !== false && $tokens[$commentNext]['code'] !== T_DOC_COMMENT) {
                     // Found a class token right after comment doc block.
                     $newlineToken = $phpcsFile->findNext(T_WHITESPACE, $commentEnd + 1, $commentNext, false, $phpcsFile->eolChar);
                     if ($newlineToken !== false) {
                         $newlineToken = $phpcsFile->findNext(T_WHITESPACE, $newlineToken + 1, $commentNext, false, $phpcsFile->eolChar);
                         if ($newlineToken === false) {
                             // No blank line between the class token and the doc block.
                             // The doc block is most likely a class comment.
                             $phpcsFile->addError('Missing file doc comment', $stackPtr + 1);
                             return;
                         }
                     }
                 }
                 $comment = $phpcsFile->getTokensAsString($commentStart, $commentEnd - $commentStart + 1);
                 // Parse the header comment docblock.
                 try {
                     $this->commentParser = new PHP_CodeSniffer_CommentParser_ClassCommentParser($comment, $phpcsFile);
                     $this->commentParser->parse();
                 } catch (PHP_CodeSniffer_CommentParser_ParserException $e) {
                     $line = $e->getLineWithinComment() + $commentStart;
                     $phpcsFile->addError($e->getMessage(), $line);
                     return;
                 }
                 $comment = $this->commentParser->getComment();
                 if (is_null($comment) === true) {
                     $error = 'File doc comment is empty';
                     $phpcsFile->addError($error, $commentStart);
                     return;
                 }
                 // No extra newline before short description.
                 $short = $comment->getShortComment();
                 $newlineCount = 0;
                 $newlineSpan = strspn($short, $phpcsFile->eolChar);
                 if ($short !== '' && $newlineSpan > 0) {
                     $line = $newlineSpan > 1 ? 'newlines' : 'newline';
                     $error = "Extra {$line} found before file comment short description";
                     $phpcsFile->addError($error, $commentStart + 1);
                 }
                 $newlineCount = substr_count($short, $phpcsFile->eolChar) + 1;
                 // Exactly one blank line between short and long description.
                 $long = $comment->getLongComment();
                 if (empty($long) === false) {
                     $between = $comment->getWhiteSpaceBetween();
                     $newlineBetween = substr_count($between, $phpcsFile->eolChar);
                     if ($newlineBetween !== 2) {
                         $error = 'There must be exactly one blank line between descriptions in file comment';
                         $phpcsFile->addError($error, $commentStart + $newlineCount + 1);
                     }
                     $newlineCount += $newlineBetween;
                 }
                 // Exactly one blank line before tags.
                 $tags = $this->commentParser->getTagOrders();
                 if (count($tags) > 1) {
                     $newlineSpan = $comment->getNewlineAfter();
                     if ($newlineSpan !== 2) {
                         $error = 'There must be exactly one blank line before the tags in file comment';
                         if ($long !== '') {
                             $newlineCount += substr_count($long, $phpcsFile->eolChar) - $newlineSpan + 1;
                         }
                         $phpcsFile->addError($error, $commentStart + $newlineCount);
                         $short = rtrim($short, $phpcsFile->eolChar . ' ');
                     }
                 }
                 // Check each tag.
                 $this->processTags($commentStart, $commentEnd);
             }
         }
     }
     //end if
 }