Skip to content

Commit

Permalink
MutatingScope::debug()` - add info about conditional expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Nov 3, 2023
1 parent d63e030 commit 80782fb
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/Analyser/MutatingScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
use function array_merge;
use function array_pop;
use function array_slice;
use function array_values;
use function count;
use function explode;
use function get_class;
Expand Down Expand Up @@ -4824,6 +4825,24 @@ public function debug(): array
$descriptions[$key] = $nativeTypeHolder->getType()->describe(VerbosityLevel::precise());
}

foreach ($this->conditionalExpressions as $exprString => $holders) {
foreach (array_values($holders) as $i => $holder) {
$key = sprintf('condition about %s #%d', $exprString, $i + 1);
$parts = [];
foreach ($holder->getConditionExpressionTypeHolders() as $conditionalExprString => $expressionTypeHolder) {
$parts[] = $conditionalExprString . '=' . $expressionTypeHolder->getType()->describe(VerbosityLevel::precise());
}
$condition = implode(' && ', $parts);
$descriptions[$key] = sprintf(
'if %s then %s is %s (%s)',
$condition,
$exprString,
$holder->getTypeHolder()->getType()->describe(VerbosityLevel::precise()),
$holder->getTypeHolder()->getCertainty()->describe(),
);
}
}

return $descriptions;
}

Expand Down

0 comments on commit 80782fb

Please sign in to comment.