<?php declare(strict_types=1); function increment(int $x): int { return $x + 1; } echo increment('1'); // 2
Standard input is empty
Standard output is empty
PHP Fatal error: Uncaught TypeError: Argument 1 passed to increment() must be of the type integer, string given, called in /home/cEDQIM/prog.php on line 10 and defined in /home/cEDQIM/prog.php:5
Stack trace:
#0 /home/cEDQIM/prog.php(10): increment('1')
#1 {main}
thrown in /home/cEDQIM/prog.php on line 5