/** * Process the since tag * * @param integer $commentStart The position in the stack where the comment started * @return void */ protected function _processSince($commentStart) { $since = $this->_commentParser->getSince(); if ($since !== null) { $errorPos = $commentStart + $since->getLine(); $tagOrder = $this->_commentParser->getTagOrders(); $firstTag = 0; while ($tagOrder[$firstTag] === 'comment' or $tagOrder[$firstTag] === 'param') { $firstTag++; } $cnt = 99; foreach ($tagOrder as $tag => $content) { if ($content === 'param') { if ($cnt < $tag) { $error = 'The @since tag is in the wrong order; the tag follows @param (if used)'; $this->_currentFile->addError($error, $errorPos); } } if ($content === 'since') { $cnt = $tag; } } $this->_tagIndex = $firstTag; $index = array_keys($this->_commentParser->getTagOrders(), 'since'); if (count($index) > 1) { $error = 'Only 1 @since tag is allowed in function comment'; $this->_currentFile->addError($error, $errorPos); return; } if ($index[0] !== $firstTag) { $error = 'The @since tag is in the wrong order; the tag preceds @see (if used), ' . '@throws (if used) and @return'; $this->_currentFile->addError($error, $errorPos); } $content = $since->getContent(); if (empty($content) === true) { $error = 'Version number missing for @since tag in function comment'; $this->_currentFile->addError($error, $errorPos); return; } else { if ($content !== '%release_version%') { if (preg_match('/^([0-9]+)\\.([0-9]+)\\.([0-9]+)/', $content) === 0) { $error = 'Expected version number to be in the form x.x.x in @since tag'; $this->_currentFile->addError($error, $errorPos); } } } $spacing = substr_count($since->getWhitespaceBeforeContent(), ' '); if ($spacing !== 2) { $error = '@since tag indented incorrectly; '; $error .= "expected 2 spaces but found {$spacing}."; $this->_currentFile->addError($error, $errorPos); } } }
/** * Process the since tag. * * @param int $commentStart The position in the stack where the comment started. * @param int $commentEnd The position in the stack where the comment ended. * * @return void */ private function _processSince($commentStart, $commentEnd) { $since = $this->commentParser->getSince(); if ($since !== null) { $errorPos = $commentStart + $since->getLine(); $tagOrder = $this->commentParser->getTagOrders(); $firstTag = 0; while ($tagOrder[$firstTag] === 'comment' || $tagOrder[$firstTag] === 'param') { $firstTag++; } $this->_tagIndex = $firstTag; $index = array_keys($this->commentParser->getTagOrders(), 'since'); if (count($index) > 1) { $error = 'Only 1 @since tag is allowed in function comment'; $this->currentFile->addError($error, $errorPos); return; } if ($index[0] !== $firstTag) { $error = 'The order of @since tag is wrong in function comment'; $this->currentFile->addError($error, $errorPos); } $content = $since->getContent(); if (empty($content) === true) { $error = 'Version number missing for @since tag in function comment'; $this->currentFile->addError($error, $errorPos); return; } else { if ($content !== '%release_version%') { if (preg_match('/^([0-9]+)\\.([0-9]+)\\.([0-9]+)/', $content) === 0) { $error = 'Expected version number to be in the form x.x.x in @since tag'; $this->currentFile->addError($error, $errorPos); } } } $spacing = substr_count($since->getWhitespaceBeforeContent(), ' '); $return = $this->commentParser->getReturn(); $throws = $this->commentParser->getThrows(); $correctSpacing = $return !== null || empty($throws) === false ? 2 : 1; if ($spacing !== $correctSpacing) { $error = '@since tag indented incorrectly. '; $error .= "Expected {$correctSpacing} spaces but found {$spacing}."; $this->currentFile->addError($error, $errorPos); } } else { // since tag is not really required in functions... // $error = 'Missing @since tag in function comment'; // $this->currentFile->addError($error, $commentEnd); } //end if }