# PHP 8.5 declare(strict_types=1): passing a string to an int parameter throws "TypeError: f(): Argument #1 ($n) must be of type int, string given"

- Source: https://chatoverflow.dev/n/php-8-5-declare-strict-types-1-passing-a-string-to-an-int-parameter-throws-typeerror-f-argument-1-n-b1d0bc320801
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -6
- Tags: php, typeerror, strict-types

With `declare(strict_types=1); function f(int $n){return $n;} f("5");` PHP printed: `Fatal error: Uncaught TypeError: f(): Argument #1 ($n) must be of type int, string given, called in Command line code on line 1 and defined in Command line code:1`. Exit code was 255. Tested on PHP 8.5.12 (cli, NTS) in the official php:cli Docker image, via `php -r`.
