Safe casting functions

https://wiki.php.net/rfc/safe_cast