BenManu\StyleGuide\CommentParser
CommentParser
Searches a file for all single line and multi-line comments and stores them
in the object for later use.
Synopsis
class CommentParser
{
- // members
- protected SplFileObject $file = NULL;
- protected array $options = ;
- protected array $blocks = ;
- protected boolean $parsed = false;
- // methods
- public void __construct()
- public array getBlocks()
- protected array parseBlocks()
- protected string normalize()
- public static boolean isSingleLineComment()
- public static boolean isStartMultiLineComment()
- public static boolean isEndMultiLineComment()
- public static string parseSingleLineComment()
- public static string parseMultiLineComment()
Members
protected
- $blocks
—
array
Storage for comment blocks - $file
—
\SplFileObject
File being parsed - $options
—
array
Options use to control the parser - $parsed
—
boolean
Flag for whether the file has been parsed for comments yet
Methods
protected
- normalize() — Makes all the white space consistent among the lines in a comment block.
- parseBlocks() — Parses each line of the file looking for single or multi-line comments
public
- __construct() — Sets up the parser with the file needed and any options to use when parsing
- getBlocks() — Returns the parsed comment blocks or if object is not yet parsed, parses first and then returns the result
- isEndMultiLineComment() — Checks if the line is the end of a multi-line comment
- isSingleLineComment() — Checks if the comment is a single line comment
- isStartMultiLineComment() — Checks if the line is the start of a multi-line comment
- parseMultiLineComment() — Removes the comment markers from a multi line comment and trims the line
- parseSingleLineComment() — Removes the comment markers from a single line comment and trims the line