1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Reduce memory footprint a little

This commit is contained in:
Brown 2020-06-25 19:12:30 -04:00
parent 8404fa0750
commit bcd7478352
4 changed files with 9 additions and 19 deletions

View File

@ -1786,8 +1786,6 @@ class ClassAnalyzer extends ClassLikeAnalyzer
$type_provider = new \Psalm\Internal\Provider\NodeDataProvider();
$time = \microtime(true);
$method_analyzer->analyze(
$method_context,
$type_provider,
@ -1812,11 +1810,6 @@ class ClassAnalyzer extends ClassLikeAnalyzer
);
}
$project_analyzer->progress->debug(
'Analyzing method ' . $stmt->name . ' took '
. \number_format(\microtime(true) - $time, 4) . "seconds \n"
);
if (!$method_already_analyzed
&& !$class_context->collect_initializations
&& !$class_context->collect_mutations

View File

@ -76,8 +76,8 @@ class Taint
Taintable $from,
Taintable $to,
string $path_type,
array $added_taints = [],
array $removed_taints = []
?array $added_taints = null,
?array $removed_taints = null
) : void {
$from_id = $from->id;
$to_id = $to->id;
@ -209,8 +209,8 @@ class Taint
foreach ($this->forward_edges[$generated_source->id] as $to_id => $path) {
$path_type = $path->type;
$added_taints = $path->unescaped_taints;
$removed_taints = $path->escaped_taints;
$added_taints = $path->unescaped_taints ?: [];
$removed_taints = $path->escaped_taints ?: [];
if (!isset($this->nodes[$to_id])) {
continue;

View File

@ -11,10 +11,10 @@ class Path
public $escaped_taints;
/**
* @param array<string> $unescaped_taints
* @param array<string> $escaped_taints
* @param ?array<string> $unescaped_taints
* @param ?array<string> $escaped_taints
*/
public function __construct(string $type, array $unescaped_taints, array $escaped_taints)
public function __construct(string $type, ?array $unescaped_taints, ?array $escaped_taints)
{
$this->type = $type;
$this->unescaped_taints = $unescaped_taints;

View File

@ -325,14 +325,11 @@ class Reconciler
}
if ($before_adjustment
&& ($result_type->parent_nodes || $before_adjustment->parent_nodes)
&& $before_adjustment->parent_nodes
&& !$result_type->isInt()
&& !$result_type->isFloat()
) {
$result_type->parent_nodes = array_merge(
$result_type->parent_nodes ?: [],
$before_adjustment->parent_nodes ?: []
);
$result_type->parent_nodes = $before_adjustment->parent_nodes;
}
$type_changed = !$before_adjustment || !$result_type->equals($before_adjustment);