diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/EncapsulatedStringAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/EncapsulatedStringAnalyzer.php index 563d58b1a58..63c815ff521 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/EncapsulatedStringAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/EncapsulatedStringAnalyzer.php @@ -46,9 +46,12 @@ public static function analyze( return false; } - $part_type = $statements_analyzer->node_data->getType($part); - - if ($part_type !== null) { + if ($part instanceof EncapsedStringPart) { + if ($literal_string !== null) { + $literal_string .= $part->value; + } + $non_empty = $non_empty || $part->value !== ""; + } elseif ($part_type = $statements_analyzer->node_data->getType($part)) { $casted_part_type = CastAnalyzer::castStringAttempt( $statements_analyzer, $context, @@ -110,11 +113,6 @@ public static function analyze( } } } - } elseif ($part instanceof EncapsedStringPart) { - if ($literal_string !== null) { - $literal_string .= $part->value; - } - $non_empty = $non_empty || $part->value !== ""; } else { $all_literals = false; $literal_string = null;