/** * Process the return comment of this function comment. * * @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 */ protected function processReturn($commentStart, $commentEnd) { // Skip constructor and destructor. $className = ''; if ($this->_classToken !== null) { $className = $this->currentFile->getDeclarationName($this->_classToken); $className = strtolower(ltrim($className, '_')); } $methodName = strtolower(ltrim($this->_methodName, '_')); $isSpecialMethod = $this->_methodName === '__construct' || $this->_methodName === '__destruct'; // Check type if ($this->commentParser->getReturn()) { $r = $this->checkType($this->commentParser->getReturn()->getValue(), $this->allowedReturnTypes, 'return'); if (true !== $r) { $this->currentFile->addError($this->getReqPrefix('REQ.PHP.3.5.15') . $r, $commentStart + $this->commentParser->getReturn()->getLine()); } } // Check comment case if ($this->commentParser->getReturn()->getComment() && preg_match('/^[a-z]/Ss', trim($this->commentParser->getReturn()->getComment()))) { $error = 'Комментарий аннотации возврата метода начинается с маленькой буквы'; $this->currentFile->addError($this->getReqPrefix('?') . $error, $commentStart + $this->commentParser->getReturn()->getLine()); } if ($isSpecialMethod === false && $methodName !== $className) { // Report missing return tag. if ($this->commentParser->getReturn() === null) { $error = 'Missing @return tag in function comment'; $this->currentFile->addError($this->getReqPrefix($this->reqCodeEmpty) . $error, $commentEnd); } else { if (trim($this->commentParser->getReturn()->getRawContent()) === '') { $error = '@return tag is empty in function comment'; $errorPos = $commentStart + $this->commentParser->getReturn()->getLine(); $this->currentFile->addError($this->getReqPrefix($this->reqCodeEmpty) . $error, $errorPos); } } } }