Skip to content
Permalink
Browse files

Fix #1943 - give up analysing really complicated conditionals

  • Loading branch information
muglug committed Dec 5, 2019
1 parent b713066 commit 8ff33ee64d227b694935d845ef7892d0f140fbdf
Showing with 31 additions and 0 deletions.
  1. +4 −0 src/Psalm/Internal/Analyzer/Statements/Block/IfAnalyzer.php
  2. +27 −0 tests/AssertTest.php
@@ -110,6 +110,10 @@ public static function analyze(
$codebase
);

if (count($if_clauses) > 200) {
$if_clauses = [];
}

$if_clauses = array_values(
array_map(
/**
@@ -453,6 +453,33 @@ function assertArrayWithOffset($decoded): array {
return $decoded;
}'
],
'avoidOOM' => [
'<?php
function gameOver(
int $b0,
int $b1,
int $b2,
int $b3,
int $b4,
int $b5,
int $b6,
int $b7,
int $b8
): bool {
if (($b0 === 1 && $b4 === 1 && $b8 === 1)
|| ($b0 === 1 && $b1 === 1 && $b2 === 1)
|| ($b0 === 1 && $b3 === 1 && $b6 === 1)
|| ($b1 === 1 && $b4 === 1 && $b7 === 1)
|| ($b2 === 1 && $b5 === 1 && $b8 === 1)
|| ($b2 === 1 && $b4 === 1 && $b6 === 1)
|| ($b3 === 1 && $b4 === 1 && $b5 === 1)
|| ($b6 === 1 && $b7 === 1 && $b8 === 1)
) {
return true;
}
return false;
}'
],
];
}
}

0 comments on commit 8ff33ee

Please sign in to comment.
You can’t perform that action at this time.