1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 04:45:20 +01:00

Add new array creation test with hard-to-key offsets

This commit is contained in:
Matt Brown 2018-05-07 14:34:25 -04:00
parent 61aeea6375
commit 9d901db740

View File

@ -312,6 +312,20 @@ class TypeAlgebraTest extends TestCase
}
}',
],
'issetArrayCreation' => [
'<?php
$arr = [];
foreach ([0, 1, 2, 3] as $i) {
$a = rand(0, 1) ? 5 : "010";
if (!isset($arr[(int) $a])) {
$arr[(int) $a] = 5;
} else {
$arr[(int) $a] += 4;
}
}',
],
'noParadoxInLoop' => [
'<?php
function paradox2(): void {
@ -885,7 +899,7 @@ class TypeAlgebraTest extends TestCase
}
}',
'error_message' => 'ParadoxicalCondition',
'error_message' => 'TypeDoesNotContainType',
],
'repeatedConditionals' => [
'<?php
@ -896,7 +910,7 @@ class TypeAlgebraTest extends TestCase
// can never get here
}
}',
'error_message' => 'ParadoxicalCondition',
'error_message' => 'TypeDoesNotContainType',
],
'repeatedAndConditional' => [
'<?php
@ -918,7 +932,7 @@ class TypeAlgebraTest extends TestCase
echo "b";
}
}',
'error_message' => 'ParadoxicalCondition',
'error_message' => 'TypeDoesNotContainType',
],
'repeatedVarFromOrConditional' => [
'<?php
@ -929,7 +943,7 @@ class TypeAlgebraTest extends TestCase
echo "b";
}
}',
'error_message' => 'ParadoxicalCondition',
'error_message' => 'TypeDoesNotContainType',
],
'typeDoesntEqualType' => [
'<?php