\SuperClosure\AnalyzerAstAnalyzer

This is the AST based analyzer.

We're using reflection and AST-based code parser to analyze a closure and determine its code and context using the nikic/php-parser library. The AST based analyzer and has more capabilities than the token analyzer, but is, unfortunately, about 25 times slower.

Summary

Methods
Properties
Constants
analyze()
No public properties found
No constants found
determineCode()
determineContext()
No protected properties found
N/A
determineBinding()
isClosureStatic()
locateClosure()
getFileAst()
getParser()
No private properties found
N/A

Methods

analyze()

analyze(\Closure  $closure) : array

Analyzer a given closure.

Parameters

\Closure $closure

Throws

\SuperClosure\Exception\ClosureAnalysisException

Returns

array

determineCode()

determineCode(array  $data) 

Parameters

array $data

determineContext()

determineContext(array  $data) 

Returns the variables that in the "use" clause of the closure definition.

These are referred to as the "used variables", "static variables", or "closed upon variables", "context" of the closure.

Parameters

array $data

determineBinding()

determineBinding(array  $data) 

Parameters

array $data

isClosureStatic()

isClosureStatic(\Closure  $closure) 

Parameters

\Closure $closure

locateClosure()

locateClosure(array  $data) 

Parses the closure's code and produces an abstract syntax tree (AST).

Parameters

array $data

Throws

\SuperClosure\Exception\ClosureAnalysisException

if there is an issue finding the closure

getFileAst()

getFileAst(\ReflectionFunction  $reflection) : array<mixed,\PhpParser\Node>

Parameters

\ReflectionFunction $reflection

Throws

\SuperClosure\Exception\ClosureAnalysisException

Returns

array<mixed,\PhpParser\Node>