Esempio n. 1
0
 /**
  * Process any throw tags that this function comment has.
  *
  * @param int $commentStart The position in the stack where the
  *                          comment started.
  *
  * @return void
  */
 protected function processThrows($commentStart)
 {
     if (count($this->commentParser->getThrows()) === 0) {
         return;
     }
     foreach ($this->commentParser->getThrows() as $throw) {
         $exception = $throw->getValue();
         $errorPos = $commentStart + $throw->getLine();
         if ($exception === '') {
             $error = '@throws tag must contain the exception class name';
             $this->currentFile->addError($error, $errorPos, 'EmptyThrows');
         }
     }
 }
 /**
  * Process any throw tags that this function comment has.
  *
  * @param int $commentStart The position in the stack where the comment started.
  *
  * @return void
  */
 protected function processThrows($commentStart)
 {
     if (count($this->commentParser->getThrows()) === 0) {
         return;
     }
     $tagOrder = $this->commentParser->getTagOrders();
     $index = array_keys($this->commentParser->getTagOrders(), 'throws');
     foreach ($this->commentParser->getThrows() as $i => $throw) {
         $exception = $throw->getValue();
         $content = trim($throw->getComment());
         $errorPos = $commentStart + $throw->getLine();
         if (empty($exception) === true) {
             $this->helper->addMessage($errorPos, M2_Sniffs_Annotations_Helper::INVALID_THROWS);
         } elseif (empty($content) === true) {
             $this->helper->addMessage($errorPos, M2_Sniffs_Annotations_Helper::EMPTY_THROWS);
         } else {
             // Assumes that $content is not empty.
             // Starts with a capital letter and ends with a fullstop.
             $firstChar = $content[0];
             if (strtoupper($firstChar) !== $firstChar) {
                 $this->helper->addMessage($errorPos, M2_Sniffs_Annotations_Helper::THROWS_NOT_CAPITAL);
             }
             $lastChar = $content[strlen($content) - 1];
             if ($lastChar !== '.') {
                 $this->helper->addMessage($errorPos, M2_Sniffs_Annotations_Helper::THROWS_NO_FULL_STOP);
             }
         }
         $since = array_keys($tagOrder, 'since');
         if (count($since) === 1 && $this->_tagIndex !== 0) {
             $this->_tagIndex++;
             if ($index[$i] !== $this->_tagIndex) {
                 $this->helper->addMessage($errorPos, M2_Sniffs_Annotations_Helper::THROWS_ORDER);
             }
         }
     }
 }