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

Class: PHP_CodeSniffer_CommentParser_AbstractParser

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

Class Overview


Parses doc comments.


Author(s):

Version:

  • Release: 0.7.0

Copyright:

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

Variables

Methods


Child classes:

Inherited Variables

Inherited Methods


Class Details

[line 59]
Parses doc comments.

This abstract parser handles the following tags:

  • The short description and the long description
  • @see
  • @link
  • @deprecated
  • @since

Extending classes should implement the getAllowedTags() method to return the tags that they wish to process, ommiting the tags that this base class processes. When one of these tags in encountered, the process<tag_name> method is called on that class. For example, if a parser's getAllowedTags() method returns \@param as one of its tags, the processParam method will be called so that the parser can process such a tag.

The method is passed the tokens that comprise this tag. The tokens array includes the whitespace that exists between the tokens, as seperate tokens. It's up to the method to create a element that implements the DocElement interface, which should be returned. The AbstractDocElement class is a helper class that can be used to handle most of the parsing of the tokens into their individual sub elements. It requires that you construct it with the element previous to the element currently being processed, which can be acquired with the protected $previousElement class member of this class.



[ Top ]


Class Variables

$comment =  null

[line 67]

The comment element that appears in the doc comment.
  • Access: protected



[ Top ]

$commentString =  ''

[line 74]

The string content of the comment.
  • Access: protected

Type:   string


[ Top ]

$deprecated =  null

[line 115]

A list of see elements that appear in this doc comment.
  • Access: protected

Type:   array(PHP_CodeSniffer_CommentParser_SingleElement)


[ Top ]

$links = array()

[line 122]

A list of see elements that appear in this doc comment.
  • Access: protected

Type:   array(PHP_CodeSniffer_CommentParser_SingleElement)


[ Top ]

$orders = array()

[line 162]

The order of tags.
  • Access: public

Type:   array(string)


[ Top ]

$phpcsFile =  null

[line 81]

The file that the comment exists in.
  • Access: protected



[ Top ]

$previousElement =  null

[line 101]

The previous doc element that was processed.

null if the current element being processed is the first element in the doc comment.

  • Access: protected



[ Top ]

$sees = array()

[line 108]

A list of see elements that appear in this doc comment.
  • Access: protected

Type:   array(PHP_CodeSniffer_CommentParser_SingleElement)


[ Top ]

$since =  null

[line 129]

A element to represent \@since tags.
  • Access: protected



[ Top ]

$unknown = array()

[line 155]

An array of unknown tags.
  • Access: public

Type:   array(string)


[ Top ]

$words = array()

[line 91]

The word tokens that appear in the comment.

Whitespace tokens also appear in this stack, but are separate tokens from words.

  • Access: protected

Type:   array(string)


[ Top ]



Method Detail

__construct (Constructor)   [line 171]

PHP_CodeSniffer_CommentParser_AbstractParser __construct( string $comment, PHP_CodeSniffer_File $phpcsFile)

Constructs a Doc Comment Parser.
  • Access: public

Overridden in child classes as:

PHP_CodeSniffer_CommentParser_FunctionCommentParser::__construct()
Constructs a PHP_CodeSniffer_CommentParser_FunctionCommentParser.

Parameters:

string   $comment   —  The comment to parse.
PHP_CodeSniffer_File   $phpcsFile   —  The file that this comment is in.

[ Top ]

getAllowedTags   [line 546]

array(string getAllowedTags( )

Returns a list of tags that this comment parser allows for it's comment.

Each tag should indicate if only one entry of this tag can exist in the comment by specifying true as the array value, or false if more than one is allowed. Each tag should ommit the @ symbol. Only tags other than the standard tags should be returned.

  • Return: => boolean)
  • Abstract:
  • Access: protected

Overridden in child classes as:

PHP_CodeSniffer_CommentParser_FunctionCommentParser::getAllowedTags()
Returns the allowed tags that can exist in a function comment.
PHP_CodeSniffer_CommentParser_ClassCommentParser::getAllowedTags()
Returns the allowed tags withing a class comment.
PHP_CodeSniffer_CommentParser_MemberCommentParser::getAllowedTags()
Returns the allowed tags for this parser.

[ Top ]

getComment   [line 447]

CommentElement getComment( )

Returns the comment element that appears at the top of this doc comment.
  • Access: public

[ Top ]

getDeprecated   [line 475]

SingleElement getDeprecated( )

Returns the deprecated element found in this comment.

Returns null if no element exists in the comment.

  • Access: public

[ Top ]

getLine   [line 341]

int getLine( int $tokenPos)

Returns the line that the token exists on in the doc comment.
  • Access: protected

Parameters:

int   $tokenPos   —  The position in the words stack to find the line number for.

[ Top ]

getLinks   [line 461]

array(SingleElement) getLinks( )

Returns the link elements found in this comment.

Returns an empty array if no links are found in the comment.

  • Access: public

[ Top ]

getSees   [line 435]

array(SingleElement) getSees( )

Returns the see elements that appear in this doc comment.
  • Access: public

[ Top ]

getSince   [line 489]

SingleElement getSince( )

Returns the since element found in this comment.

Returns null if no element exists in the comment.

  • Access: public

[ Top ]

getTagOrders   [line 554]

array getTagOrders( )

Returns the tag orders (index => tagName).
  • Access: public

[ Top ]

getUnknown   [line 566]

array getUnknown( )

Returns the unknown tags.
  • Access: public

[ Top ]

parse   [line 187]

void parse( )

Initiates the parsing of the doc comment.
  • Throws: PHP_CodeSniffer_CommentParser_ParserException If the parser finds a problem with the comment.
  • Access: public

[ Top ]

parseComment   [line 376]

DocElement parseComment( array(string) $tokens)

Parses the comment element that appears at the top of the doc comment.
  • Return: The element that represents this comment element.
  • Access: protected

Parameters:

array(string)   $tokens   —  The word tokens that comprise tihs element.

[ Top ]

parseDeprecated   [line 391]

DocElement parseDeprecated( array(string) $tokens)

Parses \@deprecated tags.
  • Return: The element that represents this deprecated tag.
  • Access: protected

Parameters:

array(string)   $tokens   —  The word tokens that comprise tihs element.

[ Top ]

parseLink   [line 421]

SingleElement parseLink( array(string) $tokens)

Parses \@link tags.
  • Return: The element that represents this link tag.
  • Access: protected

Parameters:

array(string)   $tokens   —  The word tokens that comprise this element.

[ Top ]

parseSee   [line 360]

DocElement parseSee( array(string) $tokens)

Parses see tag element within the doc comment.
  • Return: The element that represents this see comment.
  • Access: protected

Parameters:

array(string)   $tokens   —  The word tokens that comprise this element.

[ Top ]

parseSince   [line 406]

SingleElement parseSince( array(string) $tokens)

Parses \@since tags.
  • Return: The element that represents this since tag.
  • Access: protected

Parameters:

array(string)   $tokens   —  The word tokens that comprise this element.

[ Top ]

parseTag   [line 509]

void parseTag( string $tag, int $start, int $end)

Parses the specified tag.
  • Throws: Exception If the process method for the tag cannot be found.
  • Access: protected

Parameters:

string   $tag   —  The tag name to parse (omitting the @ sybmol from the tag)
int   $start   —  The position in the word tokens where this element started.
int   $end   —  The position in the word tokens where this element ended.

[ Top ]


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