Skip to content

Commit

Permalink
Add separate checks for all polyfilled functions and constants
Browse files Browse the repository at this point in the history
  • Loading branch information
JanJakes committed Apr 30, 2020
1 parent 2f2cfc9 commit dbaa734
Show file tree
Hide file tree
Showing 11 changed files with 332 additions and 15 deletions.
37 changes: 34 additions & 3 deletions src/Apcu/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,56 @@
return;
}

if (!function_exists('apcu_add')) {
if (extension_loaded('Zend Data Cache')) {
if (extension_loaded('Zend Data Cache')) {
if (!function_exists('apcu_add')) {
function apcu_add($key, $var = null, $ttl = 0) { return p\Apcu::apcu_add($key, $var, $ttl); }
}
if (!function_exists('apcu_delete')) {
function apcu_delete($key) { return p\Apcu::apcu_delete($key); }
}
if (!function_exists('apcu_exists')) {
function apcu_exists($keys) { return p\Apcu::apcu_exists($keys); }
}
if (!function_exists('apcu_fetch')) {
function apcu_fetch($key, &$success = null) { return p\Apcu::apcu_fetch($key, $success); }
}
if (!function_exists('apcu_store')) {
function apcu_store($key, $var = null, $ttl = 0) { return p\Apcu::apcu_store($key, $var, $ttl); }
} else {
}
} else {
if (!function_exists('apcu_add')) {
function apcu_add($key, $var = null, $ttl = 0) { return apc_add($key, $var, $ttl); }
}
if (!function_exists('apcu_delete')) {
function apcu_delete($key) { return apc_delete($key); }
}
if (!function_exists('apcu_exists')) {
function apcu_exists($keys) { return apc_exists($keys); }
}
if (!function_exists('apcu_fetch')) {
function apcu_fetch($key, &$success = null) { return apc_fetch($key, $success); }
}
if (!function_exists('apcu_store')) {
function apcu_store($key, $var = null, $ttl = 0) { return apc_store($key, $var, $ttl); }
}
}

if (!function_exists('apcu_cache_info')) {
function apcu_cache_info($limited = false) { return apc_cache_info('user', $limited); }
}
if (!function_exists('apcu_cas')) {
function apcu_cas($key, $old, $new) { return apc_cas($key, $old, $new); }
}
if (!function_exists('apcu_clear_cache')) {
function apcu_clear_cache() { return apc_clear_cache('user'); }
}
if (!function_exists('apcu_dec')) {
function apcu_dec($key, $step = 1, &$success = false) { return apc_dec($key, $step, $success); }
}
if (!function_exists('apcu_inc')) {
function apcu_inc($key, $step = 1, &$success = false) { return apc_inc($key, $step, $success); }
}
if (!function_exists('apcu_sma_info')) {
function apcu_sma_info($limited = false) { return apc_sma_info($limited); }
}

Expand Down
20 changes: 20 additions & 0 deletions src/Ctype/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,34 @@

if (!function_exists('ctype_alnum')) {
function ctype_alnum($text) { return p\Ctype::ctype_alnum($text); }
}
if (!function_exists('ctype_alpha')) {
function ctype_alpha($text) { return p\Ctype::ctype_alpha($text); }
}
if (!function_exists('ctype_cntrl')) {
function ctype_cntrl($text) { return p\Ctype::ctype_cntrl($text); }
}
if (!function_exists('ctype_digit')) {
function ctype_digit($text) { return p\Ctype::ctype_digit($text); }
}
if (!function_exists('ctype_graph')) {
function ctype_graph($text) { return p\Ctype::ctype_graph($text); }
}
if (!function_exists('ctype_lower')) {
function ctype_lower($text) { return p\Ctype::ctype_lower($text); }
}
if (!function_exists('ctype_print')) {
function ctype_print($text) { return p\Ctype::ctype_print($text); }
}
if (!function_exists('ctype_punct')) {
function ctype_punct($text) { return p\Ctype::ctype_punct($text); }
}
if (!function_exists('ctype_space')) {
function ctype_space($text) { return p\Ctype::ctype_space($text); }
}
if (!function_exists('ctype_upper')) {
function ctype_upper($text) { return p\Ctype::ctype_upper($text); }
}
if (!function_exists('ctype_xdigit')) {
function ctype_xdigit($text) { return p\Ctype::ctype_xdigit($text); }
}
38 changes: 36 additions & 2 deletions src/Iconv/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,68 @@

if (!defined('ICONV_IMPL')) {
define('ICONV_IMPL', 'Symfony');
}
if (!defined('ICONV_VERSION')) {
define('ICONV_VERSION', '1.0');
}
if (!defined('ICONV_MIME_DECODE_STRICT')) {
define('ICONV_MIME_DECODE_STRICT', 1);
}
if (!defined('ICONV_MIME_DECODE_CONTINUE_ON_ERROR')) {
define('ICONV_MIME_DECODE_CONTINUE_ON_ERROR', 2);
}

if (!function_exists('iconv')) {
function iconv($from, $to, $s) { return p\Iconv::iconv($from, $to, $s); }
}
if (!function_exists('iconv_get_encoding')) {
function iconv_get_encoding($type = 'all') { return p\Iconv::iconv_get_encoding($type); }
}
if (!function_exists('iconv_set_encoding')) {
function iconv_set_encoding($type, $charset) { return p\Iconv::iconv_set_encoding($type, $charset); }
}
if (!function_exists('iconv_mime_encode')) {
function iconv_mime_encode($name, $value, $pref = null) { return p\Iconv::iconv_mime_encode($name, $value, $pref); }
}
if (!function_exists('iconv_mime_decode_headers')) {
function iconv_mime_decode_headers($encodedHeaders, $mode = 0, $enc = null) { return p\Iconv::iconv_mime_decode_headers($encodedHeaders, $mode, $enc); }
}

if (extension_loaded('mbstring')) {
if (extension_loaded('mbstring')) {
if (!function_exists('iconv_strlen')) {
function iconv_strlen($s, $enc = null) { null === $enc and $enc = p\Iconv::$internalEncoding; return mb_strlen($s, $enc); }
}
if (!function_exists('iconv_strpos')) {
function iconv_strpos($s, $needle, $offset = 0, $enc = null) { null === $enc and $enc = p\Iconv::$internalEncoding; return mb_strpos($s, $needle, $offset, $enc); }
}
if (!function_exists('iconv_strrpos')) {
function iconv_strrpos($s, $needle, $enc = null) { null === $enc and $enc = p\Iconv::$internalEncoding; return mb_strrpos($s, $needle, 0, $enc); }
}
if (!function_exists('iconv_substr')) {
function iconv_substr($s, $start, $length = 2147483647, $enc = null) { null === $enc and $enc = p\Iconv::$internalEncoding; return mb_substr($s, $start, $length, $enc); }
}
if (!function_exists('iconv_mime_decode')) {
function iconv_mime_decode($encodedHeaders, $mode = 0, $enc = null) { null === $enc and $enc = p\Iconv::$internalEncoding; return mb_decode_mimeheader($encodedHeaders, $mode, $enc); }
} else {
}
} else {
if (!function_exists('iconv_strlen')) {
if (extension_loaded('xml')) {
function iconv_strlen($s, $enc = null) { return p\Iconv::strlen1($s, $enc); }
} else {
function iconv_strlen($s, $enc = null) { return p\Iconv::strlen2($s, $enc); }
}
}

if (!function_exists('iconv_strpos')) {
function iconv_strpos($s, $needle, $offset = 0, $enc = null) { return p\Iconv::iconv_strpos($s, $needle, $offset, $enc); }
}
if (!function_exists('iconv_strrpos')) {
function iconv_strrpos($s, $needle, $enc = null) { return p\Iconv::iconv_strrpos($s, $needle, $enc); }
}
if (!function_exists('iconv_substr')) {
function iconv_substr($s, $start, $length = 2147483647, $enc = null) { return p\Iconv::iconv_substr($s, $start, $length, $enc); }
}
if (!function_exists('iconv_mime_decode')) {
function iconv_mime_decode($encodedHeaders, $mode = 0, $enc = null) { return p\Iconv::iconv_mime_decode($encodedHeaders, $mode, $enc); }
}
}
22 changes: 21 additions & 1 deletion src/Intl/Grapheme/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,38 @@

if (!defined('GRAPHEME_EXTR_COUNT')) {
define('GRAPHEME_EXTR_COUNT', 0);
}
if (!defined('GRAPHEME_EXTR_MAXBYTES')) {
define('GRAPHEME_EXTR_MAXBYTES', 1);
}
if (!defined('GRAPHEME_EXTR_MAXCHARS')) {
define('GRAPHEME_EXTR_MAXCHARS', 2);
}

if (!function_exists('grapheme_strlen')) {
if (!function_exists('grapheme_extract')) {
function grapheme_extract($s, $size, $type = 0, $start = 0, &$next = 0) { return p\Grapheme::grapheme_extract($s, $size, $type, $start, $next); }
}
if (!function_exists('grapheme_stripos')) {
function grapheme_stripos($s, $needle, $offset = 0) { return p\Grapheme::grapheme_stripos($s, $needle, $offset); }
}
if (!function_exists('grapheme_stristr')) {
function grapheme_stristr($s, $needle, $beforeNeedle = false) { return p\Grapheme::grapheme_stristr($s, $needle, $beforeNeedle); }
}
if (!function_exists('grapheme_strlen')) {
function grapheme_strlen($s) { return p\Grapheme::grapheme_strlen($s); }
}
if (!function_exists('grapheme_strpos')) {
function grapheme_strpos($s, $needle, $offset = 0) { return p\Grapheme::grapheme_strpos($s, $needle, $offset); }
}
if (!function_exists('grapheme_strripos')) {
function grapheme_strripos($s, $needle, $offset = 0) { return p\Grapheme::grapheme_strripos($s, $needle, $offset); }
}
if (!function_exists('grapheme_strrpos')) {
function grapheme_strrpos($s, $needle, $offset = 0) { return p\Grapheme::grapheme_strrpos($s, $needle, $offset); }
}
if (!function_exists('grapheme_strstr')) {
function grapheme_strstr($s, $needle, $beforeNeedle = false) { return p\Grapheme::grapheme_strstr($s, $needle, $beforeNeedle); }
}
if (!function_exists('grapheme_substr')) {
function grapheme_substr($s, $start, $len = 2147483647) { return p\Grapheme::grapheme_substr($s, $start, $len); }
}
6 changes: 6 additions & 0 deletions src/Intl/Icu/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@

if (!function_exists('intl_is_failure')) {
function intl_is_failure($errorCode) { return IntlGlobals::isFailure($errorCode); }
}
if (!function_exists('intl_get_error_code')) {
function intl_get_error_code() { return IntlGlobals::getErrorCode(); }
}
if (!function_exists('intl_get_error_message')) {
function intl_get_error_message() { return IntlGlobals::getErrorMessage(); }
}
if (!function_exists('intl_error_name')) {
function intl_error_name($errorCode) { return IntlGlobals::getErrorName($errorCode); }
}
85 changes: 81 additions & 4 deletions src/Intl/Idn/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,51 +11,128 @@

use Symfony\Polyfill\Intl\Idn as p;

if (!defined('IDNA_DEFAULT')) {
if (!defined('U_IDNA_PROHIBITED_ERROR')) {
define('U_IDNA_PROHIBITED_ERROR', 66560);
}
if (!defined('U_IDNA_ERROR_START')) {
define('U_IDNA_ERROR_START', 66560);
}
if (!defined('U_IDNA_UNASSIGNED_ERROR')) {
define('U_IDNA_UNASSIGNED_ERROR', 66561);
}
if (!defined('U_IDNA_CHECK_BIDI_ERROR')) {
define('U_IDNA_CHECK_BIDI_ERROR', 66562);
}
if (!defined('U_IDNA_STD3_ASCII_RULES_ERROR')) {
define('U_IDNA_STD3_ASCII_RULES_ERROR', 66563);
}
if (!defined('U_IDNA_ACE_PREFIX_ERROR')) {
define('U_IDNA_ACE_PREFIX_ERROR', 66564);
}
if (!defined('U_IDNA_VERIFICATION_ERROR')) {
define('U_IDNA_VERIFICATION_ERROR', 66565);
}
if (!defined('U_IDNA_LABEL_TOO_LONG_ERROR')) {
define('U_IDNA_LABEL_TOO_LONG_ERROR', 66566);
}
if (!defined('U_IDNA_ZERO_LENGTH_LABEL_ERROR')) {
define('U_IDNA_ZERO_LENGTH_LABEL_ERROR', 66567);
}
if (!defined('U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR')) {
define('U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR', 66568);
}
if (!defined('U_IDNA_ERROR_LIMIT')) {
define('U_IDNA_ERROR_LIMIT', 66569);
}
if (!defined('U_STRINGPREP_PROHIBITED_ERROR')) {
define('U_STRINGPREP_PROHIBITED_ERROR', 66560);
}
if (!defined('U_STRINGPREP_UNASSIGNED_ERROR')) {
define('U_STRINGPREP_UNASSIGNED_ERROR', 66561);
}
if (!defined('U_STRINGPREP_CHECK_BIDI_ERROR')) {
define('U_STRINGPREP_CHECK_BIDI_ERROR', 66562);
}
if (!defined('IDNA_DEFAULT')) {
define('IDNA_DEFAULT', 0);
}
if (!defined('IDNA_ALLOW_UNASSIGNED')) {
define('IDNA_ALLOW_UNASSIGNED', 1);
}
if (!defined('IDNA_USE_STD3_RULES')) {
define('IDNA_USE_STD3_RULES', 2);
}
if (!defined('IDNA_CHECK_BIDI')) {
define('IDNA_CHECK_BIDI', 4);
}
if (!defined('IDNA_CHECK_CONTEXTJ')) {
define('IDNA_CHECK_CONTEXTJ', 8);
}
if (!defined('IDNA_NONTRANSITIONAL_TO_ASCII')) {
define('IDNA_NONTRANSITIONAL_TO_ASCII', 16);
}
if (!defined('IDNA_NONTRANSITIONAL_TO_UNICODE')) {
define('IDNA_NONTRANSITIONAL_TO_UNICODE', 32);
}
if (!defined('INTL_IDNA_VARIANT_2003')) {
define('INTL_IDNA_VARIANT_2003', 0);
}
if (!defined('INTL_IDNA_VARIANT_UTS46')) {
define('INTL_IDNA_VARIANT_UTS46', 1);
}
if (!defined('IDNA_ERROR_EMPTY_LABEL')) {
define('IDNA_ERROR_EMPTY_LABEL', 1);
}
if (!defined('IDNA_ERROR_LABEL_TOO_LONG')) {
define('IDNA_ERROR_LABEL_TOO_LONG', 2);
}
if (!defined('IDNA_ERROR_DOMAIN_NAME_TOO_LONG')) {
define('IDNA_ERROR_DOMAIN_NAME_TOO_LONG', 4);
}
if (!defined('IDNA_ERROR_LEADING_HYPHEN')) {
define('IDNA_ERROR_LEADING_HYPHEN', 8);
}
if (!defined('IDNA_ERROR_TRAILING_HYPHEN')) {
define('IDNA_ERROR_TRAILING_HYPHEN', 16);
}
if (!defined('IDNA_ERROR_HYPHEN_3_4')) {
define('IDNA_ERROR_HYPHEN_3_4', 32);
}
if (!defined('IDNA_ERROR_LEADING_COMBINING_MARK')) {
define('IDNA_ERROR_LEADING_COMBINING_MARK', 64);
}
if (!defined('IDNA_ERROR_DISALLOWED')) {
define('IDNA_ERROR_DISALLOWED', 128);
}
if (!defined('IDNA_ERROR_PUNYCODE')) {
define('IDNA_ERROR_PUNYCODE', 256);
}
if (!defined('IDNA_ERROR_LABEL_HAS_DOT')) {
define('IDNA_ERROR_LABEL_HAS_DOT', 512);
}
if (!defined('IDNA_ERROR_INVALID_ACE_LABEL')) {
define('IDNA_ERROR_INVALID_ACE_LABEL', 1024);
}
if (!defined('IDNA_ERROR_BIDI')) {
define('IDNA_ERROR_BIDI', 2048);
}
if (!defined('IDNA_ERROR_CONTEXTJ')) {
define('IDNA_ERROR_CONTEXTJ', 4096);
}

if (!function_exists('idn_to_ascii')) {
if (PHP_VERSION_ID < 70400) {

if (PHP_VERSION_ID < 70400) {
if (!function_exists('idn_to_ascii')) {
function idn_to_ascii($domain, $options = IDNA_DEFAULT, $variant = INTL_IDNA_VARIANT_2003, &$idna_info = array()) { return p\Idn::idn_to_ascii($domain, $options, $variant, $idna_info); }
}
if (!function_exists('idn_to_utf8')) {
function idn_to_utf8($domain, $options = IDNA_DEFAULT, $variant = INTL_IDNA_VARIANT_2003, &$idna_info = array()) { return p\Idn::idn_to_utf8($domain, $options, $variant, $idna_info); }
} else {
}
} else {
if (!function_exists('idn_to_ascii')) {
function idn_to_ascii($domain, $options = IDNA_DEFAULT, $variant = INTL_IDNA_VARIANT_UTS46, &$idna_info = array()) { return p\Idn::idn_to_ascii($domain, $options, $variant, $idna_info); }
}
if (!function_exists('idn_to_utf8')) {
function idn_to_utf8($domain, $options = IDNA_DEFAULT, $variant = INTL_IDNA_VARIANT_UTS46, &$idna_info = array()) { return p\Idn::idn_to_utf8($domain, $options, $variant, $idna_info); }
}
}
2 changes: 2 additions & 0 deletions src/Intl/Normalizer/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@

if (!function_exists('normalizer_is_normalized')) {
function normalizer_is_normalized($s, $form = p\Normalizer::NFC) { return p\Normalizer::isNormalized($s, $form); }
}
if (!function_exists('normalizer_normalize')) {
function normalizer_normalize($s, $form = p\Normalizer::NFC) { return p\Normalizer::normalize($s, $form); }
}
Loading

0 comments on commit dbaa734

Please sign in to comment.