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

Class: PHP_CodeSniffer_CommentParser_AbstractParser

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

Class Overview


Parses doc comments.


Author(s):

Version:

  • Release: 1.5.2

Copyright:

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

Variables

Methods


Child classes:

Inherited Variables

Inherited Methods


Class Details

[line 69]
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, omitting 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 separate 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 77]

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



[ Top ]

$commentString =  ''

[line 84]

The string content of the comment.
  • Access: protected

Type:   string


[ Top ]

$deprecated =  null

[line 132]

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

Type:   array(PHP_CodeSniffer_CommentParser_SingleElement)


[ Top ]

$foundTags = array()

[line 108]

An array of all tags found in the comment.
  • Access: protected

Type:   array(string)


[ Top ]

$links = array()

[line 139]

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

Type:   array(PHP_CodeSniffer_CommentParser_SingleElement)


[ Top ]

$orders = array()

[line 179]

The order of tags.
  • Access: public

Type:   array(string)


[ Top ]

$phpcsFile =  null

[line 91]

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



[ Top ]

$previousElement =  null

[line 118]

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 125]

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

Type:   array(PHP_CodeSniffer_CommentParser_SingleElement)


[ Top ]

$since =  null

[line 146]

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



[ Top ]

$unknown = array()

[line 172]

An array of unknown tags.
  • Access: public

Type:   array(string)


[ Top ]

$words = array()

[line 101]

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 188]

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 655]

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 omit 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 525]

CommentElement getComment( )

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

[ Top ]

getDeprecated   [line 577]

SingleElement getDeprecated( )

Returns the deprecated element found in this comment.

Returns null if no element exists in the comment.

  • Access: public

[ Top ]

getLine   [line 390]

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 563]

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 513]

array(SingleElement) getSees( )

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

[ Top ]

getSince   [line 591]

SingleElement getSince( )

Returns the since element found in this comment.

Returns null if no element exists in the comment.

  • Access: public

[ Top ]

getTagOrders   [line 663]

array getTagOrders( )

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

[ Top ]

getTags   [line 549]

array getTags( )

Returns the list of found tags.
  • Access: public

[ Top ]

getUnknown   [line 675]

array getUnknown( )

Returns the unknown tags.
  • Access: public

[ Top ]

getWords   [line 537]

array getWords( )

Returns the word list.
  • Access: public

[ Top ]

parse   [line 204]

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 431]

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 this element.

[ Top ]

parseDeprecated   [line 451]

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 this element.

[ Top ]

parseLink   [line 493]

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 409]

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 472]

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 611]

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 @ symbol 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:56:10 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.