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

Verify the signature of polyfills on PHP >= 8 #316

Merged
merged 1 commit into from
Dec 27, 2020
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
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
},
"require-dev": {
"symfony/intl": "^4.4|^5.0",
"symfony/phpunit-bridge": "^5.3"
"symfony/phpunit-bridge": "^5.3",
"symfony/var-dumper": "^4.4|^5.1"
},
"replace": {
"symfony/polyfill-apcu": "self.version",
Expand Down
16 changes: 10 additions & 6 deletions src/Apcu/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,41 @@
return;
}

if (PHP_VERSION_ID >= 80000) {
return require __DIR__.'/bootstrap80.php';
}

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); }
function apcu_add($key, $value = null, $ttl = 0) { return p\Apcu::apcu_add($key, $value, $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); }
function apcu_exists($key) { return p\Apcu::apcu_exists($key); }
}
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); }
function apcu_store($key, $value = null, $ttl = 0) { return p\Apcu::apcu_store($key, $value, $ttl); }
}
} else {
if (!function_exists('apcu_add')) {
function apcu_add($key, $var = null, $ttl = 0) { return apc_add($key, $var, $ttl); }
function apcu_add($key, $value = null, $ttl = 0) { return apc_add($key, $value, $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); }
function apcu_exists($key) { return apc_exists($key); }
}
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); }
function apcu_store($key, $value = null, $ttl = 0) { return apc_store($key, $value, $ttl); }
}
}

Expand Down
75 changes: 75 additions & 0 deletions src/Apcu/bootstrap80.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

use Symfony\Polyfill\Apcu as p;

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); }
}
if (!function_exists('apcu_delete')) {
function apcu_delete($key): array|bool { return p\Apcu::apcu_delete($key); }
}
if (!function_exists('apcu_exists')) {
function apcu_exists($key): array|bool { return p\Apcu::apcu_exists($key); }
}
if (!function_exists('apcu_fetch')) {
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); }
}
} else {
if (!function_exists('apcu_add')) {
function apcu_add($key, mixed $value, int $ttl = 0): array|bool { return apc_add($key, $value, $ttl); }
}
if (!function_exists('apcu_delete')) {
function apcu_delete($key): array|bool { return apc_delete($key); }
}
if (!function_exists('apcu_exists')) {
function apcu_exists($key): array|bool { return apc_exists($key); }
}
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, mixed $value, int $ttl = 0): array|bool { return apc_store($key, $value, $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); }
}

if (!class_exists('APCuIterator', false) && class_exists('APCIterator', false)) {
class APCuIterator extends APCIterator
{
public function __construct($search = null, $format = APC_ITER_ALL, $chunk_size = 100, $list = APC_LIST_ACTIVE)
{
parent::__construct('user', $search, $format, $chunk_size, $list);
}
}
}
26 changes: 15 additions & 11 deletions src/Ctype/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,40 @@

use Symfony\Polyfill\Ctype as p;

if (PHP_VERSION_ID >= 80000) {
return require __DIR__.'/bootstrap80.php';
}

if (!function_exists('ctype_alnum')) {
function ctype_alnum($input) { return p\Ctype::ctype_alnum($input); }
function ctype_alnum($text) { return p\Ctype::ctype_alnum($text); }
}
if (!function_exists('ctype_alpha')) {
function ctype_alpha($input) { return p\Ctype::ctype_alpha($input); }
function ctype_alpha($text) { return p\Ctype::ctype_alpha($text); }
}
if (!function_exists('ctype_cntrl')) {
function ctype_cntrl($input) { return p\Ctype::ctype_cntrl($input); }
function ctype_cntrl($text) { return p\Ctype::ctype_cntrl($text); }
}
if (!function_exists('ctype_digit')) {
function ctype_digit($input) { return p\Ctype::ctype_digit($input); }
function ctype_digit($text) { return p\Ctype::ctype_digit($text); }
}
if (!function_exists('ctype_graph')) {
function ctype_graph($input) { return p\Ctype::ctype_graph($input); }
function ctype_graph($text) { return p\Ctype::ctype_graph($text); }
}
if (!function_exists('ctype_lower')) {
function ctype_lower($input) { return p\Ctype::ctype_lower($input); }
function ctype_lower($text) { return p\Ctype::ctype_lower($text); }
}
if (!function_exists('ctype_print')) {
function ctype_print($input) { return p\Ctype::ctype_print($input); }
function ctype_print($text) { return p\Ctype::ctype_print($text); }
}
if (!function_exists('ctype_punct')) {
function ctype_punct($input) { return p\Ctype::ctype_punct($input); }
function ctype_punct($text) { return p\Ctype::ctype_punct($text); }
}
if (!function_exists('ctype_space')) {
function ctype_space($input) { return p\Ctype::ctype_space($input); }
function ctype_space($text) { return p\Ctype::ctype_space($text); }
}
if (!function_exists('ctype_upper')) {
function ctype_upper($input) { return p\Ctype::ctype_upper($input); }
function ctype_upper($text) { return p\Ctype::ctype_upper($text); }
}
if (!function_exists('ctype_xdigit')) {
function ctype_xdigit($input) { return p\Ctype::ctype_xdigit($input); }
function ctype_xdigit($text) { return p\Ctype::ctype_xdigit($text); }
}
46 changes: 46 additions & 0 deletions src/Ctype/bootstrap80.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

use Symfony\Polyfill\Ctype as p;

if (!function_exists('ctype_alnum')) {
function ctype_alnum(mixed $text): bool { return p\Ctype::ctype_alnum($text); }
}
if (!function_exists('ctype_alpha')) {
function ctype_alpha(mixed $text): bool { return p\Ctype::ctype_alpha($text); }
}
if (!function_exists('ctype_cntrl')) {
function ctype_cntrl(mixed $text): bool { return p\Ctype::ctype_cntrl($text); }
}
if (!function_exists('ctype_digit')) {
function ctype_digit(mixed $text): bool { return p\Ctype::ctype_digit($text); }
}
if (!function_exists('ctype_graph')) {
function ctype_graph(mixed $text): bool { return p\Ctype::ctype_graph($text); }
}
if (!function_exists('ctype_lower')) {
function ctype_lower(mixed $text): bool { return p\Ctype::ctype_lower($text); }
}
if (!function_exists('ctype_print')) {
function ctype_print(mixed $text): bool { return p\Ctype::ctype_print($text); }
}
if (!function_exists('ctype_punct')) {
function ctype_punct(mixed $text): bool { return p\Ctype::ctype_punct($text); }
}
if (!function_exists('ctype_space')) {
function ctype_space(mixed $text): bool { return p\Ctype::ctype_space($text); }
}
if (!function_exists('ctype_upper')) {
function ctype_upper(mixed $text): bool { return p\Ctype::ctype_upper($text); }
}
if (!function_exists('ctype_xdigit')) {
function ctype_xdigit(mixed $text): bool { return p\Ctype::ctype_xdigit($text); }
}
6 changes: 5 additions & 1 deletion src/Iconv/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
return;
}

if (PHP_VERSION_ID >= 80000) {
return require __DIR__.'/bootstrap80.php';
}

if (!defined('ICONV_IMPL')) {
define('ICONV_IMPL', 'Symfony');
}
Expand All @@ -38,7 +42,7 @@ function iconv_get_encoding($type = 'all') { return p\Iconv::iconv_get_encoding(
function iconv_set_encoding($type, $encoding) { return p\Iconv::iconv_set_encoding($type, $encoding); }
}
if (!function_exists('iconv_mime_encode')) {
function iconv_mime_encode($field_name, $field_value, $options = null) { return p\Iconv::iconv_mime_encode($field_name, $field_value, $options); }
function iconv_mime_encode($field_name, $field_value, $options = []) { return p\Iconv::iconv_mime_encode($field_name, $field_value, $options); }
}
if (!function_exists('iconv_mime_decode_headers')) {
function iconv_mime_decode_headers($headers, $mode = 0, $encoding = null) { return p\Iconv::iconv_mime_decode_headers($headers, $mode, $encoding); }
Expand Down
80 changes: 80 additions & 0 deletions src/Iconv/bootstrap80.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

use Symfony\Polyfill\Iconv as p;

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(string $from_encoding, string $to_encoding, string $string): string|false { return p\Iconv::iconv($from_encoding, $to_encoding, $string); }
}
if (!function_exists('iconv_get_encoding')) {
function iconv_get_encoding(string $type = 'all'): array|string|false { return p\Iconv::iconv_get_encoding($type); }
}
if (!function_exists('iconv_set_encoding')) {
function iconv_set_encoding(string $type, string $encoding): bool { return p\Iconv::iconv_set_encoding($type, $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); }
}
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); }
}

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); }
}
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); }
}
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); }
}
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); }
}
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); }
} else {
function iconv_strlen(string $string, string $encoding = null): int|false { return p\Iconv::strlen2($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); }
}
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); }
}
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); }
}
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); }
}
}
12 changes: 8 additions & 4 deletions src/Intl/Grapheme/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
return;
}

if (PHP_VERSION_ID >= 80000) {
return require __DIR__.'/bootstrap80.php';
}

if (!defined('GRAPHEME_EXTR_COUNT')) {
define('GRAPHEME_EXTR_COUNT', 0);
}
Expand All @@ -26,13 +30,13 @@
}

if (!function_exists('grapheme_extract')) {
function grapheme_extract($haystack, $size, $extract_type = 0, $start = 0, &$next = 0) { return p\Grapheme::grapheme_extract($haystack, $size, $extract_type, $start, $next); }
function grapheme_extract($haystack, $size, $type = 0, $start = 0, &$next = 0) { return p\Grapheme::grapheme_extract($haystack, $size, $type, $start, $next); }
}
if (!function_exists('grapheme_stripos')) {
function grapheme_stripos($haystack, $needle, $offset = 0) { return p\Grapheme::grapheme_stripos($haystack, $needle, $offset); }
}
if (!function_exists('grapheme_stristr')) {
function grapheme_stristr($haystack, $needle, $before_needle = false) { return p\Grapheme::grapheme_stristr($haystack, $needle, $before_needle); }
function grapheme_stristr($haystack, $needle, $beforeNeedle = false) { return p\Grapheme::grapheme_stristr($haystack, $needle, $beforeNeedle); }
}
if (!function_exists('grapheme_strlen')) {
function grapheme_strlen($input) { return p\Grapheme::grapheme_strlen($input); }
Expand All @@ -47,8 +51,8 @@ function grapheme_strripos($haystack, $needle, $offset = 0) { return p\Grapheme:
function grapheme_strrpos($haystack, $needle, $offset = 0) { return p\Grapheme::grapheme_strrpos($haystack, $needle, $offset); }
}
if (!function_exists('grapheme_strstr')) {
function grapheme_strstr($haystack, $needle, $before_needle = false) { return p\Grapheme::grapheme_strstr($haystack, $needle, $before_needle); }
function grapheme_strstr($haystack, $needle, $beforeNeedle = false) { return p\Grapheme::grapheme_strstr($haystack, $needle, $beforeNeedle); }
}
if (!function_exists('grapheme_substr')) {
function grapheme_substr($string, $start, $length = null) { return p\Grapheme::grapheme_substr($string, $start, $length); }
function grapheme_substr($string, $offset, $length = null) { return p\Grapheme::grapheme_substr($string, $offset, $length); }
}
Loading