mirror of
https://github.com/danog/psalm.git
synced 2024-12-03 10:07:52 +01:00
Don’t overwrite true flag
This commit is contained in:
parent
3cab29ec4e
commit
481cf84b94
@ -1180,7 +1180,7 @@ class ArgumentAnalyzer
|
|||||||
$input_type->by_ref = $by_ref;
|
$input_type->by_ref = $by_ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($context->inside_conditional) {
|
if ($context->inside_conditional && !isset($context->assigned_var_ids[$var_id])) {
|
||||||
$context->assigned_var_ids[$var_id] = false;
|
$context->assigned_var_ids[$var_id] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1902,6 +1902,33 @@ class ConditionalTest extends \Psalm\Tests\TestCase
|
|||||||
return $value;
|
return $value;
|
||||||
}'
|
}'
|
||||||
],
|
],
|
||||||
|
'assertVarRedefinedInIfWithOrAndConversion' => [
|
||||||
|
'<?php
|
||||||
|
interface Convertor {
|
||||||
|
function maybeConvert(string $value): ?SomeObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface SomeObject
|
||||||
|
{
|
||||||
|
function isValid(): bool;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mixed $value
|
||||||
|
*/
|
||||||
|
function exampleWithOr(Convertor $convertor, $value): SomeObject
|
||||||
|
{
|
||||||
|
if (
|
||||||
|
!\is_string($value)
|
||||||
|
|| ($value = $convertor->maybeConvert($value)) === null
|
||||||
|
|| !$value->isValid()
|
||||||
|
) {
|
||||||
|
throw new Exception();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $value;
|
||||||
|
}'
|
||||||
|
],
|
||||||
'assertVarRedefinedInIfWithExtraIf' => [
|
'assertVarRedefinedInIfWithExtraIf' => [
|
||||||
'<?php
|
'<?php
|
||||||
class O {}
|
class O {}
|
||||||
|
Loading…
Reference in New Issue
Block a user