ParserFile
ParserFile
Parses a PHP source file and indexes its top-level declarations.
class ParserFile extends \Hazaar\Parser\PHP\TokenParserThe parser stores file metadata and discovered symbols such as constants, functions, interfaces, classes, and traits.
Properties
source
Absolute path to the parsed source file.
private string $sourcesize
File size in bytes.
private int $sizeconstants
Top-level constants discovered in the file.
private array $constantsfunctions
Top-level functions discovered in the file.
private array $functionsinterfaces
Interface declarations discovered in the file.
private array $interfacesclasses
Class declarations discovered in the file.
private array $classestraits
Trait declarations discovered in the file.
private array $traitsenums
Enum declarations discovered in the file.
private array $enumsMethods
__construct
Creates a parser instance and immediately parses the given file.
public __construct(string $filename): voidParameters
| Parameter | Type | Description |
|---|---|---|
$filename | string | path to a readable PHP source file |
getSource
Returns the source file path.
public getSource(): stringgetSize
Returns the size of the file in bytes.
public getSize(): intgetConstants
Returns an array of constants defined in the file.
public getConstants(): voidgetFunctions
Returns an array of functions defined in the file.
public getFunctions(): voidgetInterfaces
Returns an array of interfaces defined in the file.
public getInterfaces(): voidgetClasses
Returns an array of classes defined in the file.
public getClasses(): voidgetTraits
Returns an array of traits defined in the file.
public getTraits(): voidgetEnums
Returns an array of enums defined in the file.
public getEnums(): voidgetDocBlock
Returns the file-level docblock marked with @file, when present.
public getDocBlock(): ?DocBlockfixTokenArray
Converts raw token output into parser token objects.
private fixTokenArray(array $tokens): voidWhitespace tokens are intentionally excluded to simplify higher-level declaration parsing.
Parameters
| Parameter | Type | Description |
|---|---|---|
$tokens | array | raw tokens from token_get_all() |
Generated by Hazaar API Doc Generator on Tue, 21 Apr 2026 04:00:25 +0000