PHP_CodeSniffer
[ class tree: PHP_CodeSniffer ] [ index: PHP_CodeSniffer ] [ all elements ]

Class: PHP_CodeSniffer_CommentParser_AbstractDocElement

Source Location: /PHP_CodeSniffer-0.7.0/CodeSniffer/CommentParser/AbstractDocElement.php

Class Overview


A class to handle most of the parsing operations of a doc comment element.


Author(s):

Version:

  • Release: 0.7.0

Copyright:

  • 2006 Squiz Pty Ltd (ABN 77 084 670 600)

Variables

Methods


Child classes:

PHP_CodeSniffer_CommentParser_PairElement
A class to represent elements that have a value => comment format.
PHP_CodeSniffer_CommentParser_ParameterElement
A class to represent param tags within a function comment.
PHP_CodeSniffer_CommentParser_SingleElement
A class to represent single element doc tags.

Inherited Variables

Inherited Methods


Class Details

[line 62]
A class to handle most of the parsing operations of a doc comment element.

Extending classes should implement the getSubElements method to return a list of elements that the doc comment element contains, in the order that they appear in the element. For example a function parameter element has a type, a variable name and a comment. It should therefore implement the method as follows:

  1.     protected function getSubElements()
  2.     {
  3.         return array(
  4.                 'type',
  5.                 'variable',
  6.                 'comment',
  7.                );
  8.     }

The processSubElement will be called for each of the sub elements to allow the extending class to process them. So for the parameter element we would have:

  1.     protected function processSubElement($name$content$whitespaceBefore)
  2.     {
  3.         if ($name === 'type'{
  4.             echo 'The name of the variable was '.$content;
  5.         }
  6.         // Process other tags.
  7.     }



[ Top ]


Class Variables

$afterWhitespace =  ''

[line 84]

The whitespace the occurs after this element and its sub elements.
  • Access: protected

Type:   string


[ Top ]

$nextElement =  null

[line 77]

The element proceeding this element.
  • Access: protected



[ Top ]

$phpcsFile =  null

[line 98]

The file this element is in.
  • Access: protected

Type:   array(string)


[ Top ]

$previousElement =  null

[line 70]

The element previous to this element.
  • Access: protected



[ Top ]

$tag =  ''

[line 105]

The tag that this element represents (omiting the @ symbol).
  • Access: protected

Type:   string


[ Top ]

$tokens = array()

[line 91]

The tokens that comprise this element.
  • Access: protected

Type:   array(string)


[ Top ]



Method Detail

__construct (Constructor)   [line 120]

PHP_CodeSniffer_CommentParser_AbstractDocElement __construct( PHP_CodeSniffer_CommentParser_DocElement $previousElement, array $tokens, string $tag, PHP_CodeSniffer_File $phpcsFile)

Constructs a Doc Element.
  • Throws: Exception If $previousElement in not a DocElement or if getSubElements() does not return an array.
  • Access: public

Overridden in child classes as:

PHP_CodeSniffer_CommentParser_PairElement::__construct()
Constructs a PHP_CodeSniffer_CommentParser_PairElement doc tag.
PHP_CodeSniffer_CommentParser_ParameterElement::__construct()
Constructs a PHP_CodeSniffer_CommentParser_ParameterElement.
PHP_CodeSniffer_CommentParser_SingleElement::__construct()
Constructs a SingleElement doc tag.
PHP_CodeSniffer_CommentParser_CommentElement::__construct()
Constructs a PHP_CodeSniffer_CommentParser_CommentElement.

Parameters:

PHP_CodeSniffer_CommentParser_DocElement   $previousElement   —  The element that ocurred before this.
array   $tokens   —  The tokens of this element.
string   $tag   —  The doc element tag this element represents.
PHP_CodeSniffer_File   $phpcsFile   —  The file that this element is in.

[ Top ]

getLine   [line 275]

int getLine( )

Returns the line in which this element first occured.
  • Access: public

[ Top ]

getNextElement   [line 195]

PHP_CodeSniffer_CommentParser_DocElement getNextElement( )

Returns the element that exists after this.
  • Access: public

[ Top ]

getOrder   [line 235]

int getOrder( )

Returns the order that this element appears in the comment.
  • Access: public

[ Top ]

getPreviousElement   [line 183]

PHP_CodeSniffer_CommentParser_DocElement getPreviousElement( )

Returns the element that exists before this.
  • Access: public

[ Top ]

getRawContent   [line 263]

string getRawContent( )

Returns the raw content of this element, ommiting the tag.
  • Access: public

[ Top ]

getSubElements   [line 297]

array(string) getSubElements( )

Returns the sub element names that make up this element in the order they appear in the element.

Overridden in child classes as:

PHP_CodeSniffer_CommentParser_PairElement::getSubElements()
Returns the element names that this tag is comprised of, in the order that they appear in the tag.
PHP_CodeSniffer_CommentParser_ParameterElement::getSubElements()
Returns the element names that this tag is comprised of, in the order that they appear in the tag.
PHP_CodeSniffer_CommentParser_SingleElement::getSubElements()
Returns the element names that this tag is comprised of, in the order that they appear in the tag.

[ Top ]

getTag   [line 251]

string getTag( )

Returns the tag that this element represents, ommiting the @ symbol.
  • Access: public

[ Top ]

getWhitespaceAfter   [line 223]

string getWhitespaceAfter( )

Returns the whitespace that exists after this element.
  • Access: public

[ Top ]

getWhitespaceBefore   [line 207]

string getWhitespaceBefore( )

Returns the whitespace that exists before this element.
  • Access: public

[ Top ]

processSubElement   [line 311]

void processSubElement( string $name, string $content, string $whitespaceBefore)

Called to process each sub element as sepcified in the return value of getSubElements().

Overridden in child classes as:

PHP_CodeSniffer_CommentParser_PairElement::processSubElement()
Processes the sub element with the specified name.
PHP_CodeSniffer_CommentParser_ParameterElement::processSubElement()
Processes the sub element with the specified name.
PHP_CodeSniffer_CommentParser_SingleElement::processSubElement()
Processes the sub element with the specified name.

Parameters:

string   $name   —  The name of the element to process.
string   $content   —  The content of the the element.
string   $whitespaceBefore   —  The whitespace found before this element.

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:06:33 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.