PHP Class Devise\Pages\Interpreter\Modifiers\EchoDeviseMagic

Inheritance: extends PhpParser\NodeVisitorAbstract
Show file Open project: devisephp/cms

Public Methods

Method Description
__construct ( DeviseParser $DeviseParser ) Create a new EchoDeviseMagic visitor
enterNode ( PhpParser\Node $node ) : PhpParser\Node We need to look for different types of nodes inside of echo nodes only

Protected Methods

Method Description
examineExpression ( $node ) : [type] Determines what to do with this expression
examineFunction ( PhpParser\Node $node ) : PhpParser\Node Examines the function node for places to put dvsmagic() wrappers
isWhiteListedFunction ( [type] $node ) : boolean we don't want to be passing ###dvsmagic-field-1-attr### to php functions, except for those functions that have been whitelisted. The only one so far is 'e' which is created by Laravel's blade to escape variables
traverseIntoEchoStatement ( PhpParser\Node\Stmt\Echo_ $node ) : PhpParser\Node\Stmt\Echo_ Looks inside of this echo for valid combinations.
wrapNodeWithMagicMethods ( PhpParser\Node $node ) : PhpParser\Node wraps the node inside of the dvsmagic method

Method Details

__construct() public method

Create a new EchoDeviseMagic visitor
public __construct ( DeviseParser $DeviseParser )
$DeviseParser Devise\Pages\Interpreter\DeviseParser

enterNode() public method

We need to look for different types of nodes inside of echo nodes only
public enterNode ( PhpParser\Node $node ) : PhpParser\Node
$node PhpParser\Node
return PhpParser\Node

examineExpression() protected method

Determines what to do with this expression
protected examineExpression ( $node ) : [type]
return [type]

examineFunction() protected method

Examines the function node for places to put dvsmagic() wrappers
protected examineFunction ( PhpParser\Node $node ) : PhpParser\Node
$node PhpParser\Node
return PhpParser\Node

isWhiteListedFunction() protected method

For example: {{ $myvar }} becomes However for functions like route('some-route', $model->id) we don't want to be passing the magic field ever... we won't ever live update that and we shouldn't even try
protected isWhiteListedFunction ( [type] $node ) : boolean
$node [type]
return boolean

traverseIntoEchoStatement() protected method

This is a context free grammar tree at this point...
protected traverseIntoEchoStatement ( PhpParser\Node\Stmt\Echo_ $node ) : PhpParser\Node\Stmt\Echo_
$node PhpParser\Node\Stmt\Echo_
return PhpParser\Node\Stmt\Echo_

wrapNodeWithMagicMethods() protected method

wraps the node inside of the dvsmagic method
protected wrapNodeWithMagicMethods ( PhpParser\Node $node ) : PhpParser\Node
$node PhpParser\Node
return PhpParser\Node