PHP Class Phan\Analysis\AssignmentVisitor

Inheritance: extends Phan\AST\Visitor\KindVisitorImplementation
Show file Open project: etsy/phan

Public Methods

Method Description
__construct ( CodeBase $code_base, Context $context, ast\Node $assignment_node, UnionType $right_type, boolean $is_dim_assignment = false )
visit ( ast\Node $node ) : Context Default visitor for node kinds that do not have an overriding method
visitArray ( ast\Node $node ) : Context This happens for code like the following list($a) = [1, 2, 3];
visitCall ( ast\Node $node ) : Context The following is an example of how this'd happen.
visitDim ( ast\Node $node ) : Context
visitList ( ast\Node $node ) : Context
visitMethodCall ( ast\Node $node ) : Context The following is an example of how this'd happen.
visitProp ( ast\Node $node ) : Context
visitStaticProp ( ast\Node $node ) : Context
visitVar ( ast\Node $node ) : Context

Private Methods

Method Description
analyzeSuperglobalDim ( ast\Node $node, string $variable_name ) : Context Analyze an assignment where $variable_name is a superglobal, and return the new context.

Method Details

__construct() public method

public __construct ( CodeBase $code_base, Context $context, ast\Node $assignment_node, UnionType $right_type, boolean $is_dim_assignment = false )
$code_base Phan\CodeBase The global code base we're operating within
$context Phan\Language\Context The context of the parser at the node for which we'd like to determine a type
$assignment_node ast\Node The AST node containing the assignment
$right_type Phan\Language\UnionType The type of the element on the right side of the assignment
$is_dim_assignment boolean True if this assignment is to an array parameter such as in `$foo[3] = 42`. We need to know this in order to decide if we're replacing the union type or if we're adding a type to the union type.

visit() public method

Default visitor for node kinds that do not have an overriding method
public visit ( ast\Node $node ) : Context
$node ast\Node A node to parse
return Phan\Language\Context A new or an unchanged context resulting from parsing the node

visitArray() public method

This happens for code like the following list($a) = [1, 2, 3];
public visitArray ( ast\Node $node ) : Context
$node ast\Node A node to parse
return Phan\Language\Context A new or an unchanged context resulting from parsing the node

visitCall() public method

php function f() { return [ 24 ]; } f()[1] = 42;
public visitCall ( ast\Node $node ) : Context
$node ast\Node A node to parse
return Phan\Language\Context A new or an unchanged context resulting from parsing the node

visitDim() public method

public visitDim ( ast\Node $node ) : Context
$node ast\Node A node to parse
return Phan\Language\Context A new or an unchanged context resulting from parsing the node

visitList() public method

public visitList ( ast\Node $node ) : Context
$node ast\Node A node to parse
return Phan\Language\Context A new or an unchanged context resulting from parsing the node

visitMethodCall() public method

php class C { function f() { return [ 24 ]; } } (new C)->f()[1] = 42;
public visitMethodCall ( ast\Node $node ) : Context
$node ast\Node A node to parse
return Phan\Language\Context A new or an unchanged context resulting from parsing the node

visitProp() public method

public visitProp ( ast\Node $node ) : Context
$node ast\Node A node to parse
return Phan\Language\Context A new or an unchanged context resulting from parsing the node

visitStaticProp() public method

public visitStaticProp ( ast\Node $node ) : Context
$node ast\Node A node to parse
return Phan\Language\Context A new or an unchanged context resulting from parsing the node

visitVar() public method

public visitVar ( ast\Node $node ) : Context
$node ast\Node A node to parse
return Phan\Language\Context A new or an unchanged context resulting from parsing the node