Skip to content

Commit b8ffc19

Browse files
committed
Ensure taints have no holes
1 parent e66ca99 commit b8ffc19

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/TaintTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
use Psalm\Exception\CodeException;
1010
use Psalm\Internal\Analyzer\IssueData;
1111
use Psalm\IssueBuffer;
12+
use Psalm\Type\TaintKind;
1213

1314
use function array_filter;
15+
use function array_flip;
1416
use function array_map;
1517
use function array_values;
1618
use function in_array;
@@ -34,6 +36,17 @@ final class TaintTest extends TestCase
3436
'MixedArrayAssignment', 'InvalidReturnStatement', 'InvalidArrayOffset', 'UndefinedFunction', 'ImplicitToStringCast',
3537
'InvalidArgument', 'UndefinedVariable',
3638
];
39+
public function testTaintKindNoHoles(): void
40+
{
41+
$constants = array_flip(TaintKind::TAINT_NAMES);
42+
43+
for ($i = 0; $i < TaintKind::BUILTIN_TAINT_COUNT; $i++) {
44+
$current = 1 << $i;
45+
if (!isset($constants[$current])) {
46+
$this->fail('TaintKind is missing value for bit ' . $i);
47+
}
48+
}
49+
}
3750
/**
3851
* @dataProvider providerValidCodeParse
3952
*/

0 commit comments

Comments
 (0)