Skip to content

Commit

Permalink
Rename ControlFlowGraph to more appropriate DataFlowGraph
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Oct 13, 2020
1 parent 446a833 commit 516141a
Show file tree
Hide file tree
Showing 45 changed files with 182 additions and 182 deletions.
4 changes: 2 additions & 2 deletions src/Psalm/Codebase.php
Original file line number Diff line number Diff line change
Expand Up @@ -1594,7 +1594,7 @@ public function addTaintSource(
return;
}

$source = new \Psalm\Internal\ControlFlow\TaintSource(
$source = new \Psalm\Internal\DataFlow\TaintSource(
$taint_id,
$taint_id,
$code_location,
Expand Down Expand Up @@ -1623,7 +1623,7 @@ public function addTaintSink(
return;
}

$sink = new \Psalm\Internal\ControlFlow\TaintSink(
$sink = new \Psalm\Internal\DataFlow\TaintSink(
$taint_id,
$taint_id,
$code_location,
Expand Down
4 changes: 2 additions & 2 deletions src/Psalm/Internal/Analyzer/ClosureAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Psalm\Issue\PossiblyUndefinedVariable;
use Psalm\Issue\UndefinedVariable;
use Psalm\IssueBuffer;
use Psalm\Internal\ControlFlow\ControlFlowNode;
use Psalm\Internal\DataFlow\DataFlowNode;
use Psalm\Type;
use Psalm\Type\Atomic\TNamedObject;
use function strpos;
Expand Down Expand Up @@ -148,7 +148,7 @@ public static function analyzeExpression(
foreach ($parent_nodes as $parent_node) {
$statements_analyzer->control_flow_graph->addPath(
$parent_node,
new ControlFlowNode('closure-use', 'closure use', null),
new DataFlowNode('closure-use', 'closure use', null),
'closure-use'
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* @psalm-immutable
*/
class ControlFlowNodeData
class DataFlowNodeData
{
/**
* @var int
Expand Down
14 changes: 7 additions & 7 deletions src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
use function array_search;
use function array_keys;
use function end;
use Psalm\Internal\ControlFlow\ControlFlowNode;
use Psalm\Internal\DataFlow\DataFlowNode;
use Psalm\Storage\FunctionStorage;

/**
Expand Down Expand Up @@ -113,7 +113,7 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer
/**
* Holds param nodes for functions with func_get_args calls
*
* @var array<string, ControlFlowNode>
* @var array<string, DataFlowNode>
*/
public $param_nodes = [];

Expand Down Expand Up @@ -865,7 +865,7 @@ function (FunctionLikeParameter $p): bool {
&& isset($context->vars_in_scope['$this'])
&& $context->vars_in_scope['$this']->parent_nodes
) {
$method_source = ControlFlowNode::getForMethodReturn(
$method_source = DataFlowNode::getForMethodReturn(
(string) $method_id,
$cased_method_id,
$storage->location
Expand Down Expand Up @@ -992,7 +992,7 @@ private function checkParamReferences(
continue;
}

$assignment_node = ControlFlowNode::getForAssignment($var_name, $original_location);
$assignment_node = DataFlowNode::getForAssignment($var_name, $original_location);

if ($statements_analyzer->control_flow_graph instanceof \Psalm\Internal\Codebase\VariableUseGraph
&& $statements_analyzer->control_flow_graph->isVariableUsed($assignment_node)
Expand Down Expand Up @@ -1209,15 +1209,15 @@ private function processParams(
if ($statements_analyzer->control_flow_graph
&& $function_param->location
) {
$param_assignment = ControlFlowNode::getForAssignment(
$param_assignment = DataFlowNode::getForAssignment(
'$' . $function_param->name,
$function_param->location
);

$statements_analyzer->control_flow_graph->addNode($param_assignment);

if ($cased_method_id) {
$type_source = ControlFlowNode::getForMethodArgument(
$type_source = DataFlowNode::getForMethodArgument(
$cased_method_id,
$cased_method_id,
$offset,
Expand All @@ -1233,7 +1233,7 @@ private function processParams(
) {
$statements_analyzer->control_flow_graph->addPath(
$param_assignment,
new ControlFlowNode('variable-use', 'variable use', null),
new DataFlowNode('variable-use', 'variable use', null),
'variable-use'
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Psalm/Internal/Analyzer/IssueData.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class IssueData
public $link;

/**
* @var ?list<ControlFlowNodeData|array{label: string, entry_path_type: string}>
* @var ?list<DataFlowNodeData|array{label: string, entry_path_type: string}>
*/
public $taint_trace;

Expand All @@ -122,7 +122,7 @@ class IssueData
public $dupe_key;

/**
* @param ?list<ControlFlowNodeData|array{label: string, entry_path_type: string}> $taint_trace
* @param ?list<DataFlowNodeData|array{label: string, entry_path_type: string}> $taint_trace
*/
public function __construct(
string $severity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use Psalm\Internal\Analyzer\StatementsAnalyzer;
use Psalm\Internal\Type\Comparator\AtomicTypeComparator;
use Psalm\Internal\FileManipulation\FileManipulationBuffer;
use Psalm\Internal\ControlFlow\ControlFlowNode;
use Psalm\Internal\DataFlow\DataFlowNode;
use Psalm\CodeLocation;
use Psalm\Context;
use Psalm\Exception\DocblockParseException;
Expand Down
6 changes: 3 additions & 3 deletions src/Psalm/Internal/Analyzer/Statements/Block/TryAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Psalm\Internal\Analyzer\ClassLikeAnalyzer;
use Psalm\Internal\Analyzer\ScopeAnalyzer;
use Psalm\Internal\Analyzer\StatementsAnalyzer;
use Psalm\Internal\ControlFlow\ControlFlowNode;
use Psalm\Internal\DataFlow\DataFlowNode;
use Psalm\CodeLocation;
use Psalm\Context;
use Psalm\Issue\InvalidCatch;
Expand Down Expand Up @@ -324,7 +324,7 @@ function ($fq_catch_class) use ($codebase): Type\Atomic {
}

if ($statements_analyzer->control_flow_graph) {
$catch_var_node = ControlFlowNode::getForAssignment($catch_var_id, $location);
$catch_var_node = DataFlowNode::getForAssignment($catch_var_id, $location);

$catch_context->vars_in_scope[$catch_var_id]->parent_nodes = [
$catch_var_node->id => $catch_var_node
Expand All @@ -333,7 +333,7 @@ function ($fq_catch_class) use ($codebase): Type\Atomic {
if ($statements_analyzer->control_flow_graph instanceof \Psalm\Internal\Codebase\VariableUseGraph) {
$statements_analyzer->control_flow_graph->addPath(
$catch_var_node,
new ControlFlowNode('variable-use', 'variable use', null),
new DataFlowNode('variable-use', 'variable use', null),
'variable-use'
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Analyzer/Statements/EchoAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Psalm\Internal\Analyzer\Statements\Expression\Call\ArgumentAnalyzer;
use Psalm\Internal\Analyzer\Statements\Expression\CastAnalyzer;
use Psalm\Internal\Analyzer\StatementsAnalyzer;
use Psalm\Internal\ControlFlow\TaintSink;
use Psalm\Internal\DataFlow\TaintSink;
use Psalm\Internal\Codebase\TaintFlowGraph;
use Psalm\CodeLocation;
use Psalm\Context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public static function analyze(
if ($item_value_type->parent_nodes) {
$var_location = new CodeLocation($statements_analyzer->getSource(), $item);

$new_parent_node = \Psalm\Internal\ControlFlow\ControlFlowNode::getForAssignment(
$new_parent_node = \Psalm\Internal\DataFlow\DataFlowNode::getForAssignment(
'array'
. ($item_key_value !== null ? '[\'' . $item_key_value . '\']' : ''),
$var_location
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ private static function taintArrayAssignment(
if (!$stmt_type->parent_nodes) {
$var_location = new \Psalm\CodeLocation($statements_analyzer->getSource(), $expr->var);

$parent_node = \Psalm\Internal\ControlFlow\ControlFlowNode::getForAssignment(
$parent_node = \Psalm\Internal\DataFlow\DataFlowNode::getForAssignment(
$var_var_id ?: 'assignment',
$var_location
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
use function count;
use function in_array;
use function strtolower;
use Psalm\Internal\ControlFlow\ControlFlowNode;
use Psalm\Internal\DataFlow\DataFlowNode;

/**
* @internal
Expand Down Expand Up @@ -1188,14 +1188,14 @@ private static function taintProperty(
return;
}

$var_node = ControlFlowNode::getForAssignment(
$var_node = DataFlowNode::getForAssignment(
$var_id,
$var_location
);

$control_flow_graph->addNode($var_node);

$property_node = ControlFlowNode::getForAssignment(
$property_node = DataFlowNode::getForAssignment(
$var_property_id ?: $var_id . '->$property',
$property_location
);
Expand Down Expand Up @@ -1237,7 +1237,7 @@ private static function taintProperty(

$code_location = new CodeLocation($statements_analyzer->getSource(), $stmt);

$localized_property_node = new ControlFlowNode(
$localized_property_node = new DataFlowNode(
$property_id . '-' . $code_location->file_name . ':' . $code_location->raw_file_start,
$property_id,
$code_location,
Expand All @@ -1246,7 +1246,7 @@ private static function taintProperty(

$control_flow_graph->addNode($localized_property_node);

$property_node = new ControlFlowNode(
$property_node = new DataFlowNode(
$property_id,
$property_id,
null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Psalm\Internal\Scanner\VarDocblockComment;
use Psalm\Internal\Codebase\VariableUseGraph;
use Psalm\Internal\Codebase\TaintFlowGraph;
use Psalm\Internal\ControlFlow\ControlFlowNode;
use Psalm\Internal\DataFlow\DataFlowNode;
use Psalm\CodeLocation;
use Psalm\Context;
use Psalm\Exception\DocblockParseException;
Expand Down Expand Up @@ -254,12 +254,12 @@ public static function analyze(
&& !$assign_value_type->parent_nodes
) {
if ($array_var_id) {
$assignment_node = ControlFlowNode::getForAssignment(
$assignment_node = DataFlowNode::getForAssignment(
$array_var_id,
new CodeLocation($statements_analyzer->getSource(), $assign_var)
);
} else {
$assignment_node = new ControlFlowNode('unknown-origin', 'unknown origin', null);
$assignment_node = new DataFlowNode('unknown-origin', 'unknown origin', null);
}

$assign_value_type->parent_nodes = [
Expand Down Expand Up @@ -455,12 +455,12 @@ public static function analyze(
) {
$location = new CodeLocation($statements_analyzer, $assign_var);

$byref_node = ControlFlowNode::getForAssignment($var_id, $location);
$byref_node = DataFlowNode::getForAssignment($var_id, $location);

foreach ($assign_value_type->parent_nodes as $parent_node) {
$statements_analyzer->control_flow_graph->addPath(
$parent_node,
new ControlFlowNode('variable-use', 'variable use', null),
new DataFlowNode('variable-use', 'variable use', null),
'variable-use'
);

Expand Down Expand Up @@ -489,7 +489,7 @@ public static function analyze(
foreach ($assign_value_type->parent_nodes as $parent_node) {
$statements_analyzer->control_flow_graph->addPath(
$parent_node,
new ControlFlowNode('variable-use', 'variable use', null),
new DataFlowNode('variable-use', 'variable use', null),
'variable-use'
);
}
Expand Down Expand Up @@ -887,7 +887,7 @@ public static function analyze(
$var_location = new CodeLocation($statements_analyzer->getSource(), $var);

if (!$context->vars_in_scope[$list_var_id]->parent_nodes) {
$assignment_node = ControlFlowNode::getForAssignment(
$assignment_node = DataFlowNode::getForAssignment(
$list_var_id,
$var_location
);
Expand All @@ -901,7 +901,7 @@ public static function analyze(
) {
$context->vars_in_scope[$list_var_id]->parent_nodes = [];
} else {
$new_parent_node = ControlFlowNode::getForAssignment($list_var_id, $var_location);
$new_parent_node = DataFlowNode::getForAssignment($list_var_id, $var_location);

$statements_analyzer->control_flow_graph->addNode($new_parent_node);

Expand Down Expand Up @@ -1099,7 +1099,7 @@ public static function analyze(
} else {
$var_location = new CodeLocation($statements_analyzer->getSource(), $assign_var);

$new_parent_node = ControlFlowNode::getForAssignment($var_id, $var_location);
$new_parent_node = DataFlowNode::getForAssignment($var_id, $var_location);

$control_flow_graph->addNode($new_parent_node);

Expand Down Expand Up @@ -1273,7 +1273,7 @@ public static function analyzeAssignmentOperation(
$statements_analyzer->node_data->setType($stmt, $fake_coalesce_type);
}

BinaryOpAnalyzer::addControlFlow(
BinaryOpAnalyzer::addDataFlow(
$statements_analyzer,
$stmt,
$stmt->var,
Expand Down Expand Up @@ -1426,7 +1426,7 @@ public static function analyzeAssignmentOperation(

$statements_analyzer->node_data->setType($stmt, $result_type);

BinaryOpAnalyzer::addControlFlow(
BinaryOpAnalyzer::addDataFlow(
$statements_analyzer,
$stmt,
$stmt->var,
Expand All @@ -1446,7 +1446,7 @@ public static function analyzeAssignmentOperation(
$statements_analyzer->node_data->setType($stmt, Type::getMixed());
}

BinaryOpAnalyzer::addControlFlow(
BinaryOpAnalyzer::addDataFlow(
$statements_analyzer,
$stmt,
$stmt->var,
Expand All @@ -1466,7 +1466,7 @@ public static function analyzeAssignmentOperation(
$context->vars_in_scope[$array_var_id] = $result_type;
$statements_analyzer->node_data->setType($stmt, clone $context->vars_in_scope[$array_var_id]);

BinaryOpAnalyzer::addControlFlow(
BinaryOpAnalyzer::addDataFlow(
$statements_analyzer,
$stmt,
$stmt->var,
Expand Down Expand Up @@ -1495,7 +1495,7 @@ public static function analyzeAssignmentOperation(
$statements_analyzer->node_data->setType($stmt, $context->vars_in_scope[$array_var_id]);
}

BinaryOpAnalyzer::addControlFlow(
BinaryOpAnalyzer::addDataFlow(
$statements_analyzer,
$stmt,
$stmt->var,
Expand All @@ -1519,7 +1519,7 @@ public static function analyzeAssignmentOperation(
} else {
$var_location = new CodeLocation($statements_analyzer->getSource(), $stmt->var);

$new_parent_node = ControlFlowNode::getForAssignment($array_var_id, $var_location);
$new_parent_node = DataFlowNode::getForAssignment($array_var_id, $var_location);

$control_flow_graph->addNode($new_parent_node);

Expand Down Expand Up @@ -1626,7 +1626,7 @@ public static function analyzeAssignmentRef(
foreach ($context->vars_in_scope[$lhs_var_id]->parent_nodes as $parent_node) {
$statements_analyzer->control_flow_graph->addPath(
$parent_node,
new ControlFlowNode('variable-use', 'variable use', null),
new DataFlowNode('variable-use', 'variable use', null),
'variable-use'
);
}
Expand All @@ -1652,7 +1652,7 @@ public static function analyzeAssignmentRef(

$lhs_location = new CodeLocation($statements_analyzer->getSource(), $stmt->var);

$lhs_node = ControlFlowNode::getForAssignment($lhs_var_id, $lhs_location);
$lhs_node = DataFlowNode::getForAssignment($lhs_var_id, $lhs_location);

foreach ($rhs_type->parent_nodes as $byref_destination_node) {
$control_flow_graph->addPath($lhs_node, $byref_destination_node, '=');
Expand Down

0 comments on commit 516141a

Please sign in to comment.