Skip to content

Commit

Permalink
Fix overwrite logic as $context->negate makes $context->false return …
Browse files Browse the repository at this point in the history
…false after
  • Loading branch information
Seldaek committed Nov 12, 2024
1 parent 55ce5e2 commit f126d9e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/PHPStan/PregMatchTypeSpecifyingExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ public function specifyTypes(MethodReflection $methodReflection, StaticCall $nod
$matchedType = PregMatchFlags::removeNullFromMatches($matchedType);
}

$overwrite = false;
if ($context->false()) {
$overwrite = true;
$context = $context->negate();
}

Expand All @@ -98,6 +100,6 @@ public function specifyTypes(MethodReflection $methodReflection, StaticCall $nod
$scope,
)->setRootExpr($node);

return $context->false() ? $typeSpecifier->setAlwaysOverwriteTypes() : $typeSpecifier;
return $overwrite ? $typeSpecifier->setAlwaysOverwriteTypes() : $typeSpecifier;
}
}
1 change: 0 additions & 1 deletion src/PcreException.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ private static function pcreLastErrorMessage($code)
return preg_last_error_msg();
}

/** @var array<string, array<string, int>> $constants */
$constants = get_defined_constants(true);
if (!isset($constants['pcre']) || !is_array($constants['pcre'])) {
return 'UNDEFINED_ERROR';
Expand Down

0 comments on commit f126d9e

Please sign in to comment.