Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always accept null values on PHP 8 #330

Merged
merged 1 commit into from
Feb 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 1.22.1

* always accept null values on PHP 8, as native functions do

# 1.22.0

* added PHP 8.1 polyfill
Expand Down
8 changes: 4 additions & 4 deletions src/Apcu/bootstrap80.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

if (extension_loaded('Zend Data Cache')) {
if (!function_exists('apcu_add')) {
function apcu_add($key, mixed $value, int $ttl = 0): array|bool { return p\Apcu::apcu_add($key, $value, $ttl); }
function apcu_add($key, mixed $value, ?int $ttl = 0): array|bool { return p\Apcu::apcu_add($key, $value, (int) $ttl); }
}
if (!function_exists('apcu_delete')) {
function apcu_delete($key): array|bool { return p\Apcu::apcu_delete($key); }
Expand All @@ -25,11 +25,11 @@ function apcu_exists($key): array|bool { return p\Apcu::apcu_exists($key); }
function apcu_fetch($key, &$success = null): mixed { return p\Apcu::apcu_fetch($key, $success); }
}
if (!function_exists('apcu_store')) {
function apcu_store($key, mixed $value, int $ttl = 0): array|bool { return p\Apcu::apcu_store($key, $value, $ttl); }
function apcu_store($key, mixed $value, ?int $ttl = 0): array|bool { return p\Apcu::apcu_store($key, $value, (int) $ttl); }
}
} else {
if (!function_exists('apcu_add')) {
function apcu_add($key, mixed $value, int $ttl = 0): array|bool { return apc_add($key, $value, $ttl); }
function apcu_add($key, mixed $value, ?int $ttl = 0): array|bool { return apc_add($key, $value, (int) $ttl); }
}
if (!function_exists('apcu_delete')) {
function apcu_delete($key): array|bool { return apc_delete($key); }
Expand All @@ -41,7 +41,7 @@ function apcu_exists($key): array|bool { return apc_exists($key); }
function apcu_fetch($key, &$success = null) { return apc_fetch($key, $success); }
}
if (!function_exists('apcu_store')) {
function apcu_store($key, mixed $value, int $ttl = 0): array|bool { return apc_store($key, $value, $ttl); }
function apcu_store($key, mixed $value, ?int $ttl = 0): array|bool { return apc_store($key, $value, (int) $ttl); }
}
}

Expand Down
30 changes: 15 additions & 15 deletions src/Iconv/bootstrap80.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,56 +25,56 @@
}

if (!function_exists('iconv')) {
function iconv(string $from_encoding, string $to_encoding, string $string): string|false { return p\Iconv::iconv($from_encoding, $to_encoding, $string); }
function iconv(?string $from_encoding, ?string $to_encoding, ?string $string): string|false { return p\Iconv::iconv((string) $from_encoding, (string) $to_encoding, (string) $string); }
}
if (!function_exists('iconv_get_encoding')) {
function iconv_get_encoding(string $type = 'all'): array|string|false { return p\Iconv::iconv_get_encoding($type); }
function iconv_get_encoding(?string $type = 'all'): array|string|false { return p\Iconv::iconv_get_encoding((string) $type); }
}
if (!function_exists('iconv_set_encoding')) {
function iconv_set_encoding(string $type, string $encoding): bool { return p\Iconv::iconv_set_encoding($type, $encoding); }
function iconv_set_encoding(?string $type, ?string $encoding): bool { return p\Iconv::iconv_set_encoding((string) $type, (string) $encoding); }
}
if (!function_exists('iconv_mime_encode')) {
function iconv_mime_encode(string $field_name, string $field_value, array $options = []): string|false { return p\Iconv::iconv_mime_encode($field_name, $field_value, $options); }
function iconv_mime_encode(?string $field_name, ?string $field_value, ?array $options = []): string|false { return p\Iconv::iconv_mime_encode((string) $field_name, (string) $field_value, (array) $options); }
}
if (!function_exists('iconv_mime_decode_headers')) {
function iconv_mime_decode_headers(string $headers, int $mode = 0, string $encoding = null): array|false { return p\Iconv::iconv_mime_decode_headers($headers, $mode, $encoding); }
function iconv_mime_decode_headers(?string $headers, ?int $mode = 0, ?string $encoding = null): array|false { return p\Iconv::iconv_mime_decode_headers((string) $headers, (int) $mode, $encoding); }
}

if (extension_loaded('mbstring')) {
if (!function_exists('iconv_strlen')) {
function iconv_strlen(string $string, string $encoding = null): int|false { null === $encoding && $encoding = p\Iconv::$internalEncoding; return mb_strlen($string, $encoding); }
function iconv_strlen(?string $string, ?string $encoding = null): int|false { null === $encoding && $encoding = p\Iconv::$internalEncoding; return mb_strlen((string) $string, $encoding); }
}
if (!function_exists('iconv_strpos')) {
function iconv_strpos(string $haystack, string $needle, int $offset = 0, string $encoding = null): int|false { null === $encoding && $encoding = p\Iconv::$internalEncoding; return mb_strpos($haystack, $needle, $offset, $encoding); }
function iconv_strpos(?string $haystack, ?string $needle, ?int $offset = 0, ?string $encoding = null): int|false { null === $encoding && $encoding = p\Iconv::$internalEncoding; return mb_strpos((string) $haystack, (string) $needle, (int) $offset, $encoding); }
}
if (!function_exists('iconv_strrpos')) {
function iconv_strrpos(string $haystack, string $needle, string $encoding = null): int|false { null === $encoding && $encoding = p\Iconv::$internalEncoding; return mb_strrpos($haystack, $needle, 0, $encoding); }
function iconv_strrpos(?string $haystack, ?string $needle, ?string $encoding = null): int|false { null === $encoding && $encoding = p\Iconv::$internalEncoding; return mb_strrpos((string) $haystack, (string) $needle, 0, $encoding); }
}
if (!function_exists('iconv_substr')) {
function iconv_substr(string $string, int $offset, int $length = null, string $encoding = null): string|false { null === $encoding && $encoding = p\Iconv::$internalEncoding; return mb_substr($string, $offset, $length, $encoding); }
function iconv_substr(?string $string, ?int $offset, ?int $length = null, ?string $encoding = null): string|false { null === $encoding && $encoding = p\Iconv::$internalEncoding; return mb_substr((string) $string, (int) $offset, (int) $length, $encoding); }
}
if (!function_exists('iconv_mime_decode')) {
function iconv_mime_decode($string, $mode = 0, $encoding = null) { null === $encoding && $encoding = p\Iconv::$internalEncoding; return mb_decode_mimeheader($string, $mode, $encoding); }
}
} else {
if (!function_exists('iconv_strlen')) {
if (extension_loaded('xml')) {
function iconv_strlen(string $string, string $encoding = null): int|false { return p\Iconv::strlen1($string, $encoding); }
function iconv_strlen(?string $string, ?string $encoding = null): int|false { return p\Iconv::strlen1((string) $string, $encoding); }
} else {
function iconv_strlen(string $string, string $encoding = null): int|false { return p\Iconv::strlen2($string, $encoding); }
function iconv_strlen(?string $string, ?string $encoding = null): int|false { return p\Iconv::strlen2((string) $string, $encoding); }
}
}

if (!function_exists('iconv_strpos')) {
function iconv_strpos(string $haystack, string $needle, int $offset = 0, string $encoding = null): int|false { return p\Iconv::iconv_strpos($haystack, $needle, $offset, $encoding); }
function iconv_strpos(?string $haystack, ?string $needle, ?int $offset = 0, ?string $encoding = null): int|false { return p\Iconv::iconv_strpos((string) $haystack, (string) $needle, (int) $offset, $encoding); }
}
if (!function_exists('iconv_strrpos')) {
function iconv_strrpos(string $haystack, string $needle, string $encoding = null): int|false { return p\Iconv::iconv_strrpos($haystack, $needle, $encoding); }
function iconv_strrpos(?string $haystack, ?string $needle, ?string $encoding = null): int|false { return p\Iconv::iconv_strrpos((string) $haystack, (string) $needle, $encoding); }
}
if (!function_exists('iconv_substr')) {
function iconv_substr(string $string, int $offset, int $length = null, string $encoding = null): string|false { return p\Iconv::iconv_substr($string, $offset, $length, $encoding); }
function iconv_substr(?string $string, ?int $offset, ?int $length = null, ?string $encoding = null): string|false { return p\Iconv::iconv_substr((string) $string, (string) $offset, (int) $length, $encoding); }
}
if (!function_exists('iconv_mime_decode')) {
function iconv_mime_decode(string $string, int $mode = 0, string $encoding = null): string|false { return p\Iconv::iconv_mime_decode($string, $mode, $encoding); }
function iconv_mime_decode(?string $string, ?int $mode = 0, ?string $encoding = null): string|false { return p\Iconv::iconv_mime_decode((string) $string, (int) $mode, $encoding); }
}
}
18 changes: 9 additions & 9 deletions src/Intl/Grapheme/bootstrap80.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,29 @@
}

if (!function_exists('grapheme_extract')) {
function grapheme_extract(string $haystack, int $size, int $type = GRAPHEME_EXTR_COUNT, int $offset = 0, &$next = null): string|false { return p\Grapheme::grapheme_extract($haystack, $size, $type, $offset, $next); }
function grapheme_extract(?string $haystack, ?int $size, ?int $type = GRAPHEME_EXTR_COUNT, ?int $offset = 0, &$next = null): string|false { return p\Grapheme::grapheme_extract((string) $haystack, (int) $size, (int) $type, (int) $offset, $next); }
}
if (!function_exists('grapheme_stripos')) {
function grapheme_stripos(string $haystack, string $needle, int $offset = 0): int|false { return p\Grapheme::grapheme_stripos($haystack, $needle, $offset); }
function grapheme_stripos(?string $haystack, ?string $needle, ?int $offset = 0): int|false { return p\Grapheme::grapheme_stripos((string) $haystack, (string) $needle, (int) $offset); }
}
if (!function_exists('grapheme_stristr')) {
function grapheme_stristr(string $haystack, string $needle, bool $beforeNeedle = false): string|false { return p\Grapheme::grapheme_stristr($haystack, $needle, $beforeNeedle); }
function grapheme_stristr(?string $haystack, ?string $needle, ?bool $beforeNeedle = false): string|false { return p\Grapheme::grapheme_stristr((string) $haystack, (string) $needle, (bool) $beforeNeedle); }
}
if (!function_exists('grapheme_strlen')) {
function grapheme_strlen(string $string): int|false|null { return p\Grapheme::grapheme_strlen($string); }
function grapheme_strlen(?string $string): int|false|null { return p\Grapheme::grapheme_strlen((string) $string); }
}
if (!function_exists('grapheme_strpos')) {
function grapheme_strpos(string $haystack, string $needle, int $offset = 0): int|false { return p\Grapheme::grapheme_strpos($haystack, $needle, $offset); }
function grapheme_strpos(?string $haystack, ?string $needle, ?int $offset = 0): int|false { return p\Grapheme::grapheme_strpos((string) $haystack, (string) $needle, (int) $offset); }
}
if (!function_exists('grapheme_strripos')) {
function grapheme_strripos(string $haystack, string $needle, int $offset = 0): int|false { return p\Grapheme::grapheme_strripos($haystack, $needle, $offset); }
function grapheme_strripos(?string $haystack, ?string $needle, ?int $offset = 0): int|false { return p\Grapheme::grapheme_strripos((string) $haystack, (string) $needle, (int) $offset); }
}
if (!function_exists('grapheme_strrpos')) {
function grapheme_strrpos(string $haystack, string $needle, int $offset = 0): int|false { return p\Grapheme::grapheme_strrpos($haystack, $needle, $offset); }
function grapheme_strrpos(?string $haystack, ?string $needle, ?int $offset = 0): int|false { return p\Grapheme::grapheme_strrpos((string) $haystack, (string) $needle, (int) $offset); }
}
if (!function_exists('grapheme_strstr')) {
function grapheme_strstr(string $haystack, string $needle, bool $beforeNeedle = false): string|false { return p\Grapheme::grapheme_strstr($haystack, $needle, $beforeNeedle); }
function grapheme_strstr(?string $haystack, ?string $needle, ?bool $beforeNeedle = false): string|false { return p\Grapheme::grapheme_strstr((string) $haystack, (string) $needle, (bool) $beforeNeedle); }
}
if (!function_exists('grapheme_substr')) {
function grapheme_substr(string $string, int $offset, int $length = null): string|false { return p\Grapheme::grapheme_substr($string, $offset, $length); }
function grapheme_substr(?string $string, ?int $offset, ?int $length = null): string|false { return p\Grapheme::grapheme_substr((string) $string, (int) $offset, (int) $length); }
}
4 changes: 2 additions & 2 deletions src/Intl/Icu/bootstrap80.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Symfony\Polyfill\Intl\Icu as p;

if (!function_exists('intl_is_failure')) {
function intl_is_failure(int $errorCode): bool { return p\Icu::isFailure($errorCode); }
function intl_is_failure(?int $errorCode): bool { return p\Icu::isFailure((int) $errorCode); }
}
if (!function_exists('intl_get_error_code')) {
function intl_get_error_code(): int { return p\Icu::getErrorCode(); }
Expand All @@ -21,5 +21,5 @@ function intl_get_error_code(): int { return p\Icu::getErrorCode(); }
function intl_get_error_message(): string { return p\Icu::getErrorMessage(); }
}
if (!function_exists('intl_error_name')) {
function intl_error_name(int $errorCode): string { return p\Icu::getErrorName($errorCode); }
function intl_error_name(?int $errorCode): string { return p\Icu::getErrorName((int) $errorCode); }
}
4 changes: 2 additions & 2 deletions src/Intl/Idn/bootstrap80.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@
}

if (!function_exists('idn_to_ascii')) {
function idn_to_ascii(string $domain, int $flags = 0, int $variant = INTL_IDNA_VARIANT_UTS46, &$idna_info = null): string|false { return p\Idn::idn_to_ascii($domain, $flags, $variant, $idna_info); }
function idn_to_ascii(?string $domain, ?int $flags = 0, ?int $variant = INTL_IDNA_VARIANT_UTS46, &$idna_info = null): string|false { return p\Idn::idn_to_ascii((string) $domain, (int) $flags, (int) $variant, $idna_info); }
}
if (!function_exists('idn_to_utf8')) {
function idn_to_utf8(string $domain, int $flags = 0, int $variant = INTL_IDNA_VARIANT_UTS46, &$idna_info = null): string|false { return p\Idn::idn_to_utf8($domain, $flags, $variant, $idna_info); }
function idn_to_utf8(?string $domain, ?int $flags = 0, ?int $variant = INTL_IDNA_VARIANT_UTS46, &$idna_info = null): string|false { return p\Idn::idn_to_utf8((string) $domain, (int) $flags, (int) $variant, $idna_info); }
}
4 changes: 2 additions & 2 deletions src/Intl/Normalizer/bootstrap80.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
use Symfony\Polyfill\Intl\Normalizer as p;

if (!function_exists('normalizer_is_normalized')) {
function normalizer_is_normalized(string $string, int $form = p\Normalizer::FORM_C): bool { return p\Normalizer::isNormalized($string, $form); }
function normalizer_is_normalized(?string $string, ?int $form = p\Normalizer::FORM_C): bool { return p\Normalizer::isNormalized((string) $string, (int) $form); }
}
if (!function_exists('normalizer_normalize')) {
function normalizer_normalize(string $string, int $form = p\Normalizer::FORM_C): string|false { return p\Normalizer::normalize($string, $form); }
function normalizer_normalize(?string $string, ?int $form = p\Normalizer::FORM_C): string|false { return p\Normalizer::normalize((string) $string, (int) $form); }
}
Loading