diff --git a/src/Psalm/Internal/Analyzer/Statements/EchoAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/EchoAnalyzer.php index 7fa82584e..d5b3b8887 100644 --- a/src/Psalm/Internal/Analyzer/Statements/EchoAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/EchoAnalyzer.php @@ -46,9 +46,7 @@ class EchoAnalyzer ); } - if ($statements_analyzer->taint_graph - && $codebase->config->trackTaintsInPath($statements_analyzer->getFilePath()) - ) { + if ($statements_analyzer->taint_graph) { $call_location = new CodeLocation($statements_analyzer->getSource(), $stmt); $echo_param_sink = Sink::getForMethodArgument( diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/ArrayAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/ArrayAnalyzer.php index 04a23c3a4..afdada9c6 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/ArrayAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/ArrayAnalyzer.php @@ -203,7 +203,6 @@ class ArrayAnalyzer } if ($statements_analyzer->taint_graph - && $codebase->config->trackTaintsInPath($statements_analyzer->getFilePath()) && !\in_array('TaintedInput', $statements_analyzer->getSuppressedIssues()) ) { if ($item_value_type = $statements_analyzer->node_data->getType($item->value)) { diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/InstancePropertyAssignmentAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/InstancePropertyAssignmentAnalyzer.php index 9d9bb6653..2644057d0 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/InstancePropertyAssignmentAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/InstancePropertyAssignmentAnalyzer.php @@ -1147,11 +1147,7 @@ class InstancePropertyAssignmentAnalyzer Type\Union $assignment_value_type, Context $context ) : void { - $codebase = $statements_analyzer->getCodebase(); - - if (!$statements_analyzer->taint_graph - || !$codebase->config->trackTaintsInPath($statements_analyzer->getFilePath()) - ) { + if (!$statements_analyzer->taint_graph) { return; } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php index 37a5184a8..36ae6e28d 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php @@ -878,9 +878,7 @@ class AssignmentAnalyzer return $context->vars_in_scope[$var_id]; } - if ($statements_analyzer->taint_graph - && $codebase->config->trackTaintsInPath($statements_analyzer->getFilePath()) - ) { + if ($statements_analyzer->taint_graph) { $taint_graph = $statements_analyzer->taint_graph; if ($context->vars_in_scope[$var_id]->parent_nodes) { @@ -1200,7 +1198,6 @@ class AssignmentAnalyzer $statements_analyzer->node_data->setType($stmt, clone $context->vars_in_scope[$array_var_id]); if ($statements_analyzer->taint_graph - && $codebase->config->trackTaintsInPath($statements_analyzer->getFilePath()) && !\in_array('TaintedInput', $statements_analyzer->getSuppressedIssues()) ) { $stmt_left_type = $statements_analyzer->node_data->getType($stmt->var); diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOpAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOpAnalyzer.php index 82040c021..94a54f77e 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOpAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOpAnalyzer.php @@ -104,10 +104,7 @@ class BinaryOpAnalyzer $stmt_type = $result_type; } - $codebase = $statements_analyzer->getCodebase(); - if ($statements_analyzer->taint_graph - && $codebase->config->trackTaintsInPath($statements_analyzer->getFilePath()) && !\in_array('TaintedInput', $statements_analyzer->getSuppressedIssues()) ) { $stmt_left_type = $statements_analyzer->node_data->getType($stmt->left); diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php index 4c7e0e0d1..992042049 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php @@ -1220,7 +1220,6 @@ class ArgumentAnalyzer $codebase = $statements_analyzer->getCodebase(); if (!$statements_analyzer->taint_graph - || !$codebase->config->trackTaintsInPath($statements_analyzer->getFilePath()) || \in_array('TaintedInput', $statements_analyzer->getSuppressedIssues()) ) { return $input_type; diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php index 3bbc1b2e4..a3ee890f3 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php @@ -1059,10 +1059,7 @@ class FunctionCallAnalyzer extends CallAnalyzer FunctionLikeStorage $function_storage, Type\Union $stmt_type ) : void { - $codebase = $statements_analyzer->getCodebase(); - if (!$statements_analyzer->taint_graph - || !$codebase->config->trackTaintsInPath($statements_analyzer->getFilePath()) || \in_array('TaintedInput', $statements_analyzer->getSuppressedIssues()) ) { return; diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodCallReturnTypeFetcher.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodCallReturnTypeFetcher.php index aa4ff3382..9a6b69d73 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodCallReturnTypeFetcher.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodCallReturnTypeFetcher.php @@ -228,7 +228,6 @@ class MethodCallReturnTypeFetcher if ($statements_analyzer->taint_graph && $declaring_method_id - && $codebase->config->trackTaintsInPath($statements_analyzer->getFilePath()) && !\in_array('TaintedInput', $statements_analyzer->getSuppressedIssues()) ) { $method_storage = $codebase->methods->getStorage( diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/NewAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/NewAnalyzer.php index 4f5978eec..6c9a1c4df 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/NewAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/NewAnalyzer.php @@ -641,7 +641,6 @@ class NewAnalyzer extends \Psalm\Internal\Analyzer\Statements\Expression\CallAna } if ($statements_analyzer->taint_graph - && $codebase->config->trackTaintsInPath($statements_analyzer->getFilePath()) && !\in_array('TaintedInput', $statements_analyzer->getSuppressedIssues()) && ($stmt_type = $statements_analyzer->node_data->getType($stmt)) ) { diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticCallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticCallAnalyzer.php index 4f00c4df8..fdae3b487 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticCallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticCallAnalyzer.php @@ -1423,10 +1423,7 @@ class StaticCallAnalyzer extends CallAnalyzer Type\Union $return_type_candidate, ?\Psalm\Storage\MethodStorage $method_storage ) : void { - $codebase = $statements_analyzer->getCodebase(); - if (!$statements_analyzer->taint_graph - || !$codebase->config->trackTaintsInPath($statements_analyzer->getFilePath()) || \in_array('TaintedInput', $statements_analyzer->getSuppressedIssues()) ) { return; diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/EncapsulatedStringAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/EncapsulatedStringAnalyzer.php index f0d315b1b..7482529a3 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/EncapsulatedStringAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/EncapsulatedStringAnalyzer.php @@ -15,8 +15,6 @@ class EncapsulatedStringAnalyzer PhpParser\Node\Scalar\Encapsed $stmt, Context $context ) : bool { - $codebase = $statements_analyzer->getCodebase(); - $stmt_type = Type::getString(); foreach ($stmt->parts as $part) { @@ -35,7 +33,6 @@ class EncapsulatedStringAnalyzer ); if ($statements_analyzer->taint_graph - && $codebase->config->trackTaintsInPath($statements_analyzer->getFilePath()) && !\in_array('TaintedInput', $statements_analyzer->getSuppressedIssues()) ) { $var_location = new CodeLocation($statements_analyzer, $part); diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/EvalAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/EvalAnalyzer.php index 3c23660d6..b3d92b762 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/EvalAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/EvalAnalyzer.php @@ -23,11 +23,8 @@ class EvalAnalyzer $expr_type = $statements_analyzer->node_data->getType($stmt->expr); if ($expr_type) { - $codebase = $statements_analyzer->getCodebase(); - if ($statements_analyzer->taint_graph && $expr_type->parent_nodes - && $codebase->config->trackTaintsInPath($statements_analyzer->getFilePath()) && !\in_array('TaintedInput', $statements_analyzer->getSuppressedIssues()) ) { $arg_location = new CodeLocation($statements_analyzer->getSource(), $stmt->expr); diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/ExitAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/ExitAnalyzer.php index b8ebca7f2..59bd81645 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/ExitAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/ExitAnalyzer.php @@ -27,11 +27,7 @@ class ExitAnalyzer return false; } - $codebase = $statements_analyzer->getCodebase(); - - if ($statements_analyzer->taint_graph - && $codebase->config->trackTaintsInPath($statements_analyzer->getFilePath()) - ) { + if ($statements_analyzer->taint_graph) { $call_location = new CodeLocation($statements_analyzer->getSource(), $stmt); $echo_param_sink = Sink::getForMethodArgument( diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ArrayFetchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ArrayFetchAnalyzer.php index 886d9db03..1d95de744 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ArrayFetchAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ArrayFetchAnalyzer.php @@ -312,12 +312,9 @@ class ArrayFetchAnalyzer Type\Union $stmt_type, Type\Union $offset_type ) : void { - $codebase = $statements_analyzer->getCodebase(); - if ($statements_analyzer->taint_graph && ($stmt_var_type = $statements_analyzer->node_data->getType($var)) && $stmt_var_type->parent_nodes - && $codebase->config->trackTaintsInPath($statements_analyzer->getFilePath()) ) { if (\in_array('TaintedInput', $statements_analyzer->getSuppressedIssues())) { $stmt_var_type->parent_nodes = []; diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/InstancePropertyFetchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/InstancePropertyFetchAnalyzer.php index 9cc198c4b..4f5108841 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/InstancePropertyFetchAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/InstancePropertyFetchAnalyzer.php @@ -1193,11 +1193,7 @@ class InstancePropertyFetchAnalyzer \Psalm\Storage\ClassLikeStorage $class_storage, bool $in_assignment ) : void { - $codebase = $statements_analyzer->getCodebase(); - - if (!$statements_analyzer->taint_graph - || !$codebase->config->trackTaintsInPath($statements_analyzer->getFilePath()) - ) { + if (!$statements_analyzer->taint_graph) { return; } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/VariableFetchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/VariableFetchAnalyzer.php index 1328908ed..883e044ae 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/VariableFetchAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/VariableFetchAnalyzer.php @@ -393,10 +393,7 @@ class VariableFetchAnalyzer Type\Union $type, PhpParser\Node\Expr\Variable $stmt ) : void { - $codebase = $statements_analyzer->getCodebase(); - if ($statements_analyzer->taint_graph - && $codebase->config->trackTaintsInPath($statements_analyzer->getFilePath()) && !\in_array('TaintedInput', $statements_analyzer->getSuppressedIssues()) ) { if ($var_name === '$_GET' diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/IncludeAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/IncludeAnalyzer.php index 9e87e9636..7492d7c4c 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/IncludeAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/IncludeAnalyzer.php @@ -104,7 +104,6 @@ class IncludeAnalyzer if ($stmt_expr_type && $statements_analyzer->taint_graph && $stmt_expr_type->parent_nodes - && $codebase->config->trackTaintsInPath($statements_analyzer->getFilePath()) && !\in_array('TaintedInput', $statements_analyzer->getSuppressedIssues()) ) { $arg_location = new CodeLocation($statements_analyzer->getSource(), $stmt->expr); diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/PrintAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/PrintAnalyzer.php index 587081efb..a73d2c91a 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/PrintAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/PrintAnalyzer.php @@ -25,9 +25,7 @@ class PrintAnalyzer return false; } - if ($statements_analyzer->taint_graph - && $codebase->config->trackTaintsInPath($statements_analyzer->getFilePath()) - ) { + if ($statements_analyzer->taint_graph) { $call_location = new CodeLocation($statements_analyzer->getSource(), $stmt); $print_param_sink = Sink::getForMethodArgument( diff --git a/src/Psalm/Internal/Analyzer/Statements/ReturnAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/ReturnAnalyzer.php index 1aee9b4f0..6801367b4 100644 --- a/src/Psalm/Internal/Analyzer/Statements/ReturnAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/ReturnAnalyzer.php @@ -189,9 +189,7 @@ class ReturnAnalyzer $source->getParentFQCLN() ); - if ($statements_analyzer->taint_graph - && $codebase->config->trackTaintsInPath($statements_analyzer->getFilePath()) - ) { + if ($statements_analyzer->taint_graph) { self::handleTaints( $statements_analyzer, $stmt, diff --git a/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php b/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php index f6c9e7ae1..09418ea4d 100644 --- a/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php @@ -135,7 +135,9 @@ class StatementsAnalyzer extends SourceAnalyzer implements StatementsSource $this->file_analyzer = $source->getFileAnalyzer(); $this->codebase = $source->getCodebase(); $this->node_data = $node_data; - $this->taint_graph = $this->codebase->taint_graph ? new TaintGraph() : null; + $this->taint_graph = $this->codebase->taint_graph + ? new TaintGraph() + : null; } /** @@ -191,7 +193,11 @@ class StatementsAnalyzer extends SourceAnalyzer implements StatementsSource } } - if ($root_scope && $this->taint_graph && $this->codebase->taint_graph) { + if ($root_scope + && $this->taint_graph + && $this->codebase->taint_graph + && $codebase->config->trackTaintsInPath($this->getFilePath()) + ) { $this->codebase->taint_graph->addGraph($this->taint_graph); } diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/FilterVarReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/FilterVarReturnTypeProvider.php index 27baeb2a2..08bd09357 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/FilterVarReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/FilterVarReturnTypeProvider.php @@ -118,10 +118,7 @@ class FilterVarReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnTy $filter_type = Type::getMixed(); } - $codebase = $statements_source->getCodebase(); - if ($statements_source->taint_graph - && $codebase->config->trackTaintsInPath($statements_source->getFilePath()) && !\in_array('TaintedInput', $statements_source->getSuppressedIssues()) ) { $function_return_sink = TaintNode::getForMethodReturn(