mirror of
https://github.com/danog/psalm.git
synced 2024-12-12 01:09:38 +01:00
allow arithmetics on variables as long as we're out of loops
This commit is contained in:
parent
012b65de78
commit
d3d11471b7
@ -311,8 +311,12 @@ class ArithmeticOpAnalyzer
|
||||
): ?Type\Union {
|
||||
if ($left_type_part instanceof TLiteralInt
|
||||
&& $right_type_part instanceof TLiteralInt
|
||||
&& !$left instanceof PhpParser\Node\Expr\Variable
|
||||
&& !$right instanceof PhpParser\Node\Expr\Variable
|
||||
&& (
|
||||
//we don't try to do arithmetics on variables in loops
|
||||
$context === null
|
||||
|| $context->inside_loop === false
|
||||
|| (!$left instanceof PhpParser\Node\Expr\Variable && !$right instanceof PhpParser\Node\Expr\Variable)
|
||||
)
|
||||
) {
|
||||
// time for some arithmetic!
|
||||
$calculated_type = self::arithmeticOperation(
|
||||
|
Loading…
Reference in New Issue
Block a user