TokenParser
in package
Parses a file for namespaces/use/class declarations.
Table of Contents
- $numTokens : int
- The number of tokens.
- $pointer : int
- The current array pointer.
- $tokens : mixed
- The token list.
- __construct() : mixed
- next() : array<string|int, mixed>|string|null
- Gets the next non whitespace and non comment token.
- parseClass() : string
- Gets the class name.
- parseNamespace() : string
- Gets the namespace.
- parseUseStatement() : array<string, string>
- Parses a single use statement.
- parseUseStatements() : array<string, string>
- Gets all use statements.
Properties
$numTokens
The number of tokens.
private
int
$numTokens
$pointer
The current array pointer.
private
int
$pointer
= 0
$tokens
The token list.
private
mixed
$tokens
Tags
Methods
__construct()
public
__construct(string $contents) : mixed
Parameters
- $contents : string
Return values
mixed —next()
Gets the next non whitespace and non comment token.
public
next([bool $docCommentIsComment = true ]) : array<string|int, mixed>|string|null
Parameters
- $docCommentIsComment : bool = true
-
If TRUE then a doc comment is considered a comment and skipped. If FALSE then only whitespace and normal comments are skipped.
Return values
array<string|int, mixed>|string|null —The token if exists, null otherwise.
parseClass()
Gets the class name.
public
parseClass() : string
Return values
string —The found class name.
parseNamespace()
Gets the namespace.
public
parseNamespace() : string
Return values
string —The found namespace.
parseUseStatement()
Parses a single use statement.
public
parseUseStatement() : array<string, string>
Return values
array<string, string> —A list with all found class names for a use statement.
parseUseStatements()
Gets all use statements.
public
parseUseStatements(string $namespaceName) : array<string, string>
Parameters
- $namespaceName : string
-
The namespace name of the reflected class.
Return values
array<string, string> —A list with all found use statements.