PHP Class PHPCfg\Parser

Mostra file Open project: ircmaxell/php-cfg Class Usage Examples

Protected Properties

Property Type Description
$anonId
$astParser
$astTraverser
$block Block
$ctx FuncContext
$currentClass PHPCfg\Operand\Literal | null
$currentNamespace
$fileName
$script Script

Public Methods

Method Description
__construct ( PhpParser\Parser $astParser, NodeTraverser $astTraverser = null )
parse ( string $code, string $fileName )
parseAst ( array $ast, string $fileName ) : Script
parseNodes ( array $nodes, Block $block )

Protected Methods

Method Description
parseArg ( PhpParser\Node\Arg $expr )
parseExprList ( array $expr, integer $readWrite = self::MODE_NONE ) : Operand[]
parseExprNode ( $expr )
parseExpr_Array ( PhpParser\Node\Expr\Array_ $expr )
parseExpr_ArrayDimFetch ( PhpParser\Node\Expr\ArrayDimFetch $expr )
parseExpr_Assign ( PhpParser\Node\Expr\Assign $expr )
parseExpr_AssignRef ( PhpParser\Node\Expr\AssignRef $expr )
parseExpr_BitwiseNot ( PhpParser\Node\Expr\BitwiseNot $expr )
parseExpr_BooleanNot ( PhpParser\Node\Expr\BooleanNot $expr )
parseExpr_ClassConstFetch ( PhpParser\Node\Expr\ClassConstFetch $expr )
parseExpr_Clone ( PhpParser\Node\Expr\Clone_ $expr )
parseExpr_Closure ( Closure $expr )
parseExpr_ConstFetch ( PhpParser\Node\Expr\ConstFetch $expr )
parseExpr_Empty ( PhpParser\Node\Expr\Empty_ $expr )
parseExpr_ErrorSuppress ( PhpParser\Node\Expr\ErrorSuppress $expr )
parseExpr_Eval ( PhpParser\Node\Expr\Eval_ $expr )
parseExpr_Exit ( PhpParser\Node\Expr\Exit_ $expr )
parseExpr_FuncCall ( PhpParser\Node\Expr\FuncCall $expr )
parseExpr_Include ( PhpParser\Node\Expr\Include_ $expr )
parseExpr_Instanceof ( PhpParser\Node\Expr\InstanceOf_ $expr )
parseExpr_Isset ( PhpParser\Node\Expr\Isset_ $expr )
parseExpr_MethodCall ( PhpParser\Node\Expr\MethodCall $expr )
parseExpr_New ( PhpParser\Node\Expr\New_ $expr )
parseExpr_PostDec ( PhpParser\Node\Expr\PostDec $expr )
parseExpr_PostInc ( PhpParser\Node\Expr\PostInc $expr )
parseExpr_PreDec ( PhpParser\Node\Expr\PreDec $expr )
parseExpr_PreInc ( PhpParser\Node\Expr\PreInc $expr )
parseExpr_Print ( PhpParser\Node\Expr\Print_ $expr )
parseExpr_PropertyFetch ( PhpParser\Node\Expr\PropertyFetch $expr )
parseExpr_ShellExec ( PhpParser\Node\Expr\ShellExec $expr )
parseExpr_StaticCall ( PhpParser\Node\Expr\StaticCall $expr )
parseExpr_StaticPropertyFetch ( PhpParser\Node\Expr\StaticPropertyFetch $expr )
parseExpr_Ternary ( PhpParser\Node\Expr\Ternary $expr )
parseExpr_UnaryMinus ( PhpParser\Node\Expr\UnaryMinus $expr )
parseExpr_UnaryPlus ( PhpParser\Node\Expr\UnaryPlus $expr )
parseExpr_Yield ( PhpParser\Node\Expr\Yield_ $expr )
parseFunc ( Func $func, array $params, array $stmts, $implicitReturnValue )
parseIf ( PhpParser\Node\Stmt\If_ | PhpParser\Node\Stmt\ElseIf_ $node, Block $endBlock )
parseListAssignment ( List_ $expr, Operand $rhs )
parseNode ( PhpParser\Node $node )
parseStmt_Class ( Class_ $node )
parseStmt_ClassConst ( ClassConst $node )
parseStmt_ClassMethod ( ClassMethod $node )
parseStmt_Const ( PhpParser\Node\Stmt\Const_ $node )
parseStmt_Declare ( Declare_ $node )
parseStmt_Do ( PhpParser\Node\Stmt\Do_ $node )
parseStmt_Echo ( PhpParser\Node\Stmt\Echo_ $node )
parseStmt_For ( PhpParser\Node\Stmt\For_ $node )
parseStmt_Foreach ( PhpParser\Node\Stmt\Foreach_ $node )
parseStmt_Function ( Function_ $node )
parseStmt_Global ( PhpParser\Node\Stmt\Global_ $node )
parseStmt_Goto ( PhpParser\Node\Stmt\Goto_ $node )
parseStmt_HaltCompiler ( PhpParser\Node\Stmt\HaltCompiler $node )
parseStmt_If ( PhpParser\Node\Stmt\If_ $node )
parseStmt_InlineHTML ( PhpParser\Node\Stmt\InlineHTML $node )
parseStmt_Interface ( Interface_ $node )
parseStmt_Label ( PhpParser\Node\Stmt\Label $node )
parseStmt_Namespace ( Namespace_ $node )
parseStmt_Nop ( PhpParser\Node\Stmt\Nop $node )
parseStmt_Property ( Property $node )
parseStmt_Return ( PhpParser\Node\Stmt\Return_ $node )
parseStmt_Static ( PhpParser\Node\Stmt\Static_ $node )
parseStmt_Switch ( PhpParser\Node\Stmt\Switch_ $node )
parseStmt_Throw ( PhpParser\Node\Stmt\Throw_ $node )
parseStmt_Trait ( Trait_ $node )
parseStmt_TraitUse ( PhpParser\Node\Stmt\TraitUse $node )
parseStmt_TryCatch ( TryCatch $node )
parseStmt_Unset ( PhpParser\Node\Stmt\Unset_ $node )
parseStmt_Use ( PhpParser\Node\Stmt\Use_ $node )
parseStmt_While ( PhpParser\Node\Stmt\While_ $node )
processAssertions ( Operand $op, Block $if, Block $else )
readAssertion ( Assertion $assert )
throwUndefinedLabelError ( )

Private Methods

Method Description
compileJumptableSwitch ( PhpParser\Node\Stmt\Switch_ $node )
getVariableName ( Variable $var )
mapAttributes ( PhpParser\Node $expr )
parseParameterList ( Func $func, array $params )
parseScalarNode ( PhpParser\Node\Scalar $scalar )
parseShortCircuiting ( PhpParser\Node\Expr\BinaryOp $expr, $isOr )
readVariable ( Operand $var )
readVariableName ( $name, Block $block )
readVariableRecursive ( $name, Block $block )
switchCanUseJumptable ( PhpParser\Node\Stmt\Switch_ $node )
writeVariable ( Operand $var )
writeVariableName ( $name, Operand $value, Block $block )

Method Details

__construct() public method

public __construct ( PhpParser\Parser $astParser, NodeTraverser $astTraverser = null )
$astParser PhpParser\Parser
$astTraverser PhpParser\NodeTraverser

parse() public method

public parse ( string $code, string $fileName )
$code string
$fileName string

parseArg() protected method

protected parseArg ( PhpParser\Node\Arg $expr )
$expr PhpParser\Node\Arg

parseAst() public method

public parseAst ( array $ast, string $fileName ) : Script
$ast array PHP-Parser AST
$fileName string
return Script

parseExprList() protected method

protected parseExprList ( array $expr, integer $readWrite = self::MODE_NONE ) : Operand[]
$expr array
$readWrite integer
return Operand[]

parseExprNode() protected method

protected parseExprNode ( $expr )

parseExpr_Array() protected method

protected parseExpr_Array ( PhpParser\Node\Expr\Array_ $expr )
$expr PhpParser\Node\Expr\Array_

parseExpr_ArrayDimFetch() protected method

protected parseExpr_ArrayDimFetch ( PhpParser\Node\Expr\ArrayDimFetch $expr )
$expr PhpParser\Node\Expr\ArrayDimFetch

parseExpr_Assign() protected method

protected parseExpr_Assign ( PhpParser\Node\Expr\Assign $expr )
$expr PhpParser\Node\Expr\Assign

parseExpr_AssignRef() protected method

protected parseExpr_AssignRef ( PhpParser\Node\Expr\AssignRef $expr )
$expr PhpParser\Node\Expr\AssignRef

parseExpr_BitwiseNot() protected method

protected parseExpr_BitwiseNot ( PhpParser\Node\Expr\BitwiseNot $expr )
$expr PhpParser\Node\Expr\BitwiseNot

parseExpr_BooleanNot() protected method

protected parseExpr_BooleanNot ( PhpParser\Node\Expr\BooleanNot $expr )
$expr PhpParser\Node\Expr\BooleanNot

parseExpr_ClassConstFetch() protected method

protected parseExpr_ClassConstFetch ( PhpParser\Node\Expr\ClassConstFetch $expr )
$expr PhpParser\Node\Expr\ClassConstFetch

parseExpr_Clone() protected method

protected parseExpr_Clone ( PhpParser\Node\Expr\Clone_ $expr )
$expr PhpParser\Node\Expr\Clone_

parseExpr_Closure() protected method

protected parseExpr_Closure ( Closure $expr )
$expr PhpParser\Node\Expr\Closure

parseExpr_ConstFetch() protected method

protected parseExpr_ConstFetch ( PhpParser\Node\Expr\ConstFetch $expr )
$expr PhpParser\Node\Expr\ConstFetch

parseExpr_Empty() protected method

protected parseExpr_Empty ( PhpParser\Node\Expr\Empty_ $expr )
$expr PhpParser\Node\Expr\Empty_

parseExpr_ErrorSuppress() protected method

protected parseExpr_ErrorSuppress ( PhpParser\Node\Expr\ErrorSuppress $expr )
$expr PhpParser\Node\Expr\ErrorSuppress

parseExpr_Eval() protected method

protected parseExpr_Eval ( PhpParser\Node\Expr\Eval_ $expr )
$expr PhpParser\Node\Expr\Eval_

parseExpr_Exit() protected method

protected parseExpr_Exit ( PhpParser\Node\Expr\Exit_ $expr )
$expr PhpParser\Node\Expr\Exit_

parseExpr_FuncCall() protected method

protected parseExpr_FuncCall ( PhpParser\Node\Expr\FuncCall $expr )
$expr PhpParser\Node\Expr\FuncCall

parseExpr_Include() protected method

protected parseExpr_Include ( PhpParser\Node\Expr\Include_ $expr )
$expr PhpParser\Node\Expr\Include_

parseExpr_Instanceof() protected method

protected parseExpr_Instanceof ( PhpParser\Node\Expr\InstanceOf_ $expr )
$expr PhpParser\Node\Expr\InstanceOf_

parseExpr_Isset() protected method

protected parseExpr_Isset ( PhpParser\Node\Expr\Isset_ $expr )
$expr PhpParser\Node\Expr\Isset_

parseExpr_MethodCall() protected method

protected parseExpr_MethodCall ( PhpParser\Node\Expr\MethodCall $expr )
$expr PhpParser\Node\Expr\MethodCall

parseExpr_New() protected method

protected parseExpr_New ( PhpParser\Node\Expr\New_ $expr )
$expr PhpParser\Node\Expr\New_

parseExpr_PostDec() protected method

protected parseExpr_PostDec ( PhpParser\Node\Expr\PostDec $expr )
$expr PhpParser\Node\Expr\PostDec

parseExpr_PostInc() protected method

protected parseExpr_PostInc ( PhpParser\Node\Expr\PostInc $expr )
$expr PhpParser\Node\Expr\PostInc

parseExpr_PreDec() protected method

protected parseExpr_PreDec ( PhpParser\Node\Expr\PreDec $expr )
$expr PhpParser\Node\Expr\PreDec

parseExpr_PreInc() protected method

protected parseExpr_PreInc ( PhpParser\Node\Expr\PreInc $expr )
$expr PhpParser\Node\Expr\PreInc

parseExpr_Print() protected method

protected parseExpr_Print ( PhpParser\Node\Expr\Print_ $expr )
$expr PhpParser\Node\Expr\Print_

parseExpr_PropertyFetch() protected method

protected parseExpr_PropertyFetch ( PhpParser\Node\Expr\PropertyFetch $expr )
$expr PhpParser\Node\Expr\PropertyFetch

parseExpr_ShellExec() protected method

protected parseExpr_ShellExec ( PhpParser\Node\Expr\ShellExec $expr )
$expr PhpParser\Node\Expr\ShellExec

parseExpr_StaticCall() protected method

protected parseExpr_StaticCall ( PhpParser\Node\Expr\StaticCall $expr )
$expr PhpParser\Node\Expr\StaticCall

parseExpr_StaticPropertyFetch() protected method

protected parseExpr_StaticPropertyFetch ( PhpParser\Node\Expr\StaticPropertyFetch $expr )
$expr PhpParser\Node\Expr\StaticPropertyFetch

parseExpr_Ternary() protected method

protected parseExpr_Ternary ( PhpParser\Node\Expr\Ternary $expr )
$expr PhpParser\Node\Expr\Ternary

parseExpr_UnaryMinus() protected method

protected parseExpr_UnaryMinus ( PhpParser\Node\Expr\UnaryMinus $expr )
$expr PhpParser\Node\Expr\UnaryMinus

parseExpr_UnaryPlus() protected method

protected parseExpr_UnaryPlus ( PhpParser\Node\Expr\UnaryPlus $expr )
$expr PhpParser\Node\Expr\UnaryPlus

parseExpr_Yield() protected method

protected parseExpr_Yield ( PhpParser\Node\Expr\Yield_ $expr )
$expr PhpParser\Node\Expr\Yield_

parseFunc() protected method

protected parseFunc ( Func $func, array $params, array $stmts, $implicitReturnValue )
$func Func
$params array
$stmts array

parseIf() protected method

protected parseIf ( PhpParser\Node\Stmt\If_ | PhpParser\Node\Stmt\ElseIf_ $node, Block $endBlock )
$node PhpParser\Node\Stmt\If_ | PhpParser\Node\Stmt\ElseIf_
$endBlock Block

parseListAssignment() protected method

protected parseListAssignment ( List_ $expr, Operand $rhs )
$expr PhpParser\Node\Expr\List_
$rhs Operand

parseNode() protected method

protected parseNode ( PhpParser\Node $node )
$node PhpParser\Node

parseNodes() public method

public parseNodes ( array $nodes, Block $block )
$nodes array
$block Block

parseStmt_Class() protected method

protected parseStmt_Class ( Class_ $node )
$node PhpParser\Node\Stmt\Class_

parseStmt_ClassConst() protected method

protected parseStmt_ClassConst ( ClassConst $node )
$node PhpParser\Node\Stmt\ClassConst

parseStmt_ClassMethod() protected method

protected parseStmt_ClassMethod ( ClassMethod $node )
$node PhpParser\Node\Stmt\ClassMethod

parseStmt_Const() protected method

protected parseStmt_Const ( PhpParser\Node\Stmt\Const_ $node )
$node PhpParser\Node\Stmt\Const_

parseStmt_Declare() protected method

protected parseStmt_Declare ( Declare_ $node )
$node PhpParser\Node\Stmt\Declare_

parseStmt_Do() protected method

protected parseStmt_Do ( PhpParser\Node\Stmt\Do_ $node )
$node PhpParser\Node\Stmt\Do_

parseStmt_Echo() protected method

protected parseStmt_Echo ( PhpParser\Node\Stmt\Echo_ $node )
$node PhpParser\Node\Stmt\Echo_

parseStmt_For() protected method

protected parseStmt_For ( PhpParser\Node\Stmt\For_ $node )
$node PhpParser\Node\Stmt\For_

parseStmt_Foreach() protected method

protected parseStmt_Foreach ( PhpParser\Node\Stmt\Foreach_ $node )
$node PhpParser\Node\Stmt\Foreach_

parseStmt_Function() protected method

protected parseStmt_Function ( Function_ $node )
$node PhpParser\Node\Stmt\Function_

parseStmt_Global() protected method

protected parseStmt_Global ( PhpParser\Node\Stmt\Global_ $node )
$node PhpParser\Node\Stmt\Global_

parseStmt_Goto() protected method

protected parseStmt_Goto ( PhpParser\Node\Stmt\Goto_ $node )
$node PhpParser\Node\Stmt\Goto_

parseStmt_HaltCompiler() protected method

protected parseStmt_HaltCompiler ( PhpParser\Node\Stmt\HaltCompiler $node )
$node PhpParser\Node\Stmt\HaltCompiler

parseStmt_If() protected method

protected parseStmt_If ( PhpParser\Node\Stmt\If_ $node )
$node PhpParser\Node\Stmt\If_

parseStmt_InlineHTML() protected method

protected parseStmt_InlineHTML ( PhpParser\Node\Stmt\InlineHTML $node )
$node PhpParser\Node\Stmt\InlineHTML

parseStmt_Interface() protected method

protected parseStmt_Interface ( Interface_ $node )
$node PhpParser\Node\Stmt\Interface_

parseStmt_Label() protected method

protected parseStmt_Label ( PhpParser\Node\Stmt\Label $node )
$node PhpParser\Node\Stmt\Label

parseStmt_Namespace() protected method

protected parseStmt_Namespace ( Namespace_ $node )
$node PhpParser\Node\Stmt\Namespace_

parseStmt_Nop() protected method

protected parseStmt_Nop ( PhpParser\Node\Stmt\Nop $node )
$node PhpParser\Node\Stmt\Nop

parseStmt_Property() protected method

protected parseStmt_Property ( Property $node )
$node PhpParser\Node\Stmt\Property

parseStmt_Return() protected method

protected parseStmt_Return ( PhpParser\Node\Stmt\Return_ $node )
$node PhpParser\Node\Stmt\Return_

parseStmt_Static() protected method

protected parseStmt_Static ( PhpParser\Node\Stmt\Static_ $node )
$node PhpParser\Node\Stmt\Static_

parseStmt_Switch() protected method

protected parseStmt_Switch ( PhpParser\Node\Stmt\Switch_ $node )
$node PhpParser\Node\Stmt\Switch_

parseStmt_Throw() protected method

protected parseStmt_Throw ( PhpParser\Node\Stmt\Throw_ $node )
$node PhpParser\Node\Stmt\Throw_

parseStmt_Trait() protected method

protected parseStmt_Trait ( Trait_ $node )
$node PhpParser\Node\Stmt\Trait_

parseStmt_TraitUse() protected method

protected parseStmt_TraitUse ( PhpParser\Node\Stmt\TraitUse $node )
$node PhpParser\Node\Stmt\TraitUse

parseStmt_TryCatch() protected method

protected parseStmt_TryCatch ( TryCatch $node )
$node PhpParser\Node\Stmt\TryCatch

parseStmt_Unset() protected method

protected parseStmt_Unset ( PhpParser\Node\Stmt\Unset_ $node )
$node PhpParser\Node\Stmt\Unset_

parseStmt_Use() protected method

protected parseStmt_Use ( PhpParser\Node\Stmt\Use_ $node )
$node PhpParser\Node\Stmt\Use_

parseStmt_While() protected method

protected parseStmt_While ( PhpParser\Node\Stmt\While_ $node )
$node PhpParser\Node\Stmt\While_

processAssertions() protected method

protected processAssertions ( Operand $op, Block $if, Block $else )
$op Operand
$if Block
$else Block

readAssertion() protected method

protected readAssertion ( Assertion $assert )
$assert Assertion

throwUndefinedLabelError() protected method

protected throwUndefinedLabelError ( )

Property Details

$anonId protected_oe property

protected $anonId

$astParser protected_oe property

protected $astParser

$astTraverser protected_oe property

protected $astTraverser

$block protected_oe property

protected Block,phpcfg $block
return Block

$ctx protected_oe property

protected FuncContext,phpcfg $ctx
return FuncContext

$currentClass protected_oe property

protected Literal,PHPCfg\Operand|null $currentClass
return PHPCfg\Operand\Literal | null

$currentNamespace protected_oe property

protected $currentNamespace

$fileName protected_oe property

protected $fileName

$script protected_oe property

protected Script,phpcfg $script
return Script