Skip to content

Commit f69d1a8

Browse files
committed
Merge remote-tracking branch 'origin/6.x'
2 parents b8ffc19 + 79ca8ce commit f69d1a8

File tree

2 files changed

+25
-16
lines changed

2 files changed

+25
-16
lines changed

psalm-baseline.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<files psalm-version="6.x-dev@2b0ff73c8bed091af231a0a80ac109126c92083a">
2+
<files psalm-version="6.x-dev@bbd217fc98c0daa0a13aea2a7f119d03ba3fc9a0">
33
<file src="examples/TemplateChecker.php">
44
<PossiblyUndefinedIntArrayOffset>
55
<code><![CDATA[$comment_block->tags['variablesfrom'][0]]]></code>
@@ -1653,6 +1653,9 @@
16531653
<RiskyTruthyFalsyComparison>
16541654
<code><![CDATA[end($path_types)]]></code>
16551655
</RiskyTruthyFalsyComparison>
1656+
<UnnecessaryVarAnnotation>
1657+
<code><![CDATA[DataFlowNode]]></code>
1658+
</UnnecessaryVarAnnotation>
16561659
</file>
16571660
<file src="src/Psalm/Internal/Composer.php">
16581661
<RiskyTruthyFalsyComparison>

src/Psalm/Internal/Codebase/TaintFlowGraph.php

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@
3535
use Psalm\Type\TaintKind;
3636
use Webmozart\Assert\Assert;
3737

38+
use function array_diff;
39+
use function array_filter;
40+
use function array_intersect;
41+
use function array_merge;
42+
use function array_unique;
43+
use function array_unshift;
3844
use function count;
3945
use function end;
4046
use function json_encode;
@@ -185,23 +191,23 @@ public function getSuccessorPath(DataFlowNode $sink): string
185191
*/
186192
public function getIssueTrace(DataFlowNode $source): array
187193
{
188-
$previous_source = $source->taintSource;
189-
$path_types = $source->path_types;
190-
$node = [
191-
'location' => $source->code_location,
192-
'label' => $source->label,
193-
'entry_path_type' => end($path_types) ?: '',
194-
];
195-
196-
if ($previous_source) {
194+
$out = [];
195+
do {
196+
/** @var DataFlowNode $source */
197+
$previous_source = $source->taintSource;
197198
if ($previous_source === $source) {
198-
return [];
199+
break;
199200
}
200-
201-
return [...$this->getIssueTrace($previous_source), $node];
202-
}
203-
204-
return [$node];
201+
$path_types = $source->path_types;
202+
array_unshift($out, [
203+
'location' => $source->code_location,
204+
'label' => $source->label,
205+
'entry_path_type' => end($path_types) ?: '',
206+
]);
207+
$source = $previous_source;
208+
} while ($previous_source);
209+
210+
return $out;
205211
}
206212

207213
public function connectSinksAndSources(Progress $progress): void

0 commit comments

Comments
 (0)