From 80782fb84dcb3d1cff7777da10d957117aa85299 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Thu, 2 Nov 2023 17:32:33 +0100 Subject: [PATCH] MutatingScope::debug()` - add info about conditional expressions --- src/Analyser/MutatingScope.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/Analyser/MutatingScope.php b/src/Analyser/MutatingScope.php index 653fbe732d..c5ddd96917 100644 --- a/src/Analyser/MutatingScope.php +++ b/src/Analyser/MutatingScope.php @@ -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; @@ -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; }