Parser
in package
Class responsible for parsing the given file or files to the intermediate structure file.
This class can be used to parse one or more files to the intermediate file format for further processing.
Table of Contents
- $defaultPackageName : string
- $encoding : string
- $logger : LoggerInterface
- $markers : array<string|int, string>
- $path : string
- $projectFactory : ProjectFactory
- $stopwatch : Stopwatch
- $validate : bool
- __construct() : mixed
- Initializes the parser.
- doValidation() : bool
- Returns whether we want to run PHPLint on every file.
- getDefaultPackageName() : string
- Returns the name of the default package.
- getEncoding() : string
- Returns the currently active encoding.
- getMarkers() : array<string|int, string>
- Returns the list of markers.
- getPath() : string
- Returns the absolute base path for all files.
- parse() : Project
- Iterates through the given files feeds them to the builder.
- setDefaultPackageName() : void
- Sets the name of the default package.
- setEncoding() : void
- Sets the encoding of the files.
- setMarkers() : void
- Sets a list of markers to gather (i.e. TODO, FIXME).
- setPath() : void
- Sets the base path of the files that will be parsed.
- setValidate() : void
- Sets whether to run PHPLint on every file.
- log() : void
- Dispatches a logging request.
- logAfterParsingAllFiles() : void
- Writes the complete parsing cycle to log.
- startTimingTheParsePhase() : void
Properties
$defaultPackageName
private
string
$defaultPackageName
= 'Default'
the name of the default package
$encoding
private
string
$encoding
= 'utf-8'
The encoding in which the files are encoded
$logger
private
LoggerInterface
$logger
$markers
private
array<string|int, string>
$markers
= ['TODO', 'FIXME']
which markers (i.e. TODO or FIXME) to collect
$path
private
string
$path
= ''
target location's root path
$projectFactory
private
ProjectFactory
$projectFactory
$stopwatch
private
Stopwatch
$stopwatch
The profiling component that measures time and memory usage over time
$validate
private
bool
$validate
= false
whether to execute a PHPLint on every file
Methods
__construct()
Initializes the parser.
public
__construct(ProjectFactory $projectFactory, Stopwatch $stopwatch, LoggerInterface $logger) : mixed
This constructor checks the user's PHP ini settings to detect which encoding is used by default. This encoding is used as a default value for phpDocumentor to convert the source files that it receives.
If no encoding is specified than 'utf-8' is assumed by default.
Parameters
- $projectFactory : ProjectFactory
- $stopwatch : Stopwatch
- $logger : LoggerInterface
Tags
Return values
mixed —doValidation()
Returns whether we want to run PHPLint on every file.
public
doValidation() : bool
Return values
bool —getDefaultPackageName()
Returns the name of the default package.
public
getDefaultPackageName() : string
Return values
string —getEncoding()
Returns the currently active encoding.
public
getEncoding() : string
Return values
string —getMarkers()
Returns the list of markers.
public
getMarkers() : array<string|int, string>
Return values
array<string|int, string> —getPath()
Returns the absolute base path for all files.
public
getPath() : string
Return values
string —parse()
Iterates through the given files feeds them to the builder.
public
parse(array<string|int, File> $files) : Project
Parameters
- $files : array<string|int, File>
Return values
Project —setDefaultPackageName()
Sets the name of the default package.
public
setDefaultPackageName(string $defaultPackageName) : void
Parameters
- $defaultPackageName : string
-
Name used to categorize elements without an @package tag.
Return values
void —setEncoding()
Sets the encoding of the files.
public
setEncoding(string $encoding) : void
With this option it is possible to tell the parser to use a specific encoding to interpret the provided files.
By default this is set to UTF-8, in which case no action is taken. Any other encoding will result in the output
being converted to UTF-8 using iconv
.
Please note that it is recommended to provide files in UTF-8 format; this will ensure a faster performance since no transformation is required.
Parameters
- $encoding : string
Return values
void —setMarkers()
Sets a list of markers to gather (i.e. TODO, FIXME).
public
setMarkers(array<string|int, string> $markers) : void
Parameters
- $markers : array<string|int, string>
-
A list or markers to gather.
Return values
void —setPath()
Sets the base path of the files that will be parsed.
public
setPath(string $path) : void
Parameters
- $path : string
-
Must be an absolute path.
Return values
void —setValidate()
Sets whether to run PHPLint on every file.
public
setValidate(bool $validate) : void
PHPLint has a huge performance impact on the execution of phpDocumentor and is thus disabled by default.
Parameters
- $validate : bool
-
when true this file will be checked.
Return values
void —log()
Dispatches a logging request.
private
log(string $message[, string $priority = LogLevel::INFO ][, array<string|int, string> $parameters = [] ]) : void
Parameters
- $message : string
-
The message to log.
- $priority : string = LogLevel::INFO
-
The logging priority as declared in the LogLevel PSR-3 class.
- $parameters : array<string|int, string> = []
Return values
void —logAfterParsingAllFiles()
Writes the complete parsing cycle to log.
private
logAfterParsingAllFiles() : void
Return values
void —startTimingTheParsePhase()
private
startTimingTheParsePhase() : void