class KalimahApps / Daleel / Visitor

Visitor

Visitor class for PHPParser to extract data from PHP files.

Extends

    PhpParser\NodeVisitorAbstract

Properties

private

$classes array

Array of classes

Default: []
private

$traits array

Array of traits

Default: []
private

$interfaces array

Array of interfaces

Default: []
private

$uses array

Array of uses

Default: []
private

$functions

Default: []
private

$tree array

Hierarchy tree of namespaces, classes, methods .. etc

Default: []
private

$docblock_factory phpDocumentor\...\DocBlockFactory

Docblock factory dependency

Default: null
private

$namespace string

Current namespace

Default: ''
private

$is_namespaced

Default: false

Methods

public

__construct ( phpDocumentor\...\DocBlockFactory $docblock_factory ) : void

Constructor.

Parameters

  • $docblock_factory phpDocumentor\...\DocBlockFactory
    Docblock factory dependency
private

getClassNode ( PhpParser\...\Class_ $node ) : void

Get the list of classes.

Parameters

  • $node PhpParser\...\Class_
    Node to process
public

leaveNode ( PhpParser\Node $node ) : void

Handle node on enter.

Parameters

  • $node PhpParser\Node
    Node to process
public

beforeTraverse ( array $nodes ) : void

Clear data before traversing.

Parameters

  • $nodes array
    Nodes to process. Not used
public

afterTraverse ( array $nodes ) : void

Handle node on leave.

Parameters

  • $nodes array
    Nodes to process
private

getVisibility ( $node ) : string

Get visibility of a node.

Parameters

  • $node PhpParser\...\ClassConst|PhpParser\...\ClassMethod|PhpParser\...\Property
    Node to process
private

getDefaultValue ( $node ) : mixed

Process $node to get the default value.

Parameters

  • $node PhpParser\Node
    Node to process
private

processMembers ( $nodes , $type ) : array

Process object members (properties, constants).

Parameters

  • $nodes Property[]|ClassConst[]
    Array of nodes
  • $type string
    Type of node (property or constant)
private

processMethods ( array $nodes ) : array

Process object methods.

Parameters

  • $nodes ClassMethod[]
    Array of nodes
private

processDocBlock ( string $docblock ) : array

Process docblock.

Parameters

  • $docblock string
    string Docblock to process
public

getTree ( ) : void

Get the hierarchy tree.

public

getNamespaces ( ) : void

Get the list of namespaces.