PHP Class Kahlan\Jit\Parser

Datei anzeigen Open project: crysalead/kahlan Class Usage Examples

Protected Properties

Property Type Description
$_root object The root node.
$_states array [ 'php' => false, // Indicate if the parser is in a PHP block. 'class' => false, // Indicate if the parser is in a PHP class. 'lines' => false, // Indicate if the parser need to process line mathing. 'num' => 0, // Current line number. 'root' => object, // Root node. 'current' => object, // Current node. 'visibility' => [] // Store function visibility. 'uses' => [] // Maintain the uses dependencies 'body' => '' // Maintain the current parsed content ]
$_stream object The current streamer.

Public Methods

Method Description
__construct ( array $config = [] ) The constructor function
debug ( $content ) : string Returns a reader-friendly output for debug purpose.
parse ( $content, $config = [] ) : object Parsing a file into nested nodes.
unparse ( $node ) : string Unparsing a node.

Protected Methods

Method Description
_assignCoverable ( ) Assign coverable data to lines.
_assignLine ( $index, object $node, $line ) Assign a node to a specific line.
_assignLines ( object $node ) Assign the node to some lines and makes them availaible at the root node.
_classNode ( ) Build a class node.
_closeCurly ( ) Manage curly brackets.
_codeNode ( $type = null, $coverable = false ) Build a code node.
_codeType ( ) : string Get code type from context
_commentNode ( ) Build a comment node.
_contextualize ( $node, $coverable = false ) Contextualize a node.
_declareNode ( ) Build a namespace node.
_flushUses ( ) Attache the founded uses to the current namespace.
_functionNode ( ) Build a function node.
_initLines ( string $content ) Adds lines stores for root node.
_interfaceNode ( ) Build an interface node.
_isCoverable ( integer $index ) : boolean Checks if a specific line is coverable.
_namespaceNode ( ) Build a namespace node.
_normalizeClass ( string $name ) : string Normalizes a class name.
_normalizeImplements ( string $implements ) : array Formats an implements string.
_parseArgs ( ) : array Extracting a function/method args array from a stream.
_parser ( string $content, boolean $lines = false ) : object Parsing a file into nested nodes.
_stringNode ( $delimiter = '' ) Build a string node.
_traitNode ( ) Build a trait node.
_useNode ( ) Manage use statement.

Method Details

__construct() public method

The constructor function
public __construct ( array $config = [] )
$config array The configuration array.

_assignCoverable() protected method

Assign coverable data to lines.
protected _assignCoverable ( )

_assignLine() protected method

Assign a node to a specific line.
protected _assignLine ( $index, object $node, $line )
$node object The node to match.

_assignLines() protected method

Assign the node to some lines and makes them availaible at the root node.
protected _assignLines ( object $node )
$node object The node to match.

_classNode() protected method

Build a class node.
protected _classNode ( )

_closeCurly() protected method

Manage curly brackets.
protected _closeCurly ( )

_codeNode() protected method

Build a code node.
protected _codeNode ( $type = null, $coverable = false )

_codeType() protected method

Get code type from context
protected _codeType ( ) : string
return string

_commentNode() protected method

Build a comment node.
protected _commentNode ( )

_contextualize() protected method

Contextualize a node.
protected _contextualize ( $node, $coverable = false )

_declareNode() protected method

Build a namespace node.
protected _declareNode ( )

_flushUses() protected method

Attache the founded uses to the current namespace.
protected _flushUses ( )

_functionNode() protected method

Build a function node.
protected _functionNode ( )

_initLines() protected method

Adds lines stores for root node.
protected _initLines ( string $content )
$content string A php file content.

_interfaceNode() protected method

Build an interface node.
protected _interfaceNode ( )

_isCoverable() protected method

Checks if a specific line is coverable.
protected _isCoverable ( integer $index ) : boolean
$index integer The line to check.
return boolean

_namespaceNode() protected method

Build a namespace node.
protected _namespaceNode ( )

_normalizeClass() protected method

Normalizes a class name.
protected _normalizeClass ( string $name ) : string
$name string A class name value.
return string The fully namespaced class extends value.

_normalizeImplements() protected method

Formats an implements string.
protected _normalizeImplements ( string $implements ) : array
$implements string The implements string.
return array The implements array.

_parseArgs() protected method

Extracting a function/method args array from a stream.
protected _parseArgs ( ) : array
return array The function/method args array.

_parser() protected method

Parsing a file into nested nodes.
protected _parser ( string $content, boolean $lines = false ) : object
$content string A file.
$lines boolean Indicate if the parser need to process line mathing.
return object The parsed file node.

_stringNode() protected method

Build a string node.
protected _stringNode ( $delimiter = '' )

_traitNode() protected method

Build a trait node.
protected _traitNode ( )

_useNode() protected method

Manage use statement.
protected _useNode ( )

debug() public static method

Returns a reader-friendly output for debug purpose.
public static debug ( $content ) : string
return string the unparsed file.

parse() public static method

Parsing a file into nested nodes.
public static parse ( $content, $config = [] ) : object
return object the parsed file node.

unparse() public static method

Unparsing a node.
public static unparse ( $node ) : string
return string the unparsed file.

Property Details

$_root protected_oe property

The root node.
protected object $_root
return object

$_states protected_oe property

[ 'php' => false, // Indicate if the parser is in a PHP block. 'class' => false, // Indicate if the parser is in a PHP class. 'lines' => false, // Indicate if the parser need to process line mathing. 'num' => 0, // Current line number. 'root' => object, // Root node. 'current' => object, // Current node. 'visibility' => [] // Store function visibility. 'uses' => [] // Maintain the uses dependencies 'body' => '' // Maintain the current parsed content ]
protected array $_states
return array

$_stream protected_oe property

The current streamer.
protected object $_stream
return object