From 0d0a06e78f38e7d50270929b6d9f4b36d215c3d0 Mon Sep 17 00:00:00 2001 From: ralila <> Date: Mon, 15 Nov 2021 02:04:59 +0100 Subject: [PATCH] Avoid empty variable names instead of filtering them later --- src/Psalm/Internal/Analyzer/StatementsAnalyzer.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php b/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php index 0e2a3b73f..2bcd65f94 100644 --- a/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php @@ -61,6 +61,7 @@ use function strtolower; use function substr; use function trim; +use const PREG_SPLIT_NO_EMPTY; use const STDERR; /** @@ -382,12 +383,9 @@ class StatementsAnalyzer extends SourceAnalyzer if (isset($statements_analyzer->parsed_docblock->tags['psalm-trace'])) { foreach ($statements_analyzer->parsed_docblock->tags['psalm-trace'] as $traced_variable_line) { - $possible_traced_variable_names = preg_split('/(?:\s*,\s*|\s+)/', $traced_variable_line); + $possible_traced_variable_names = preg_split('/(?:\s*,\s*|\s+)/', $traced_variable_line, -1, PREG_SPLIT_NO_EMPTY); if ($possible_traced_variable_names) { - $traced_variables = array_merge( - $traced_variables, - array_filter($possible_traced_variable_names) - ); + $traced_variables = array_merge($traced_variables, $possible_traced_variable_names); } } }