\phpDocumentor\ParserParser

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.

Example of use:

$files = new \phpDocumentor\File\Collection();
$ files->addDirectories(getcwd());
$parser = new \phpDocumentor\Parser\Parser();
$parser->setPath($files->getProjectRoot());
echo $parser->parseFiles($files);

Summary

Methods
Properties
Constants
__construct()
setStopwatch()
setForced()
isForced()
setValidate()
doValidation()
setMarkers()
getMarkers()
setIgnoredTags()
getIgnoredTags()
setPath()
getPath()
setDefaultPackageName()
getDefaultPackageName()
setEncoding()
getEncoding()
setLogger()
parse()
No public properties found
No constants found
getFilenames()
parseFileIntoDescriptor()
forceRebuildIfSettingsHaveModified()
logAfterParsingAFile()
logAfterParsingAllFiles()
log()
startTimingTheParsePhase()
$defaultPackageName
$force
$validate
$markers
$ignoredTags
$path
$logger
$encoding
$stopwatch
N/A
No private methods found
No private properties found
N/A

Properties

$defaultPackageName

$defaultPackageName : string

Type

string — the name of the default package

$force

$force : boolean

Type

boolean — whether we force a full re-parse

$validate

$validate : boolean

Type

boolean — whether to execute a PHPLint on every file

$markers

$markers : array<mixed,string>

Type

array<mixed,string> — which markers (i.e. TODO or FIXME) to collect

$ignoredTags

$ignoredTags : array<mixed,string>

Type

array<mixed,string> — which tags to ignore

$path

$path : string

Type

string — target location's root path

$logger

$logger : \Psr\Log\LoggerInterface

Type

\Psr\Log\LoggerInterface

$encoding

$encoding : string

Type

string — The encoding in which the files are encoded

$stopwatch

$stopwatch : \Symfony\Component\Stopwatch\Stopwatch

Type

\Symfony\Component\Stopwatch\Stopwatch — The profiling component that measures time and memory usage over time

Methods

__construct()

__construct() 

Initializes the parser.

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.

setStopwatch()

setStopwatch(\Symfony\Component\Stopwatch\Stopwatch  $stopwatch) : void

Registers the component that profiles the execution of the parser.

Parameters

\Symfony\Component\Stopwatch\Stopwatch $stopwatch

setForced()

setForced(boolean  $forced) : void

Sets whether to force a full parse run of all files.

Parameters

boolean $forced

Forces a full parse.

isForced()

isForced() : boolean

Returns whether a full rebuild is required.

Returns

boolean

setValidate()

setValidate(boolean  $validate) : void

Sets whether to run PHPLint on every file.

PHPLint has a huge performance impact on the execution of phpDocumentor and is thus disabled by default.

Parameters

boolean $validate

when true this file will be checked.

doValidation()

doValidation() : boolean

Returns whether we want to run PHPLint on every file.

Returns

boolean

setMarkers()

setMarkers(array<mixed,string>  $markers) : void

Sets a list of markers to gather (i.e. TODO, FIXME).

Parameters

array<mixed,string> $markers

A list or markers to gather.

getMarkers()

getMarkers() : array<mixed,string>

Returns the list of markers.

Returns

array<mixed,string>

setIgnoredTags()

setIgnoredTags(array<mixed,string>  $ignoredTags) : void

Sets a list of tags to ignore.

Parameters

array<mixed,string> $ignoredTags

A list of tags to ignore.

getIgnoredTags()

getIgnoredTags() : array<mixed,string>

Returns the list of ignored tags.

Returns

array<mixed,string>

setPath()

setPath(string  $path) : void

Sets the base path of the files that will be parsed.

Parameters

string $path

Must be an absolute path.

getPath()

getPath() : string

Returns the absolute base path for all files.

Returns

string

setDefaultPackageName()

setDefaultPackageName(string  $defaultPackageName) : void

Sets the name of the default package.

Parameters

string $defaultPackageName

Name used to categorize elements without an @package tag.

getDefaultPackageName()

getDefaultPackageName() : string

Returns the name of the default package.

Returns

string

setEncoding()

setEncoding(string  $encoding) : void

Sets the encoding of the files.

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

string $encoding

getEncoding()

getEncoding() : string

Returns the currently active encoding.

Returns

string

setLogger()

setLogger(\Psr\Log\LoggerInterface  $logger) : null

Sets a logger instance on the object

Parameters

\Psr\Log\LoggerInterface $logger

Returns

null

parse()

parse(\phpDocumentor\Descriptor\ProjectDescriptorBuilder  $builder, \phpDocumentor\Fileset\Collection  $files) : boolean|string

Iterates through the given files feeds them to the builder.

Parameters

\phpDocumentor\Descriptor\ProjectDescriptorBuilder $builder
\phpDocumentor\Fileset\Collection $files

A files container to parse.

Throws

\phpDocumentor\Parser\Exception

if no files were found.

Returns

boolean|string

getFilenames()

getFilenames(\phpDocumentor\Fileset\Collection  $files) : array<mixed,string>

Extract all filenames from the given collection and output the amount of files.

Parameters

\phpDocumentor\Fileset\Collection $files

Throws

\phpDocumentor\Parser\Exception\FilesNotFoundException

if no files were found.

Returns

array<mixed,string>

parseFileIntoDescriptor()

parseFileIntoDescriptor(\phpDocumentor\Descriptor\ProjectDescriptorBuilder  $builder, string  $filename) : void

Parses a file and creates a Descriptor for it in the project.

Parameters

\phpDocumentor\Descriptor\ProjectDescriptorBuilder $builder
string $filename

forceRebuildIfSettingsHaveModified()

forceRebuildIfSettingsHaveModified(\phpDocumentor\Descriptor\ProjectDescriptorBuilder  $builder) : void

Checks if the settings of the project have changed and forces a complete rebuild if they have.

Parameters

\phpDocumentor\Descriptor\ProjectDescriptorBuilder $builder

logAfterParsingAFile()

logAfterParsingAFile(integer  $memory) : integer

Collects the time and duration of processing a file, logs it and returns the new amount of memory in use.

Parameters

integer $memory

Returns

integer

logAfterParsingAllFiles()

logAfterParsingAllFiles() : void

Writes the complete parsing cycle to log.

log()

log(string  $message, string  $priority = \Psr\Log\LogLevel::INFO, array<mixed,string>  $parameters = array()) : void

Dispatches a logging request.

Parameters

string $message

The message to log.

string $priority

The logging priority as declared in the LogLevel PSR-3 class.

array<mixed,string> $parameters

startTimingTheParsePhase()

startTimingTheParsePhase()