1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 04:45:20 +01:00

Fix errors

This commit is contained in:
Brown 2019-08-06 18:56:36 -04:00
parent 14b37b95af
commit 16a1dc8538
2 changed files with 26 additions and 14 deletions

View File

@ -999,7 +999,7 @@ class StaticCallAnalyzer extends \Psalm\Internal\Analyzer\Statements\Expression\
$method_id
. '-' . $code_location->file_name
. ':' . $code_location->raw_file_start
),
),
new CodeLocation($source, $stmt->name)
);
} else {

View File

@ -154,19 +154,23 @@ class Taint
*/
public function getPredecessorPath(TypeSource $source, array $visited_paths = []) : string
{
$location_summary = $source->code_location->getQuickSummary();
$location_summary = '';
if (isset($visited_paths[$location_summary])) {
return '';
if ($source->code_location) {
$location_summary = $source->code_location->getQuickSummary();
if (isset($visited_paths[$location_summary])) {
return '';
}
$visited_paths[$location_summary] = true;
}
$visited_paths[$location_summary] = true;
$source_descriptor = $source->id . ($source->code_location ? ' (' . $location_summary . ')' : '');
$source_descriptor = $source->id . ($location_summary ? ' (' . $location_summary . ')' : '');
if ($previous_source = $this->new_sources[$source->id] ?? self::$archived_sources[$source->id] ?? null) {
if ($previous_source === $source) {
throw new \UnexpectedValueException('bad');
return '';
}
return $this->getPredecessorPath($previous_source, $visited_paths) . ' -> ' . $source_descriptor;
@ -180,17 +184,25 @@ class Taint
*/
public function getSuccessorPath(TypeSource $source, array $visited_paths = []) : string
{
$location_summary = $source->code_location->getQuickSummary();
$location_summary = '';
if (isset($visited_paths[$location_summary])) {
return '';
if ($source->code_location) {
$location_summary = $source->code_location->getQuickSummary();
if (isset($visited_paths[$location_summary])) {
return '';
}
$visited_paths[$location_summary] = true;
}
$visited_paths[$location_summary] = true;
$source_descriptor = $source->id . ($source->code_location ? ' (' . $location_summary . ')' : '');
$source_descriptor = $source->id . ($location_summary ? ' (' . $location_summary . ')' : '');
if ($next_source = $this->new_sinks[$source->id] ?? self::$archived_sinks[$source->id] ?? null) {
if ($next_source === $source) {
return '';
}
return $source_descriptor . ' -> ' . $this->getSuccessorPath($next_source, $visited_paths);
}