/**
  * Returns the line in which this element first occured.
  *
  * @return int
  */
 public function getLine()
 {
     if ($this->previousElement === null) {
         // First element is on line one.
         return 1;
     } else {
         $previousContent = $this->previousElement->getRawContent();
         $previousLine = $this->previousElement->getLine();
         return $previousLine + substr_count($previousContent, $this->phpcsFile->eolChar);
     }
 }
Esempio n. 2
0
 /**
  * Get the indentation information of each tag.
  *
  * @param string                                   $tagName    The name of the
  *                                                             doc comment
  *                                                             element.
  * @param PHP_CodeSniffer_CommentParser_DocElement $tagElement The doc comment
  *                                                             element.
  *
  * @return void
  */
 protected function getIndentation($tagName, $tagElement)
 {
     if ($tagElement instanceof PHP_CodeSniffer_CommentParser_SingleElement) {
         if ($tagElement->getContent() !== '') {
             return strlen($tagName) + substr_count($tagElement->getWhitespaceBeforeContent(), ' ');
         }
     } else {
         if ($tagElement instanceof PHP_CodeSniffer_CommentParser_PairElement) {
             if ($tagElement->getValue() !== '') {
                 return strlen($tagName) + substr_count($tagElement->getWhitespaceBeforeValue(), ' ');
             }
         }
     }
     return 0;
 }