Skip to content
Permalink
Browse files

Fix #2536 - grab binary op left assertions after analysis

  • Loading branch information
muglug committed Jan 1, 2020
1 parent 1b4bda4 commit 4021d673bd16965c8ef175a78babece80daf1e76
@@ -99,14 +99,6 @@ public static function analyze(
return null;
}

$left_clauses = Algebra::getFormula(
\spl_object_id($stmt->left),
$stmt->left,
$context->self,
$statements_analyzer,
$codebase
);

$pre_referenced_var_ids = $context->referenced_var_ids;

$pre_assigned_var_ids = $context->assigned_var_ids;
@@ -123,6 +115,14 @@ public static function analyze(
return false;
}

$left_clauses = Algebra::getFormula(
\spl_object_id($stmt->left),
$stmt->left,
$context->self,
$statements_analyzer,
$codebase
);

foreach ($left_context->vars_in_scope as $var_id => $type) {
if (isset($left_context->assigned_var_ids[$var_id])) {
$context->vars_in_scope[$var_id] = $type;
@@ -1813,6 +1813,7 @@ function assertArrayWithOffset($decoded): array {
],
'avoidOOM' => [
'<?php
/** @psalm-suppress MixedInferredReturnType */
function gameOver(
int $b0,
int $b1,
@@ -2470,6 +2471,18 @@ function f(Project $project): int {
return strlen($project->assessment->root);
}'
],
'castIsType' => [
'<?php
/**
* @param string|int $s
*/
function foo($s, int $f = 1) : void {
if ($f === 1
&& (string) $s === $s
&& \strpos($s, "foo") !== false
) {}
}'
],
];
}

0 comments on commit 4021d67

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