Why this arbitrary restriction? A forced cast of a string to integer is always guaranteed to produce an integer.
https://www.php.net/manual/en/function.is-numeric.php
And, if you naïvely use the suggested function for the purpose you've suggested it for, e.g., like,
if(!is_numeric($input)) { error(); } else { return (int)$input; }
Why this arbitrary restriction? A forced cast of a string to integer is always guaranteed to produce an integer.