Skip to content
Permalink
Browse files

Treat more things as assignments

  • Loading branch information
muglug committed Dec 7, 2019
1 parent f0cd7ea commit 2e00ad2240729bb5578f43413866a2245bd1820f
@@ -3171,6 +3171,10 @@ private static function coerceValueAfterGatekeeperArgument(
}
}

if ($context->inside_conditional) {
$context->assigned_var_ids[$var_id] = true;
}

if ($was_cloned) {
$context->removeVarFromConflictingClauses($var_id, null, $statements_analyzer);
}
@@ -886,6 +886,8 @@ public static function assignByRefParam(
}
}

$context->assigned_var_ids[$var_id] = true;

$context->vars_in_scope[$var_id] = $by_ref_out_type;

if (!($stmt_type = $statements_analyzer->node_data->getType($stmt)) || $stmt_type->isEmpty()) {
@@ -2110,6 +2110,50 @@ function foo(A $left, A $right) : void {
}
}'
],
'assertionAfterAssertionInsideBooleanNot' => [
'<?php
class A {}
function foo(?A $a) : void {
if (rand(0, 1) && !($a && rand(0, 1))) {
if ($a !== null) {}
}
}'
],
'assertionAfterAssertionInsideExpandedBooleanNot' => [
'<?php
class A {}
function bar(?A $a) : void {
if (rand(0, 1) && (!$a || rand(0, 1))) {
if ($a !== null) {}
}
}'
],
'byrefChangeNested' => [
'<?php
if (!preg_match("/hello/", "hello", $matches) || $matches[0] !== "hello") {}'
],
'checkBeforeUse' => [
'<?php
class A {
public function foo() : void {}
}
function takesA(A $a) : bool {
return true;
}
/**
* @param mixed $a
*/
function takesMaybeA($a) : void {
/**
* @psalm-suppress MixedArgument
*/
if ($a !== null && takesA($a)) {}
}'
],
];
}

0 comments on commit 2e00ad2

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