toContain('$port = (int) $port;'); // non-numeric ports fall back to the default rather than passing through expect($body)->toContain('empty($port) || !is_numeric($port)'); }); test('the ext-based session target also casts the port', function () use ($src) { expect($src)->toContain("':' . (is_numeric(\$port) ? (int) \$port : 161)"); }); test('the cast neutralises a metacharacter-bearing port value', function () { // model of the sanitizer's port handling $normalize = static fn ($port) => (empty($port) || !is_numeric($port)) ? 161 : (int) $port; expect($normalize('161; rm -rf /'))->toBe(161); expect($normalize('161 -c public'))->toBe(161); expect($normalize(''))->toBe(161); expect($normalize('1611'))->toBe(1611); expect($normalize(162))->toBe(162); });