1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-15 19:07:00 +01:00
psalm/src/Psalm/Internal/Analyzer/Statements/Expression/EncapsulatedStringAnalyzer.php
2020-05-18 15:13:27 -04:00

32 lines
897 B
PHP

<?php
namespace Psalm\Internal\Analyzer\Statements\Expression;
use PhpParser;
use Psalm\Internal\Analyzer\Statements\ExpressionAnalyzer;
use Psalm\Internal\Analyzer\StatementsAnalyzer;
use Psalm\Context;
use Psalm\Type;
class EncapsulatedStringAnalyzer
{
public static function analyze(
StatementsAnalyzer $statements_analyzer,
PhpParser\Node\Scalar\Encapsed $stmt,
Context $context
) : bool {
foreach ($stmt->parts as $part) {
if (ExpressionAnalyzer::analyze($statements_analyzer, $part, $context) === false) {
return false;
}
if ($statements_analyzer->node_data->getType($part)) {
CastAnalyzer::castStringAttempt($statements_analyzer, $context, $part);
}
}
$statements_analyzer->node_data->setType($stmt, Type::getString());
return true;
}
}