Skip to content

Commit b09282f

Browse files
committed
Make sure conditional taints aren't registered directly
1 parent 1b20d9c commit b09282f

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

src/Psalm/Codebase.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,9 @@ public function getOrRegisterTaint(string $taint_type, ?CodeLocation $location =
365365
}
366366
throw new RuntimeException($err);
367367
}
368+
if ($taint_type[0] === '(') {
369+
throw new AssertionError('Conditional taints cannot be registered directly');
370+
}
368371
$id = 1 << ($this->taint_count++);
369372
$this->custom_taints[$id] = $taint_type;
370373
$this->taint_map[$taint_type] = $id;

src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeDocblockScanner.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ public static function addDocblockInfo(
369369

370370
foreach ($docblock_info->removed_taints as $removed_taint) {
371371
if ($removed_taint[0] === '(') {
372-
self::handleRemovedTaint(
372+
self::handleConditionallyRemovedTaint(
373373
$codebase,
374374
$stmt,
375375
$aliases,
@@ -1150,7 +1150,7 @@ private static function handleTaintFlow(
11501150
* @param array<string, non-empty-array<string, Union>> $function_template_types
11511151
* @param array<string, non-empty-array<string, Union>> $class_template_types
11521152
*/
1153-
private static function handleRemovedTaint(
1153+
private static function handleConditionallyRemovedTaint(
11541154
Codebase $codebase,
11551155
PhpParser\Node\FunctionLike $stmt,
11561156
Aliases $aliases,

0 commit comments

Comments
 (0)