diff options
author | Scott <scott@paragonie.com> | 2016-10-17 10:45:38 -0400 |
---|---|---|
committer | Scott <scott@paragonie.com> | 2016-10-17 10:45:38 -0400 |
commit | a602dde8d96888f408e60d20c8b2930ec5d77bed (patch) | |
tree | 812859110e765df9043ef42437ded68a854c4521 | |
parent | 29f512b9945cdb6147718d1fc61e30cf5b4c642a (diff) | |
download | random_compat-a602dde8d96888f408e60d20c8b2930ec5d77bed.zip random_compat-a602dde8d96888f408e60d20c8b2930ec5d77bed.tar.gz random_compat-a602dde8d96888f408e60d20c8b2930ec5d77bed.tar.bz2 |
Use is_callable() everywhere
-rw-r--r-- | lib/byte_safe_strings.php | 4 | ||||
-rw-r--r-- | lib/cast_to_int.php | 2 | ||||
-rw-r--r-- | lib/random.php | 14 | ||||
-rw-r--r-- | lib/random_bytes_dev_urandom.php | 4 |
4 files changed, 12 insertions, 12 deletions
diff --git a/lib/byte_safe_strings.php b/lib/byte_safe_strings.php index 8a24e2c..dd03690 100644 --- a/lib/byte_safe_strings.php +++ b/lib/byte_safe_strings.php @@ -26,7 +26,7 @@ * SOFTWARE. */ -if (!function_exists('RandomCompat_strlen')) { +if (!is_callable('RandomCompat_strlen')) { if ( defined('MB_OVERLOAD_STRING') && ini_get('mbstring.func_overload') & MB_OVERLOAD_STRING @@ -78,7 +78,7 @@ if (!function_exists('RandomCompat_strlen')) { } } -if (!function_exists('RandomCompat_substr')) { +if (!is_callable('RandomCompat_substr')) { if ( defined('MB_OVERLOAD_STRING') diff --git a/lib/cast_to_int.php b/lib/cast_to_int.php index 6427bb2..65e9d21 100644 --- a/lib/cast_to_int.php +++ b/lib/cast_to_int.php @@ -26,7 +26,7 @@ * SOFTWARE. */ -if (!function_exists('RandomCompat_intval')) { +if (!is_callable('RandomCompat_intval')) { /** * Cast to an integer if we can, safely. diff --git a/lib/random.php b/lib/random.php index 7171460..c3dacb7 100644 --- a/lib/random.php +++ b/lib/random.php @@ -53,7 +53,7 @@ if (PHP_VERSION_ID < 70000) { require_once $RandomCompatDIR.'/cast_to_int.php'; require_once $RandomCompatDIR.'/error_polyfill.php'; - if (!function_exists('random_bytes')) { + if (!is_callable('random_bytes')) { /** * PHP 5.2.0 - 5.6.x way to implement random_bytes() * @@ -71,7 +71,7 @@ if (PHP_VERSION_ID < 70000) { */ if (extension_loaded('libsodium')) { // See random_bytes_libsodium.php - if (PHP_VERSION_ID >= 50300 && function_exists('\\Sodium\\randombytes_buf')) { + if (PHP_VERSION_ID >= 50300 && is_callable('\\Sodium\\randombytes_buf')) { require_once $RandomCompatDIR.'/random_bytes_libsodium.php'; } elseif (method_exists('Sodium', 'randombytes_buf')) { require_once $RandomCompatDIR.'/random_bytes_libsodium_legacy.php'; @@ -100,7 +100,7 @@ if (PHP_VERSION_ID < 70000) { } if ( - !function_exists('random_bytes') + !is_callable('random_bytes') && $RandomCompatUrandom && @@ -125,7 +125,7 @@ if (PHP_VERSION_ID < 70000) { * mcrypt_create_iv() */ if ( - !function_exists('random_bytes') + !is_callable('random_bytes') && PHP_VERSION_ID >= 50307 && @@ -146,7 +146,7 @@ if (PHP_VERSION_ID < 70000) { $RandomCompatUrandom = null; if ( - !function_exists('random_bytes') + !is_callable('random_bytes') && extension_loaded('com_dotnet') && @@ -175,7 +175,7 @@ if (PHP_VERSION_ID < 70000) { /** * throw new Exception */ - if (!function_exists('random_bytes')) { + if (!is_callable('random_bytes')) { /** * We don't have any more options, so let's throw an exception right now * and hope the developer won't let it fail silently. @@ -189,7 +189,7 @@ if (PHP_VERSION_ID < 70000) { } } - if (!function_exists('random_int')) { + if (!is_callable('random_int')) { require_once $RandomCompatDIR.'/random_int.php'; } diff --git a/lib/random_bytes_dev_urandom.php b/lib/random_bytes_dev_urandom.php index 144f7ab..a0d9b42 100644 --- a/lib/random_bytes_dev_urandom.php +++ b/lib/random_bytes_dev_urandom.php @@ -72,10 +72,10 @@ function random_bytes($bytes) * * stream_set_read_buffer returns 0 on success */ - if (function_exists('stream_set_read_buffer')) { + if (is_callable('stream_set_read_buffer')) { stream_set_read_buffer($fp, RANDOM_COMPAT_READ_BUFFER); } - if (function_exists('stream_set_chunk_size')) { + if (is_callable('stream_set_chunk_size')) { stream_set_chunk_size($fp, RANDOM_COMPAT_READ_BUFFER); } } |