Parser

Implements \Psr\Log\LoggerAwareInterface

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);
package

Default

Methods

Initializes the parser.

__construct() 

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.

codeCoverageIgnore

the ini_get call cannot be tested as setting it using ini_set has no effect.

Returns whether we want to run PHPLint on every file.

doValidation() : boolean
api

Response

boolean

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

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

Returns the name of the default package.

getDefaultPackageName() : string

Response

string

Returns the currently active encoding.

getEncoding() : string

Response

string

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

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

if no files were found.

Arguments

$files

\phpDocumentor\Fileset\Collection

Response

array<mixed,string>

Returns the list of ignored tags.

getIgnoredTags() : array<mixed,string>
api

Response

array<mixed,string>

Returns the list of markers.

getMarkers() : array<mixed,string>
api

Response

array<mixed,string>

Returns the absolute base path for all files.

getPath() : string

Response

string

Returns whether a full rebuild is required.

isForced() : boolean
api

Response

boolean

Dispatches a logging request.

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

Arguments

$message

string

The message to log.

$priority

string

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

$parameters

array<mixed,string>

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

logAfterParsingAFile(integer $memory) : integer

Arguments

$memory

integer

Response

integer

Writes the complete parsing cycle to log.

logAfterParsingAllFiles() : void

Iterates through the given files feeds them to the builder.

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

if no files were found.

Arguments

$files

\phpDocumentor\Fileset\Collection

A files container to parse.

Response

boolean|string

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

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

Arguments

$filename

string

Sets the name of the default package.

setDefaultPackageName(string $defaultPackageName) : void

Arguments

$defaultPackageName

string

Name used to categorize elements without an @package tag.

Sets the encoding of the files.

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.

Arguments

$encoding

string

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

setForced(boolean $forced) : void
api

Arguments

$forced

boolean

Forces a full parse.

Sets a list of tags to ignore.

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

Arguments

$ignoredTags

array<mixed,string>

A list of tags to ignore.

Sets a logger instance on the object

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

Arguments

$logger

\Psr\Log\LoggerInterface

Response

null

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

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

Arguments

$markers

array<mixed,string>

A list or markers to gather.

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

setPath(string $path) : void
api

Arguments

$path

string

Must be an absolute path.

Registers the component that profiles the execution of the parser.

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

Arguments

$stopwatch

\Symfony\Component\Stopwatch\Stopwatch

Sets whether to run PHPLint on every file.

setValidate(boolean $validate) : void
api

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

Arguments

$validate

boolean

when true this file will be checked.

startTimingTheParsePhase

startTimingTheParsePhase() 

Properties

the name of the default package

defaultPackageName : string
var

the name of the default package

Type(s)

string

whether we force a full re-parse

force : boolean
var

whether we force a full re-parse

Type(s)

boolean

whether to execute a PHPLint on every file

validate : boolean
var

whether to execute a PHPLint on every file

Type(s)

boolean

which markers (i.e. TODO or FIXME) to collect

markers : array<mixed,string>
var

which markers (i.e. TODO or FIXME) to collect

Type(s)

array<mixed,string>

which tags to ignore

ignoredTags : array<mixed,string>
var

which tags to ignore

Type(s)

array<mixed,string>

target location's root path

path : string
var

target location's root path

Type(s)

string

logger

logger : \Psr\Log\LoggerInterface
var

Type(s)

\Psr\Log\LoggerInterface

The encoding in which the files are encoded

encoding : string
var

The encoding in which the files are encoded

Type(s)

string

The profiling component that measures time and memory usage over time

stopwatch : \Symfony\Component\Stopwatch\Stopwatch
var

The profiling component that measures time and memory usage over time

Type(s)

\Symfony\Component\Stopwatch\Stopwatch