Files
pterodactyl-panel/tools/phpstan/rules/tests/Rules/data/require-safety-comment.php
T
6c0413e39b Start 2.0 development
Co-authored-by: Anthony <anthony@infraly.co>
Co-authored-by: Sky Mulley <daniel.mulley@outlook.com>
2026-10-05 18:10:18 -04:00

36 lines
886 B
PHP

<?php
declare(strict_types=1);
namespace Rules\Tests\Data\RequireSafetyComment;
use Webmozart\Assert\Assert;
/**
* @param array{id: string} $payload
*/
function handle(array $payload, string $raw, object $thing): int
{
$bare = (int) $raw; // error: line 14
// SAFETY: The regex above guarantees a digit-only string.
$justified = (int) $raw;
/** @var positive-int $count */
$count = $bare; // error: line 19 (inline @var, no SAFETY)
/** @var positive-int $total SAFETY: validated by the request rules. */
$total = $justified;
assert(is_string($payload['id'])); // error: line 25
// SAFETY: only string ids reach this branch.
assert(is_string($payload['id']));
Assert::isInstanceOf($thing, \DateTimeImmutable::class); // error: line 30
$sum = $count + $total;
return $sum + (int) $bare; // dead cast on int: not flagged
}