Avoids use of (string) casts because of exceptions
See <https://bugs.php.net/bug.php?id=53648> for details