mirror of
https://github.com/gtbu/Typesetter-5.3-p8.git
synced 2025-08-06 14:23:14 +02:00
added symfony polyfills
https://github.com/symfony/polyfill php - polyfills from php7.4 tp 84. This makes older plugins compatible and more
This commit is contained in:
parent
b70b4a0e13
commit
8ec460c113
241 changed files with 52902 additions and 0 deletions
|
@ -13,6 +13,8 @@ set_error_handler('showError');
|
|||
|
||||
require_once('thirdparty/time/strftime.php');
|
||||
|
||||
require_once('thirdparty/polyfills/bootstrap.php');
|
||||
|
||||
require_once('tool.php');
|
||||
|
||||
gp_defined('gp_restrict_uploads', false);
|
||||
|
|
106
include/thirdparty/polyfills/Apcu/Apcu.php
vendored
Normal file
106
include/thirdparty/polyfills/Apcu/Apcu.php
vendored
Normal file
|
@ -0,0 +1,106 @@
|
|||
<?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.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Apcu;
|
||||
|
||||
/**
|
||||
* Apcu for Zend Server Data Cache.
|
||||
*
|
||||
* @author Kate Gray <opensource@codebykate.com>
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
final class Apcu
|
||||
{
|
||||
public static function apcu_add($key, $var = null, $ttl = 0)
|
||||
{
|
||||
if (!\is_array($key)) {
|
||||
return apc_add($key, $var, $ttl);
|
||||
}
|
||||
|
||||
$errors = [];
|
||||
foreach ($key as $k => $v) {
|
||||
if (!apc_add($k, $v, $ttl)) {
|
||||
$errors[$k] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
||||
public static function apcu_store($key, $var = null, $ttl = 0)
|
||||
{
|
||||
if (!\is_array($key)) {
|
||||
return apc_store($key, $var, $ttl);
|
||||
}
|
||||
|
||||
$errors = [];
|
||||
foreach ($key as $k => $v) {
|
||||
if (!apc_store($k, $v, $ttl)) {
|
||||
$errors[$k] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
||||
public static function apcu_exists($keys)
|
||||
{
|
||||
if (!\is_array($keys)) {
|
||||
return apc_exists($keys);
|
||||
}
|
||||
|
||||
$existing = [];
|
||||
foreach ($keys as $k) {
|
||||
if (apc_exists($k)) {
|
||||
$existing[$k] = true;
|
||||
}
|
||||
}
|
||||
|
||||
return $existing;
|
||||
}
|
||||
|
||||
public static function apcu_fetch($key, &$success = null)
|
||||
{
|
||||
if (!\is_array($key)) {
|
||||
return apc_fetch($key, $success);
|
||||
}
|
||||
|
||||
$succeeded = true;
|
||||
$values = [];
|
||||
foreach ($key as $k) {
|
||||
$v = apc_fetch($k, $success);
|
||||
if ($success) {
|
||||
$values[$k] = $v;
|
||||
} else {
|
||||
$succeeded = false;
|
||||
}
|
||||
}
|
||||
$success = $succeeded;
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
public static function apcu_delete($key)
|
||||
{
|
||||
if (!\is_array($key)) {
|
||||
return apc_delete($key);
|
||||
}
|
||||
|
||||
$success = true;
|
||||
foreach ($key as $k) {
|
||||
$success = apc_delete($k) && $success;
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
}
|
19
include/thirdparty/polyfills/Apcu/LICENSE
vendored
Normal file
19
include/thirdparty/polyfills/Apcu/LICENSE
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
Copyright (c) 2015-present Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
12
include/thirdparty/polyfills/Apcu/README.md
vendored
Normal file
12
include/thirdparty/polyfills/Apcu/README.md
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
Symfony Polyfill / APCu
|
||||
========================
|
||||
|
||||
This component provides `apcu_*` functions and the `APCuIterator` class to users of the legacy APC extension.
|
||||
|
||||
More information can be found in the
|
||||
[main Polyfill README](https://github.com/symfony/polyfill/blob/main/README.md).
|
||||
|
||||
License
|
||||
=======
|
||||
|
||||
This library is released under the [MIT license](LICENSE).
|
83
include/thirdparty/polyfills/Apcu/bootstrap.php
vendored
Normal file
83
include/thirdparty/polyfills/Apcu/bootstrap.php
vendored
Normal file
|
@ -0,0 +1,83 @@
|
|||
<?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('apc') && !extension_loaded('apcu')) {
|
||||
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, $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($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, $value = null, $ttl = 0) { return p\Apcu::apcu_store($key, $value, $ttl); }
|
||||
}
|
||||
} else {
|
||||
if (!function_exists('apcu_add')) {
|
||||
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($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, $value = null, $ttl = 0) { 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);
|
||||
}
|
||||
}
|
||||
}
|
75
include/thirdparty/polyfills/Apcu/bootstrap80.php
vendored
Normal file
75
include/thirdparty/polyfills/Apcu/bootstrap80.php
vendored
Normal file
|
@ -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, (int) $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) { 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, (int) $ttl); }
|
||||
}
|
||||
} else {
|
||||
if (!function_exists('apcu_add')) {
|
||||
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); }
|
||||
}
|
||||
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, (int) $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);
|
||||
}
|
||||
}
|
||||
}
|
232
include/thirdparty/polyfills/Ctype/Ctype.php
vendored
Normal file
232
include/thirdparty/polyfills/Ctype/Ctype.php
vendored
Normal file
|
@ -0,0 +1,232 @@
|
|||
<?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.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Ctype;
|
||||
|
||||
/**
|
||||
* Ctype implementation through regex.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @author Gert de Pagter <BackEndTea@gmail.com>
|
||||
*/
|
||||
final class Ctype
|
||||
{
|
||||
/**
|
||||
* Returns TRUE if every character in text is either a letter or a digit, FALSE otherwise.
|
||||
*
|
||||
* @see https://php.net/ctype-alnum
|
||||
*
|
||||
* @param mixed $text
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function ctype_alnum($text)
|
||||
{
|
||||
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
|
||||
|
||||
return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z0-9]/', $text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE if every character in text is a letter, FALSE otherwise.
|
||||
*
|
||||
* @see https://php.net/ctype-alpha
|
||||
*
|
||||
* @param mixed $text
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function ctype_alpha($text)
|
||||
{
|
||||
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
|
||||
|
||||
return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z]/', $text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE if every character in text is a control character from the current locale, FALSE otherwise.
|
||||
*
|
||||
* @see https://php.net/ctype-cntrl
|
||||
*
|
||||
* @param mixed $text
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function ctype_cntrl($text)
|
||||
{
|
||||
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
|
||||
|
||||
return \is_string($text) && '' !== $text && !preg_match('/[^\x00-\x1f\x7f]/', $text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE if every character in the string text is a decimal digit, FALSE otherwise.
|
||||
*
|
||||
* @see https://php.net/ctype-digit
|
||||
*
|
||||
* @param mixed $text
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function ctype_digit($text)
|
||||
{
|
||||
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
|
||||
|
||||
return \is_string($text) && '' !== $text && !preg_match('/[^0-9]/', $text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE if every character in text is printable and actually creates visible output (no white space), FALSE otherwise.
|
||||
*
|
||||
* @see https://php.net/ctype-graph
|
||||
*
|
||||
* @param mixed $text
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function ctype_graph($text)
|
||||
{
|
||||
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
|
||||
|
||||
return \is_string($text) && '' !== $text && !preg_match('/[^!-~]/', $text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE if every character in text is a lowercase letter.
|
||||
*
|
||||
* @see https://php.net/ctype-lower
|
||||
*
|
||||
* @param mixed $text
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function ctype_lower($text)
|
||||
{
|
||||
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
|
||||
|
||||
return \is_string($text) && '' !== $text && !preg_match('/[^a-z]/', $text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE if every character in text will actually create output (including blanks). Returns FALSE if text contains control characters or characters that do not have any output or control function at all.
|
||||
*
|
||||
* @see https://php.net/ctype-print
|
||||
*
|
||||
* @param mixed $text
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function ctype_print($text)
|
||||
{
|
||||
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
|
||||
|
||||
return \is_string($text) && '' !== $text && !preg_match('/[^ -~]/', $text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE if every character in text is printable, but neither letter, digit or blank, FALSE otherwise.
|
||||
*
|
||||
* @see https://php.net/ctype-punct
|
||||
*
|
||||
* @param mixed $text
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function ctype_punct($text)
|
||||
{
|
||||
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
|
||||
|
||||
return \is_string($text) && '' !== $text && !preg_match('/[^!-\/\:-@\[-`\{-~]/', $text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE if every character in text creates some sort of white space, FALSE otherwise. Besides the blank character this also includes tab, vertical tab, line feed, carriage return and form feed characters.
|
||||
*
|
||||
* @see https://php.net/ctype-space
|
||||
*
|
||||
* @param mixed $text
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function ctype_space($text)
|
||||
{
|
||||
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
|
||||
|
||||
return \is_string($text) && '' !== $text && !preg_match('/[^\s]/', $text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE if every character in text is an uppercase letter.
|
||||
*
|
||||
* @see https://php.net/ctype-upper
|
||||
*
|
||||
* @param mixed $text
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function ctype_upper($text)
|
||||
{
|
||||
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
|
||||
|
||||
return \is_string($text) && '' !== $text && !preg_match('/[^A-Z]/', $text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE if every character in text is a hexadecimal 'digit', that is a decimal digit or a character from [A-Fa-f] , FALSE otherwise.
|
||||
*
|
||||
* @see https://php.net/ctype-xdigit
|
||||
*
|
||||
* @param mixed $text
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function ctype_xdigit($text)
|
||||
{
|
||||
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
|
||||
|
||||
return \is_string($text) && '' !== $text && !preg_match('/[^A-Fa-f0-9]/', $text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts integers to their char versions according to normal ctype behaviour, if needed.
|
||||
*
|
||||
* If an integer between -128 and 255 inclusive is provided,
|
||||
* it is interpreted as the ASCII value of a single character
|
||||
* (negative values have 256 added in order to allow characters in the Extended ASCII range).
|
||||
* Any other integer is interpreted as a string containing the decimal digits of the integer.
|
||||
*
|
||||
* @param mixed $int
|
||||
* @param string $function
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
private static function convert_int_to_char_for_ctype($int, $function)
|
||||
{
|
||||
if (!\is_int($int)) {
|
||||
return $int;
|
||||
}
|
||||
|
||||
if ($int < -128 || $int > 255) {
|
||||
return (string) $int;
|
||||
}
|
||||
|
||||
if (\PHP_VERSION_ID >= 80100) {
|
||||
@trigger_error($function.'(): Argument of type int will be interpreted as string in the future', \E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
if ($int < 0) {
|
||||
$int += 256;
|
||||
}
|
||||
|
||||
return \chr($int);
|
||||
}
|
||||
}
|
19
include/thirdparty/polyfills/Ctype/LICENSE
vendored
Normal file
19
include/thirdparty/polyfills/Ctype/LICENSE
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
Copyright (c) 2018-present Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
12
include/thirdparty/polyfills/Ctype/README.md
vendored
Normal file
12
include/thirdparty/polyfills/Ctype/README.md
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
Symfony Polyfill / Ctype
|
||||
========================
|
||||
|
||||
This component provides `ctype_*` functions to users who run php versions without the ctype extension.
|
||||
|
||||
More information can be found in the
|
||||
[main Polyfill README](https://github.com/symfony/polyfill/blob/main/README.md).
|
||||
|
||||
License
|
||||
=======
|
||||
|
||||
This library is released under the [MIT license](LICENSE).
|
50
include/thirdparty/polyfills/Ctype/bootstrap.php
vendored
Normal file
50
include/thirdparty/polyfills/Ctype/bootstrap.php
vendored
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?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 (\PHP_VERSION_ID >= 80000) {
|
||||
return require __DIR__.'/bootstrap80.php';
|
||||
}
|
||||
|
||||
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); }
|
||||
}
|
46
include/thirdparty/polyfills/Ctype/bootstrap80.php
vendored
Normal file
46
include/thirdparty/polyfills/Ctype/bootstrap80.php
vendored
Normal file
|
@ -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); }
|
||||
}
|
718
include/thirdparty/polyfills/Iconv/Iconv.php
vendored
Normal file
718
include/thirdparty/polyfills/Iconv/Iconv.php
vendored
Normal file
|
@ -0,0 +1,718 @@
|
|||
<?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.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Iconv;
|
||||
|
||||
/**
|
||||
* iconv implementation in pure PHP, UTF-8 centric.
|
||||
*
|
||||
* Implemented:
|
||||
* - iconv - Convert string to requested character encoding
|
||||
* - iconv_mime_decode - Decodes a MIME header field
|
||||
* - iconv_mime_decode_headers - Decodes multiple MIME header fields at once
|
||||
* - iconv_get_encoding - Retrieve internal configuration variables of iconv extension
|
||||
* - iconv_set_encoding - Set current setting for character encoding conversion
|
||||
* - iconv_mime_encode - Composes a MIME header field
|
||||
* - iconv_strlen - Returns the character count of string
|
||||
* - iconv_strpos - Finds position of first occurrence of a needle within a haystack
|
||||
* - iconv_strrpos - Finds the last occurrence of a needle within a haystack
|
||||
* - iconv_substr - Cut out part of a string
|
||||
*
|
||||
* Charsets available for conversion are defined by files
|
||||
* in the charset/ directory and by Iconv::$alias below.
|
||||
* You're welcome to send back any addition you make.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
final class Iconv
|
||||
{
|
||||
public const ERROR_ILLEGAL_CHARACTER = 'iconv(): Detected an illegal character in input string';
|
||||
public const ERROR_WRONG_CHARSET = 'iconv(): Wrong charset, conversion from `%s\' to `%s\' is not allowed';
|
||||
|
||||
public static $inputEncoding = 'utf-8';
|
||||
public static $outputEncoding = 'utf-8';
|
||||
public static $internalEncoding = 'utf-8';
|
||||
|
||||
private static $alias = [
|
||||
'utf8' => 'utf-8',
|
||||
'ascii' => 'us-ascii',
|
||||
'tis-620' => 'iso-8859-11',
|
||||
'cp1250' => 'windows-1250',
|
||||
'cp1251' => 'windows-1251',
|
||||
'cp1252' => 'windows-1252',
|
||||
'cp1253' => 'windows-1253',
|
||||
'cp1254' => 'windows-1254',
|
||||
'cp1255' => 'windows-1255',
|
||||
'cp1256' => 'windows-1256',
|
||||
'cp1257' => 'windows-1257',
|
||||
'cp1258' => 'windows-1258',
|
||||
'shift-jis' => 'cp932',
|
||||
'shift_jis' => 'cp932',
|
||||
'latin1' => 'iso-8859-1',
|
||||
'latin2' => 'iso-8859-2',
|
||||
'latin3' => 'iso-8859-3',
|
||||
'latin4' => 'iso-8859-4',
|
||||
'latin5' => 'iso-8859-9',
|
||||
'latin6' => 'iso-8859-10',
|
||||
'latin7' => 'iso-8859-13',
|
||||
'latin8' => 'iso-8859-14',
|
||||
'latin9' => 'iso-8859-15',
|
||||
'latin10' => 'iso-8859-16',
|
||||
'iso8859-1' => 'iso-8859-1',
|
||||
'iso8859-2' => 'iso-8859-2',
|
||||
'iso8859-3' => 'iso-8859-3',
|
||||
'iso8859-4' => 'iso-8859-4',
|
||||
'iso8859-5' => 'iso-8859-5',
|
||||
'iso8859-6' => 'iso-8859-6',
|
||||
'iso8859-7' => 'iso-8859-7',
|
||||
'iso8859-8' => 'iso-8859-8',
|
||||
'iso8859-9' => 'iso-8859-9',
|
||||
'iso8859-10' => 'iso-8859-10',
|
||||
'iso8859-11' => 'iso-8859-11',
|
||||
'iso8859-12' => 'iso-8859-12',
|
||||
'iso8859-13' => 'iso-8859-13',
|
||||
'iso8859-14' => 'iso-8859-14',
|
||||
'iso8859-15' => 'iso-8859-15',
|
||||
'iso8859-16' => 'iso-8859-16',
|
||||
'iso_8859-1' => 'iso-8859-1',
|
||||
'iso_8859-2' => 'iso-8859-2',
|
||||
'iso_8859-3' => 'iso-8859-3',
|
||||
'iso_8859-4' => 'iso-8859-4',
|
||||
'iso_8859-5' => 'iso-8859-5',
|
||||
'iso_8859-6' => 'iso-8859-6',
|
||||
'iso_8859-7' => 'iso-8859-7',
|
||||
'iso_8859-8' => 'iso-8859-8',
|
||||
'iso_8859-9' => 'iso-8859-9',
|
||||
'iso_8859-10' => 'iso-8859-10',
|
||||
'iso_8859-11' => 'iso-8859-11',
|
||||
'iso_8859-12' => 'iso-8859-12',
|
||||
'iso_8859-13' => 'iso-8859-13',
|
||||
'iso_8859-14' => 'iso-8859-14',
|
||||
'iso_8859-15' => 'iso-8859-15',
|
||||
'iso_8859-16' => 'iso-8859-16',
|
||||
'iso88591' => 'iso-8859-1',
|
||||
'iso88592' => 'iso-8859-2',
|
||||
'iso88593' => 'iso-8859-3',
|
||||
'iso88594' => 'iso-8859-4',
|
||||
'iso88595' => 'iso-8859-5',
|
||||
'iso88596' => 'iso-8859-6',
|
||||
'iso88597' => 'iso-8859-7',
|
||||
'iso88598' => 'iso-8859-8',
|
||||
'iso88599' => 'iso-8859-9',
|
||||
'iso885910' => 'iso-8859-10',
|
||||
'iso885911' => 'iso-8859-11',
|
||||
'iso885912' => 'iso-8859-12',
|
||||
'iso885913' => 'iso-8859-13',
|
||||
'iso885914' => 'iso-8859-14',
|
||||
'iso885915' => 'iso-8859-15',
|
||||
'iso885916' => 'iso-8859-16',
|
||||
];
|
||||
private static $translitMap = [];
|
||||
private static $convertMap = [];
|
||||
private static $errorHandler;
|
||||
private static $lastError;
|
||||
|
||||
private static $ulenMask = ["\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4];
|
||||
private static $isValidUtf8;
|
||||
|
||||
public static function iconv($inCharset, $outCharset, $str)
|
||||
{
|
||||
$str = (string) $str;
|
||||
if ('' === $str) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Prepare for //IGNORE and //TRANSLIT
|
||||
|
||||
$translit = $ignore = '';
|
||||
|
||||
$outCharset = strtolower($outCharset);
|
||||
$inCharset = strtolower($inCharset);
|
||||
|
||||
if ('' === $outCharset) {
|
||||
$outCharset = 'iso-8859-1';
|
||||
}
|
||||
if ('' === $inCharset) {
|
||||
$inCharset = 'iso-8859-1';
|
||||
}
|
||||
|
||||
do {
|
||||
$loop = false;
|
||||
|
||||
if ('//translit' === substr($outCharset, -10)) {
|
||||
$loop = $translit = true;
|
||||
$outCharset = substr($outCharset, 0, -10);
|
||||
}
|
||||
|
||||
if ('//ignore' === substr($outCharset, -8)) {
|
||||
$loop = $ignore = true;
|
||||
$outCharset = substr($outCharset, 0, -8);
|
||||
}
|
||||
} while ($loop);
|
||||
|
||||
do {
|
||||
$loop = false;
|
||||
|
||||
if ('//translit' === substr($inCharset, -10)) {
|
||||
$loop = true;
|
||||
$inCharset = substr($inCharset, 0, -10);
|
||||
}
|
||||
|
||||
if ('//ignore' === substr($inCharset, -8)) {
|
||||
$loop = true;
|
||||
$inCharset = substr($inCharset, 0, -8);
|
||||
}
|
||||
} while ($loop);
|
||||
|
||||
if (isset(self::$alias[$inCharset])) {
|
||||
$inCharset = self::$alias[$inCharset];
|
||||
}
|
||||
if (isset(self::$alias[$outCharset])) {
|
||||
$outCharset = self::$alias[$outCharset];
|
||||
}
|
||||
|
||||
// Load charset maps
|
||||
|
||||
if (('utf-8' !== $inCharset && !self::loadMap('from.', $inCharset, $inMap))
|
||||
|| ('utf-8' !== $outCharset && !self::loadMap('to.', $outCharset, $outMap))) {
|
||||
trigger_error(sprintf(self::ERROR_WRONG_CHARSET, $inCharset, $outCharset));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if ('utf-8' !== $inCharset) {
|
||||
// Convert input to UTF-8
|
||||
$result = '';
|
||||
if (self::mapToUtf8($result, $inMap, $str, $ignore)) {
|
||||
$str = $result;
|
||||
} else {
|
||||
$str = false;
|
||||
}
|
||||
self::$isValidUtf8 = true;
|
||||
} else {
|
||||
self::$isValidUtf8 = preg_match('//u', $str);
|
||||
|
||||
if (!self::$isValidUtf8 && !$ignore) {
|
||||
trigger_error(self::ERROR_ILLEGAL_CHARACTER);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if ('utf-8' === $outCharset) {
|
||||
// UTF-8 validation
|
||||
$str = self::utf8ToUtf8($str, $ignore);
|
||||
}
|
||||
}
|
||||
|
||||
if ('utf-8' !== $outCharset && false !== $str) {
|
||||
// Convert output to UTF-8
|
||||
$result = '';
|
||||
if (self::mapFromUtf8($result, $outMap, $str, $ignore, $translit)) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
public static function iconv_mime_decode_headers($str, $mode = 0, $charset = null)
|
||||
{
|
||||
if (null === $charset) {
|
||||
$charset = self::$internalEncoding;
|
||||
}
|
||||
|
||||
if (false !== strpos($str, "\r")) {
|
||||
$str = strtr(str_replace("\r\n", "\n", $str), "\r", "\n");
|
||||
}
|
||||
$str = explode("\n\n", $str, 2);
|
||||
|
||||
$headers = [];
|
||||
|
||||
$str = preg_split('/\n(?![ \t])/', $str[0]);
|
||||
foreach ($str as $str) {
|
||||
$str = self::iconv_mime_decode($str, $mode, $charset);
|
||||
if (false === $str) {
|
||||
return false;
|
||||
}
|
||||
$str = explode(':', $str, 2);
|
||||
|
||||
if (2 === \count($str)) {
|
||||
if (isset($headers[$str[0]])) {
|
||||
if (!\is_array($headers[$str[0]])) {
|
||||
$headers[$str[0]] = [$headers[$str[0]]];
|
||||
}
|
||||
$headers[$str[0]][] = ltrim($str[1]);
|
||||
} else {
|
||||
$headers[$str[0]] = ltrim($str[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $headers;
|
||||
}
|
||||
|
||||
public static function iconv_mime_decode($str, $mode = 0, $charset = null)
|
||||
{
|
||||
if (null === $charset) {
|
||||
$charset = self::$internalEncoding;
|
||||
}
|
||||
if (\ICONV_MIME_DECODE_CONTINUE_ON_ERROR & $mode) {
|
||||
$charset .= '//IGNORE';
|
||||
}
|
||||
|
||||
if (false !== strpos($str, "\r")) {
|
||||
$str = strtr(str_replace("\r\n", "\n", $str), "\r", "\n");
|
||||
}
|
||||
$str = preg_split('/\n(?![ \t])/', rtrim($str), 2);
|
||||
$str = preg_replace('/[ \t]*\n[ \t]+/', ' ', rtrim($str[0]));
|
||||
$str = preg_split('/=\?([^?]+)\?([bqBQ])\?(.*?)\?=/', $str, -1, \PREG_SPLIT_DELIM_CAPTURE);
|
||||
|
||||
$result = self::iconv('utf-8', $charset, $str[0]);
|
||||
if (false === $result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$i = 1;
|
||||
$len = \count($str);
|
||||
|
||||
while ($i < $len) {
|
||||
$c = strtolower($str[$i]);
|
||||
if ((\ICONV_MIME_DECODE_CONTINUE_ON_ERROR & $mode)
|
||||
&& 'utf-8' !== $c
|
||||
&& !isset(self::$alias[$c])
|
||||
&& !self::loadMap('from.', $c, $d)) {
|
||||
$d = false;
|
||||
} elseif ('B' === strtoupper($str[$i + 1])) {
|
||||
$d = base64_decode($str[$i + 2]);
|
||||
} else {
|
||||
$d = rawurldecode(strtr(str_replace('%', '%25', $str[$i + 2]), '=_', '% '));
|
||||
}
|
||||
|
||||
if (false !== $d) {
|
||||
if ('' !== $d) {
|
||||
if ('' === $d = self::iconv($c, $charset, $d)) {
|
||||
$str[$i + 3] = substr($str[$i + 3], 1);
|
||||
} else {
|
||||
$result .= $d;
|
||||
}
|
||||
}
|
||||
$d = self::iconv('utf-8', $charset, $str[$i + 3]);
|
||||
if ('' !== trim($d)) {
|
||||
$result .= $d;
|
||||
}
|
||||
} elseif (\ICONV_MIME_DECODE_CONTINUE_ON_ERROR & $mode) {
|
||||
$result .= "=?{$str[$i]}?{$str[$i + 1]}?{$str[$i + 2]}?={$str[$i + 3]}";
|
||||
} else {
|
||||
$result = false;
|
||||
break;
|
||||
}
|
||||
|
||||
$i += 4;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function iconv_get_encoding($type = 'all')
|
||||
{
|
||||
switch ($type) {
|
||||
case 'input_encoding': return self::$inputEncoding;
|
||||
case 'output_encoding': return self::$outputEncoding;
|
||||
case 'internal_encoding': return self::$internalEncoding;
|
||||
}
|
||||
|
||||
return [
|
||||
'input_encoding' => self::$inputEncoding,
|
||||
'output_encoding' => self::$outputEncoding,
|
||||
'internal_encoding' => self::$internalEncoding,
|
||||
];
|
||||
}
|
||||
|
||||
public static function iconv_set_encoding($type, $charset)
|
||||
{
|
||||
switch ($type) {
|
||||
case 'input_encoding': self::$inputEncoding = $charset; break;
|
||||
case 'output_encoding': self::$outputEncoding = $charset; break;
|
||||
case 'internal_encoding': self::$internalEncoding = $charset; break;
|
||||
default: return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function iconv_mime_encode($fieldName, $fieldValue, $pref = null)
|
||||
{
|
||||
if (!\is_array($pref)) {
|
||||
$pref = [];
|
||||
}
|
||||
|
||||
$pref += [
|
||||
'scheme' => 'B',
|
||||
'input-charset' => self::$internalEncoding,
|
||||
'output-charset' => self::$internalEncoding,
|
||||
'line-length' => 76,
|
||||
'line-break-chars' => "\r\n",
|
||||
];
|
||||
|
||||
if (preg_match('/[\x80-\xFF]/', $fieldName)) {
|
||||
$fieldName = '';
|
||||
}
|
||||
|
||||
$scheme = strtoupper(substr($pref['scheme'], 0, 1));
|
||||
$in = strtolower($pref['input-charset']);
|
||||
$out = strtolower($pref['output-charset']);
|
||||
|
||||
if ('utf-8' !== $in && false === $fieldValue = self::iconv($in, 'utf-8', $fieldValue)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
preg_match_all('/./us', $fieldValue, $chars);
|
||||
|
||||
$chars = $chars[0] ?? [];
|
||||
|
||||
$lineBreak = (int) $pref['line-length'];
|
||||
$lineStart = "=?{$pref['output-charset']}?{$scheme}?";
|
||||
$lineLength = \strlen($fieldName) + 2 + \strlen($lineStart) + 2;
|
||||
$lineOffset = \strlen($lineStart) + 3;
|
||||
$lineData = '';
|
||||
|
||||
$fieldValue = [];
|
||||
|
||||
$Q = 'Q' === $scheme;
|
||||
|
||||
foreach ($chars as $c) {
|
||||
if ('utf-8' !== $out && false === $c = self::iconv('utf-8', $out, $c)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$o = $Q
|
||||
? $c = preg_replace_callback(
|
||||
'/[=_\?\x00-\x1F\x80-\xFF]/',
|
||||
[__CLASS__, 'qpByteCallback'],
|
||||
$c
|
||||
)
|
||||
: base64_encode($lineData.$c);
|
||||
|
||||
if (isset($o[$lineBreak - $lineLength])) {
|
||||
if (!$Q) {
|
||||
$lineData = base64_encode($lineData);
|
||||
}
|
||||
$fieldValue[] = $lineStart.$lineData.'?=';
|
||||
$lineLength = $lineOffset;
|
||||
$lineData = '';
|
||||
}
|
||||
|
||||
$lineData .= $c;
|
||||
$Q && $lineLength += \strlen($c);
|
||||
}
|
||||
|
||||
if ('' !== $lineData) {
|
||||
if (!$Q) {
|
||||
$lineData = base64_encode($lineData);
|
||||
}
|
||||
$fieldValue[] = $lineStart.$lineData.'?=';
|
||||
}
|
||||
|
||||
return $fieldName.': '.implode($pref['line-break-chars'].' ', $fieldValue);
|
||||
}
|
||||
|
||||
public static function iconv_strlen($s, $encoding = null)
|
||||
{
|
||||
if (null === $encoding) {
|
||||
$encoding = self::$internalEncoding;
|
||||
}
|
||||
if (0 !== stripos($encoding, 'utf-8') && false === $s = self::iconv($encoding, 'utf-8', $s)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$ulenMask = self::$ulenMask;
|
||||
|
||||
$i = 0;
|
||||
$j = 0;
|
||||
$len = \strlen($s);
|
||||
|
||||
while ($i < $len) {
|
||||
$u = $s[$i] & "\xF0";
|
||||
$i += $ulenMask[$u] ?? 1;
|
||||
++$j;
|
||||
}
|
||||
|
||||
return $j;
|
||||
}
|
||||
|
||||
public static function iconv_strpos($haystack, $needle, $offset = 0, $encoding = null)
|
||||
{
|
||||
if (null === $encoding) {
|
||||
$encoding = self::$internalEncoding;
|
||||
}
|
||||
|
||||
if (0 !== stripos($encoding, 'utf-8')) {
|
||||
if (false === $haystack = self::iconv($encoding, 'utf-8', $haystack)) {
|
||||
return false;
|
||||
}
|
||||
if (false === $needle = self::iconv($encoding, 'utf-8', $needle)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($offset = (int) $offset) {
|
||||
$haystack = self::iconv_substr($haystack, $offset, 2147483647, 'utf-8');
|
||||
}
|
||||
$pos = strpos($haystack, $needle);
|
||||
|
||||
return false === $pos ? false : ($offset + ($pos ? self::iconv_strlen(substr($haystack, 0, $pos), 'utf-8') : 0));
|
||||
}
|
||||
|
||||
public static function iconv_strrpos($haystack, $needle, $encoding = null)
|
||||
{
|
||||
if (null === $encoding) {
|
||||
$encoding = self::$internalEncoding;
|
||||
}
|
||||
|
||||
if (0 !== stripos($encoding, 'utf-8')) {
|
||||
if (false === $haystack = self::iconv($encoding, 'utf-8', $haystack)) {
|
||||
return false;
|
||||
}
|
||||
if (false === $needle = self::iconv($encoding, 'utf-8', $needle)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$pos = isset($needle[0]) ? strrpos($haystack, $needle) : false;
|
||||
|
||||
return false === $pos ? false : self::iconv_strlen($pos ? substr($haystack, 0, $pos) : $haystack, 'utf-8');
|
||||
}
|
||||
|
||||
public static function iconv_substr($s, $start, $length = 2147483647, $encoding = null)
|
||||
{
|
||||
if (null === $encoding) {
|
||||
$encoding = self::$internalEncoding;
|
||||
}
|
||||
if (0 !== stripos($encoding, 'utf-8')) {
|
||||
$encoding = null;
|
||||
} elseif (false === $s = self::iconv($encoding, 'utf-8', $s)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$s = (string) $s;
|
||||
$slen = self::iconv_strlen($s, 'utf-8');
|
||||
$start = (int) $start;
|
||||
|
||||
if (0 > $start) {
|
||||
$start += $slen;
|
||||
}
|
||||
if (0 > $start) {
|
||||
if (\PHP_VERSION_ID < 80000) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$start = 0;
|
||||
}
|
||||
if ($start >= $slen) {
|
||||
return \PHP_VERSION_ID >= 80000 ? '' : false;
|
||||
}
|
||||
|
||||
$rx = $slen - $start;
|
||||
|
||||
if (0 > $length) {
|
||||
$length += $rx;
|
||||
}
|
||||
if (0 === $length) {
|
||||
return '';
|
||||
}
|
||||
if (0 > $length) {
|
||||
return \PHP_VERSION_ID >= 80000 ? '' : false;
|
||||
}
|
||||
|
||||
if ($length > $rx) {
|
||||
$length = $rx;
|
||||
}
|
||||
|
||||
$rx = '/^'.($start ? self::pregOffset($start) : '').'('.self::pregOffset($length).')/u';
|
||||
|
||||
$s = preg_match($rx, $s, $s) ? $s[1] : '';
|
||||
|
||||
if (null === $encoding) {
|
||||
return $s;
|
||||
}
|
||||
|
||||
return self::iconv('utf-8', $encoding, $s);
|
||||
}
|
||||
|
||||
private static function loadMap($type, $charset, &$map)
|
||||
{
|
||||
if (!isset(self::$convertMap[$type.$charset])) {
|
||||
if (false === $map = self::getData($type.$charset)) {
|
||||
if ('to.' === $type && self::loadMap('from.', $charset, $map)) {
|
||||
$map = array_flip($map);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
self::$convertMap[$type.$charset] = $map;
|
||||
} else {
|
||||
$map = self::$convertMap[$type.$charset];
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static function utf8ToUtf8($str, $ignore)
|
||||
{
|
||||
$ulenMask = self::$ulenMask;
|
||||
$valid = self::$isValidUtf8;
|
||||
|
||||
$u = $str;
|
||||
$i = $j = 0;
|
||||
$len = \strlen($str);
|
||||
|
||||
while ($i < $len) {
|
||||
if ($str[$i] < "\x80") {
|
||||
$u[$j++] = $str[$i++];
|
||||
} else {
|
||||
$ulen = $str[$i] & "\xF0";
|
||||
$ulen = $ulenMask[$ulen] ?? 1;
|
||||
$uchr = substr($str, $i, $ulen);
|
||||
|
||||
if (1 === $ulen || !($valid || preg_match('/^.$/us', $uchr))) {
|
||||
if ($ignore) {
|
||||
++$i;
|
||||
continue;
|
||||
}
|
||||
|
||||
trigger_error(self::ERROR_ILLEGAL_CHARACTER);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$i += $ulen;
|
||||
|
||||
$u[$j++] = $uchr[0];
|
||||
|
||||
isset($uchr[1]) && 0 !== ($u[$j++] = $uchr[1])
|
||||
&& isset($uchr[2]) && 0 !== ($u[$j++] = $uchr[2])
|
||||
&& isset($uchr[3]) && 0 !== ($u[$j++] = $uchr[3]);
|
||||
}
|
||||
}
|
||||
|
||||
return substr($u, 0, $j);
|
||||
}
|
||||
|
||||
private static function mapToUtf8(&$result, array $map, $str, $ignore)
|
||||
{
|
||||
$len = \strlen($str);
|
||||
for ($i = 0; $i < $len; ++$i) {
|
||||
if (isset($str[$i + 1], $map[$str[$i].$str[$i + 1]])) {
|
||||
$result .= $map[$str[$i].$str[++$i]];
|
||||
} elseif (isset($map[$str[$i]])) {
|
||||
$result .= $map[$str[$i]];
|
||||
} elseif (!$ignore) {
|
||||
trigger_error(self::ERROR_ILLEGAL_CHARACTER);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static function mapFromUtf8(&$result, array $map, $str, $ignore, $translit)
|
||||
{
|
||||
$ulenMask = self::$ulenMask;
|
||||
$valid = self::$isValidUtf8;
|
||||
|
||||
if ($translit && !self::$translitMap) {
|
||||
self::$translitMap = self::getData('translit');
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
$len = \strlen($str);
|
||||
|
||||
while ($i < $len) {
|
||||
if ($str[$i] < "\x80") {
|
||||
$uchr = $str[$i++];
|
||||
} else {
|
||||
$ulen = $str[$i] & "\xF0";
|
||||
$ulen = $ulenMask[$ulen] ?? 1;
|
||||
$uchr = substr($str, $i, $ulen);
|
||||
|
||||
if ($ignore && (1 === $ulen || !($valid || preg_match('/^.$/us', $uchr)))) {
|
||||
++$i;
|
||||
continue;
|
||||
}
|
||||
|
||||
$i += $ulen;
|
||||
}
|
||||
|
||||
if (isset($map[$uchr])) {
|
||||
$result .= $map[$uchr];
|
||||
} elseif ($translit) {
|
||||
if (isset(self::$translitMap[$uchr])) {
|
||||
$uchr = self::$translitMap[$uchr];
|
||||
} elseif ($uchr >= "\xC3\x80") {
|
||||
$uchr = \Normalizer::normalize($uchr, \Normalizer::NFD);
|
||||
|
||||
if ($uchr[0] < "\x80") {
|
||||
$uchr = $uchr[0];
|
||||
} elseif ($ignore) {
|
||||
continue;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} elseif ($ignore) {
|
||||
continue;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
$str = $uchr.substr($str, $i);
|
||||
$len = \strlen($str);
|
||||
$i = 0;
|
||||
} elseif (!$ignore) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static function qpByteCallback(array $m)
|
||||
{
|
||||
return '='.strtoupper(dechex(\ord($m[0])));
|
||||
}
|
||||
|
||||
private static function pregOffset($offset)
|
||||
{
|
||||
$rx = [];
|
||||
$offset = (int) $offset;
|
||||
|
||||
while ($offset > 65535) {
|
||||
$rx[] = '.{65535}';
|
||||
$offset -= 65535;
|
||||
}
|
||||
|
||||
return implode('', $rx).'.{'.$offset.'}';
|
||||
}
|
||||
|
||||
private static function getData($file)
|
||||
{
|
||||
if (file_exists($file = __DIR__.'/Resources/charset/'.$file.'.php')) {
|
||||
return require $file;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
19
include/thirdparty/polyfills/Iconv/LICENSE
vendored
Normal file
19
include/thirdparty/polyfills/Iconv/LICENSE
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
Copyright (c) 2015-present Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
14
include/thirdparty/polyfills/Iconv/README.md
vendored
Normal file
14
include/thirdparty/polyfills/Iconv/README.md
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
Symfony Polyfill / Iconv
|
||||
========================
|
||||
|
||||
This component provides a native PHP implementation of the
|
||||
[php.net/iconv](https://php.net/iconv) functions
|
||||
(short of [`ob_iconv_handler`](https://php.net/ob-iconv-handler)).
|
||||
|
||||
More information can be found in the
|
||||
[main Polyfill README](https://github.com/symfony/polyfill/blob/main/README.md).
|
||||
|
||||
License
|
||||
=======
|
||||
|
||||
This library is released under the [MIT license](LICENSE).
|
13719
include/thirdparty/polyfills/Iconv/Resources/charset/from.big5.php
vendored
Normal file
13719
include/thirdparty/polyfills/Iconv/Resources/charset/from.big5.php
vendored
Normal file
File diff suppressed because it is too large
Load diff
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp037.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp037.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp1006.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp1006.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp1026.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp1026.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp424.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp424.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp437.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp437.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp500.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp500.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp737.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp737.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp775.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp775.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp850.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp850.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp852.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp852.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp855.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp855.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp856.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp856.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp857.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp857.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp860.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp860.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp861.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp861.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp862.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp862.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp863.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp863.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp864.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp864.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp865.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp865.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp866.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp866.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp869.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp869.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp874.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp874.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp875.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp875.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp932.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp932.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp936.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp936.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp949.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp949.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp950.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.cp950.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.iso-8859-1.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.iso-8859-1.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.iso-8859-10.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.iso-8859-10.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.iso-8859-11.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.iso-8859-11.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.iso-8859-13.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.iso-8859-13.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.iso-8859-14.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.iso-8859-14.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.iso-8859-15.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.iso-8859-15.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.iso-8859-16.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.iso-8859-16.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.iso-8859-2.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.iso-8859-2.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.iso-8859-3.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.iso-8859-3.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.iso-8859-4.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.iso-8859-4.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.iso-8859-5.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.iso-8859-5.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.iso-8859-6.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.iso-8859-6.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.iso-8859-7.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.iso-8859-7.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.iso-8859-8.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.iso-8859-8.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.iso-8859-9.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.iso-8859-9.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.koi8-r.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.koi8-r.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.koi8-u.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.koi8-u.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.us-ascii.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.us-ascii.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.windows-1250.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.windows-1250.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.windows-1251.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.windows-1251.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.windows-1252.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.windows-1252.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.windows-1253.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.windows-1253.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.windows-1254.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.windows-1254.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.windows-1255.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.windows-1255.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.windows-1256.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.windows-1256.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.windows-1257.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.windows-1257.php
vendored
Normal file
Binary file not shown.
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.windows-1258.php
vendored
Normal file
BIN
include/thirdparty/polyfills/Iconv/Resources/charset/from.windows-1258.php
vendored
Normal file
Binary file not shown.
4106
include/thirdparty/polyfills/Iconv/Resources/charset/translit.php
vendored
Normal file
4106
include/thirdparty/polyfills/Iconv/Resources/charset/translit.php
vendored
Normal file
File diff suppressed because it is too large
Load diff
84
include/thirdparty/polyfills/Iconv/bootstrap.php
vendored
Normal file
84
include/thirdparty/polyfills/Iconv/bootstrap.php
vendored
Normal file
|
@ -0,0 +1,84 @@
|
|||
<?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 (extension_loaded('iconv')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (\PHP_VERSION_ID >= 80000) {
|
||||
return require __DIR__.'/bootstrap80.php';
|
||||
}
|
||||
|
||||
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_encoding, $to_encoding, $string) { return p\Iconv::iconv($from_encoding, $to_encoding, $string); }
|
||||
}
|
||||
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, $encoding) { return p\Iconv::iconv_set_encoding($type, $encoding); }
|
||||
}
|
||||
if (!function_exists('iconv_mime_encode')) {
|
||||
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); }
|
||||
}
|
||||
|
||||
if (extension_loaded('mbstring')) {
|
||||
if (!function_exists('iconv_strlen')) {
|
||||
function iconv_strlen($string, $encoding = null) { null === $encoding && $encoding = p\Iconv::$internalEncoding; return mb_strlen($string, $encoding); }
|
||||
}
|
||||
if (!function_exists('iconv_strpos')) {
|
||||
function iconv_strpos($haystack, $needle, $offset = 0, $encoding = null) { null === $encoding && $encoding = p\Iconv::$internalEncoding; return mb_strpos($haystack, $needle, $offset, $encoding); }
|
||||
}
|
||||
if (!function_exists('iconv_strrpos')) {
|
||||
function iconv_strrpos($haystack, $needle, $encoding = null) { null === $encoding && $encoding = p\Iconv::$internalEncoding; return mb_strrpos($haystack, $needle, 0, $encoding); }
|
||||
}
|
||||
if (!function_exists('iconv_substr')) {
|
||||
function iconv_substr($string, $offset, $length = 2147483647, $encoding = null) { 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) { $currentMbEncoding = mb_internal_encoding(); null === $encoding && $encoding = p\Iconv::$internalEncoding; mb_internal_encoding($encoding); $decoded = mb_decode_mimeheader($string); mb_internal_encoding($currentMbEncoding); return $decoded; }
|
||||
}
|
||||
} else {
|
||||
if (!function_exists('iconv_strlen')) {
|
||||
function iconv_strlen($string, $encoding = null) { return p\Iconv::iconv_strlen($string, $encoding); }
|
||||
}
|
||||
|
||||
if (!function_exists('iconv_strpos')) {
|
||||
function iconv_strpos($haystack, $needle, $offset = 0, $encoding = null) { return p\Iconv::iconv_strpos($haystack, $needle, $offset, $encoding); }
|
||||
}
|
||||
if (!function_exists('iconv_strrpos')) {
|
||||
function iconv_strrpos($haystack, $needle, $encoding = null) { return p\Iconv::iconv_strrpos($haystack, $needle, $encoding); }
|
||||
}
|
||||
if (!function_exists('iconv_substr')) {
|
||||
function iconv_substr($string, $offset, $length = 2147483647, $encoding = null) { return p\Iconv::iconv_substr($string, $offset, $length, $encoding); }
|
||||
}
|
||||
if (!function_exists('iconv_mime_decode')) {
|
||||
function iconv_mime_decode($string, $mode = 0, $encoding = null) { return p\Iconv::iconv_mime_decode($string, $mode, $encoding); }
|
||||
}
|
||||
}
|
76
include/thirdparty/polyfills/Iconv/bootstrap80.php
vendored
Normal file
76
include/thirdparty/polyfills/Iconv/bootstrap80.php
vendored
Normal file
|
@ -0,0 +1,76 @@
|
|||
<?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((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((string) $type); }
|
||||
}
|
||||
if (!function_exists('iconv_set_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((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((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) $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((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((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) $string, (int) $offset, $length, $encoding); }
|
||||
}
|
||||
if (!function_exists('iconv_mime_decode')) {
|
||||
function iconv_mime_decode($string, $mode = 0, $encoding = null) { $currentMbEncoding = mb_internal_encoding(); null === $encoding && $encoding = p\Iconv::$internalEncoding; mb_internal_encoding($encoding); $decoded = mb_decode_mimeheader($string); mb_internal_encoding($currentMbEncoding); return $decoded; }
|
||||
}
|
||||
} else {
|
||||
if (!function_exists('iconv_strlen')) {
|
||||
function iconv_strlen(?string $string, ?string $encoding = null): int|false { return p\Iconv::iconv_strlen((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((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((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) $string, (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) $string, (int) $mode, $encoding); }
|
||||
}
|
||||
}
|
279
include/thirdparty/polyfills/Intl/Grapheme/Grapheme.php
vendored
Normal file
279
include/thirdparty/polyfills/Intl/Grapheme/Grapheme.php
vendored
Normal file
|
@ -0,0 +1,279 @@
|
|||
<?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.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Intl\Grapheme;
|
||||
|
||||
\define('SYMFONY_GRAPHEME_CLUSTER_RX', ((float) \PCRE_VERSION < 10 ? (float) \PCRE_VERSION >= 8.32 : (float) \PCRE_VERSION >= 10.39) ? '\X' : Grapheme::GRAPHEME_CLUSTER_RX);
|
||||
|
||||
/**
|
||||
* Partial intl implementation in pure PHP.
|
||||
*
|
||||
* Implemented:
|
||||
* - grapheme_extract - Extract a sequence of grapheme clusters from a text buffer, which must be encoded in UTF-8
|
||||
* - grapheme_stripos - Find position (in grapheme units) of first occurrence of a case-insensitive string
|
||||
* - grapheme_stristr - Returns part of haystack string from the first occurrence of case-insensitive needle to the end of haystack
|
||||
* - grapheme_strlen - Get string length in grapheme units
|
||||
* - grapheme_strpos - Find position (in grapheme units) of first occurrence of a string
|
||||
* - grapheme_strripos - Find position (in grapheme units) of last occurrence of a case-insensitive string
|
||||
* - grapheme_strrpos - Find position (in grapheme units) of last occurrence of a string
|
||||
* - grapheme_strstr - Returns part of haystack string from the first occurrence of needle to the end of haystack
|
||||
* - grapheme_substr - Return part of a string
|
||||
* - grapheme_str_split - Splits a string into an array of individual or chunks of graphemes
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
final class Grapheme
|
||||
{
|
||||
// (CRLF|([ZWNJ-ZWJ]|T+|L*(LV?V+|LV|LVT)T*|L+|[^Control])[Extend]*|[Control])
|
||||
// This regular expression is a work around for http://bugs.exim.org/1279
|
||||
public const GRAPHEME_CLUSTER_RX = '(?:\r\n|(?:[ -~\x{200C}\x{200D}]|[ᆨ-ᇹ]+|[ᄀ-ᅟ]*(?:[가개갸걔거게겨계고과괘괴교구궈궤귀규그긔기까깨꺄꺠꺼께껴꼐꼬꽈꽤꾀꾜꾸꿔꿰뀌뀨끄끠끼나내냐냬너네녀녜노놔놰뇌뇨누눠눼뉘뉴느늬니다대댜댸더데뎌뎨도돠돼되됴두둬뒈뒤듀드듸디따때땨떄떠떼뗘뗴또똬뙈뙤뚀뚜뚸뛔뛰뜌뜨띄띠라래랴럐러레려례로롸뢔뢰료루뤄뤠뤼류르릐리마매먀먜머메며몌모뫄뫠뫼묘무뭐뭬뮈뮤므믜미바배뱌뱨버베벼볘보봐봬뵈뵤부붜붸뷔뷰브븨비빠빼뺘뺴뻐뻬뼈뼤뽀뽜뽸뾔뾰뿌뿨쀄쀠쀼쁘쁴삐사새샤섀서세셔셰소솨쇄쇠쇼수숴쉐쉬슈스싀시싸쌔쌰썌써쎄쎠쎼쏘쏴쐐쐬쑈쑤쒀쒜쒸쓔쓰씌씨아애야얘어에여예오와왜외요우워웨위유으의이자재쟈쟤저제져졔조좌좨죄죠주줘줴쥐쥬즈즤지짜째쨔쨰쩌쩨쪄쪠쪼쫘쫴쬐쬬쭈쭤쮀쮜쮸쯔쯰찌차채챠챼처체쳐쳬초촤쵀최쵸추춰췌취츄츠츼치카캐캬컈커케켜켸코콰쾌쾨쿄쿠쿼퀘퀴큐크킈키타태탸턔터테텨톄토톼퇘퇴툐투퉈퉤튀튜트틔티파패퍄퍠퍼페펴폐포퐈퐤푀표푸풔풰퓌퓨프픠피하해햐햬허헤혀혜호화홰회효후훠훼휘휴흐희히]?[ᅠ-ᆢ]+|[가-힣])[ᆨ-ᇹ]*|[ᄀ-ᅟ]+|[^\p{Cc}\p{Cf}\p{Zl}\p{Zp}])[\p{Mn}\p{Me}\x{09BE}\x{09D7}\x{0B3E}\x{0B57}\x{0BBE}\x{0BD7}\x{0CC2}\x{0CD5}\x{0CD6}\x{0D3E}\x{0D57}\x{0DCF}\x{0DDF}\x{200C}\x{200D}\x{1D165}\x{1D16E}-\x{1D172}]*|[\p{Cc}\p{Cf}\p{Zl}\p{Zp}])';
|
||||
|
||||
private const CASE_FOLD = [
|
||||
['µ', 'ſ', "\xCD\x85", 'ς', "\xCF\x90", "\xCF\x91", "\xCF\x95", "\xCF\x96", "\xCF\xB0", "\xCF\xB1", "\xCF\xB5", "\xE1\xBA\x9B", "\xE1\xBE\xBE"],
|
||||
['μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', 'ρ', 'ε', "\xE1\xB9\xA1", 'ι'],
|
||||
];
|
||||
|
||||
public static function grapheme_extract($s, $size, $type = \GRAPHEME_EXTR_COUNT, $start = 0, &$next = 0)
|
||||
{
|
||||
if (0 > $start) {
|
||||
$start = \strlen($s) + $start;
|
||||
}
|
||||
|
||||
if (!\is_scalar($s)) {
|
||||
$hasError = false;
|
||||
set_error_handler(function () use (&$hasError) { $hasError = true; });
|
||||
$next = substr($s, $start);
|
||||
restore_error_handler();
|
||||
if ($hasError) {
|
||||
substr($s, $start);
|
||||
$s = '';
|
||||
} else {
|
||||
$s = $next;
|
||||
}
|
||||
} else {
|
||||
$s = substr($s, $start);
|
||||
}
|
||||
$size = (int) $size;
|
||||
$type = (int) $type;
|
||||
$start = (int) $start;
|
||||
|
||||
if (\GRAPHEME_EXTR_COUNT !== $type && \GRAPHEME_EXTR_MAXBYTES !== $type && \GRAPHEME_EXTR_MAXCHARS !== $type) {
|
||||
if (80000 > \PHP_VERSION_ID) {
|
||||
return false;
|
||||
}
|
||||
|
||||
throw new \ValueError('grapheme_extract(): Argument #3 ($type) must be one of GRAPHEME_EXTR_COUNT, GRAPHEME_EXTR_MAXBYTES, or GRAPHEME_EXTR_MAXCHARS');
|
||||
}
|
||||
|
||||
if (!isset($s[0]) || 0 > $size || 0 > $start) {
|
||||
return false;
|
||||
}
|
||||
if (0 === $size) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$next = $start;
|
||||
|
||||
$s = preg_split('/('.SYMFONY_GRAPHEME_CLUSTER_RX.')/u', "\r\n".$s, $size + 1, \PREG_SPLIT_NO_EMPTY | \PREG_SPLIT_DELIM_CAPTURE);
|
||||
|
||||
if (!isset($s[1])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$i = 1;
|
||||
$ret = '';
|
||||
|
||||
do {
|
||||
if (\GRAPHEME_EXTR_COUNT === $type) {
|
||||
--$size;
|
||||
} elseif (\GRAPHEME_EXTR_MAXBYTES === $type) {
|
||||
$size -= \strlen($s[$i]);
|
||||
} else {
|
||||
$size -= iconv_strlen($s[$i], 'UTF-8//IGNORE');
|
||||
}
|
||||
|
||||
if ($size >= 0) {
|
||||
$ret .= $s[$i];
|
||||
}
|
||||
} while (isset($s[++$i]) && $size > 0);
|
||||
|
||||
$next += \strlen($ret);
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function grapheme_strlen($s)
|
||||
{
|
||||
preg_replace('/'.SYMFONY_GRAPHEME_CLUSTER_RX.'/u', '', $s, -1, $len);
|
||||
|
||||
return 0 === $len && '' !== $s ? null : $len;
|
||||
}
|
||||
|
||||
public static function grapheme_substr($s, $start, $len = null)
|
||||
{
|
||||
if (null === $len) {
|
||||
$len = 2147483647;
|
||||
}
|
||||
|
||||
preg_match_all('/'.SYMFONY_GRAPHEME_CLUSTER_RX.'/u', $s, $s);
|
||||
|
||||
$slen = \count($s[0]);
|
||||
$start = (int) $start;
|
||||
|
||||
if (0 > $start) {
|
||||
$start += $slen;
|
||||
}
|
||||
if (0 > $start) {
|
||||
if (\PHP_VERSION_ID < 80000) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$start = 0;
|
||||
}
|
||||
if ($start >= $slen) {
|
||||
return \PHP_VERSION_ID >= 80000 ? '' : false;
|
||||
}
|
||||
|
||||
$rem = $slen - $start;
|
||||
|
||||
if (0 > $len) {
|
||||
$len += $rem;
|
||||
}
|
||||
if (0 === $len) {
|
||||
return '';
|
||||
}
|
||||
if (0 > $len) {
|
||||
return \PHP_VERSION_ID >= 80000 ? '' : false;
|
||||
}
|
||||
if ($len > $rem) {
|
||||
$len = $rem;
|
||||
}
|
||||
|
||||
return implode('', \array_slice($s[0], $start, $len));
|
||||
}
|
||||
|
||||
public static function grapheme_strpos($s, $needle, $offset = 0)
|
||||
{
|
||||
return self::grapheme_position($s, $needle, $offset, 0);
|
||||
}
|
||||
|
||||
public static function grapheme_stripos($s, $needle, $offset = 0)
|
||||
{
|
||||
return self::grapheme_position($s, $needle, $offset, 1);
|
||||
}
|
||||
|
||||
public static function grapheme_strrpos($s, $needle, $offset = 0)
|
||||
{
|
||||
return self::grapheme_position($s, $needle, $offset, 2);
|
||||
}
|
||||
|
||||
public static function grapheme_strripos($s, $needle, $offset = 0)
|
||||
{
|
||||
return self::grapheme_position($s, $needle, $offset, 3);
|
||||
}
|
||||
|
||||
public static function grapheme_stristr($s, $needle, $beforeNeedle = false)
|
||||
{
|
||||
return mb_stristr($s, $needle, $beforeNeedle, 'UTF-8');
|
||||
}
|
||||
|
||||
public static function grapheme_strstr($s, $needle, $beforeNeedle = false)
|
||||
{
|
||||
return mb_strstr($s, $needle, $beforeNeedle, 'UTF-8');
|
||||
}
|
||||
|
||||
public static function grapheme_str_split($s, $len = 1)
|
||||
{
|
||||
if (0 > $len || 1073741823 < $len) {
|
||||
if (80000 > \PHP_VERSION_ID) {
|
||||
return false;
|
||||
}
|
||||
|
||||
throw new \ValueError('grapheme_str_split(): Argument #2 ($length) must be greater than 0 and less than or equal to 1073741823.');
|
||||
}
|
||||
|
||||
if ('' === $s) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (!preg_match_all('/('.SYMFONY_GRAPHEME_CLUSTER_RX.')/u', $s, $matches)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (1 === $len) {
|
||||
return $matches[0];
|
||||
}
|
||||
|
||||
$chunks = array_chunk($matches[0], $len);
|
||||
|
||||
foreach ($chunks as &$chunk) {
|
||||
$chunk = implode('', $chunk);
|
||||
}
|
||||
|
||||
return $chunks;
|
||||
}
|
||||
|
||||
private static function grapheme_position($s, $needle, $offset, $mode)
|
||||
{
|
||||
$needle = (string) $needle;
|
||||
if (80000 > \PHP_VERSION_ID && !preg_match('/./us', $needle)) {
|
||||
return false;
|
||||
}
|
||||
$s = (string) $s;
|
||||
if (!preg_match('/./us', $s)) {
|
||||
return false;
|
||||
}
|
||||
if ($offset > 0) {
|
||||
$s = self::grapheme_substr($s, $offset);
|
||||
} elseif ($offset < 0) {
|
||||
if (2 > $mode) {
|
||||
$offset += self::grapheme_strlen($s);
|
||||
$s = self::grapheme_substr($s, $offset);
|
||||
if (0 > $offset) {
|
||||
$offset = 0;
|
||||
}
|
||||
} elseif (0 > $offset += self::grapheme_strlen($needle)) {
|
||||
$s = self::grapheme_substr($s, 0, $offset);
|
||||
$offset = 0;
|
||||
} else {
|
||||
$offset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// As UTF-8 is self-synchronizing, and we have ensured the strings are valid UTF-8,
|
||||
// we can use normal binary string functions here. For case-insensitive searches,
|
||||
// case fold the strings first.
|
||||
$caseInsensitive = $mode & 1;
|
||||
$reverse = $mode & 2;
|
||||
if ($caseInsensitive) {
|
||||
// Use the same case folding mode as mbstring does for mb_stripos().
|
||||
// Stick to SIMPLE case folding to avoid changing the length of the string, which
|
||||
// might result in offsets being shifted.
|
||||
$mode = \defined('MB_CASE_FOLD_SIMPLE') ? \MB_CASE_FOLD_SIMPLE : \MB_CASE_LOWER;
|
||||
$s = mb_convert_case($s, $mode, 'UTF-8');
|
||||
$needle = mb_convert_case($needle, $mode, 'UTF-8');
|
||||
|
||||
if (!\defined('MB_CASE_FOLD_SIMPLE')) {
|
||||
$s = str_replace(self::CASE_FOLD[0], self::CASE_FOLD[1], $s);
|
||||
$needle = str_replace(self::CASE_FOLD[0], self::CASE_FOLD[1], $needle);
|
||||
}
|
||||
}
|
||||
if ($reverse) {
|
||||
$needlePos = strrpos($s, $needle);
|
||||
} else {
|
||||
$needlePos = strpos($s, $needle);
|
||||
}
|
||||
|
||||
return false !== $needlePos ? self::grapheme_strlen(substr($s, 0, $needlePos)) + $offset : false;
|
||||
}
|
||||
}
|
19
include/thirdparty/polyfills/Intl/Grapheme/LICENSE
vendored
Normal file
19
include/thirdparty/polyfills/Intl/Grapheme/LICENSE
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
Copyright (c) 2015-present Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
32
include/thirdparty/polyfills/Intl/Grapheme/README.md
vendored
Normal file
32
include/thirdparty/polyfills/Intl/Grapheme/README.md
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
Symfony Polyfill / Intl: Grapheme
|
||||
=================================
|
||||
|
||||
This component provides a partial, native PHP implementation of the
|
||||
[Grapheme functions](https://php.net/intl.grapheme) from the
|
||||
[Intl](https://php.net/intl) extension.
|
||||
|
||||
- [`grapheme_extract`](https://php.net/grapheme_extract): Extract a sequence of grapheme
|
||||
clusters from a text buffer, which must be encoded in UTF-8
|
||||
- [`grapheme_stripos`](https://php.net/grapheme_stripos): Find position (in grapheme units)
|
||||
of first occurrence of a case-insensitive string
|
||||
- [`grapheme_stristr`](https://php.net/grapheme_stristr): Returns part of haystack string
|
||||
from the first occurrence of case-insensitive needle to the end of haystack
|
||||
- [`grapheme_strlen`](https://php.net/grapheme_strlen): Get string length in grapheme units
|
||||
- [`grapheme_strpos`](https://php.net/grapheme_strpos): Find position (in grapheme units)
|
||||
of first occurrence of a string
|
||||
- [`grapheme_strripos`](https://php.net/grapheme_strripos): Find position (in grapheme units)
|
||||
of last occurrence of a case-insensitive string
|
||||
- [`grapheme_strrpos`](https://php.net/grapheme_strrpos): Find position (in grapheme units)
|
||||
of last occurrence of a string
|
||||
- [`grapheme_strstr`](https://php.net/grapheme_strstr): Returns part of haystack string from
|
||||
the first occurrence of needle to the end of haystack
|
||||
- [`grapheme_substr`](https://php.net/grapheme_substr): Return part of a string
|
||||
- [`grapheme_str_split`](https://php.net/grapheme_str_split): Splits a string into an array of individual or chunks of graphemes
|
||||
|
||||
More information can be found in the
|
||||
[main Polyfill README](https://github.com/symfony/polyfill/blob/main/README.md).
|
||||
|
||||
License
|
||||
=======
|
||||
|
||||
This library is released under the [MIT license](LICENSE).
|
57
include/thirdparty/polyfills/Intl/Grapheme/bootstrap.php
vendored
Normal file
57
include/thirdparty/polyfills/Intl/Grapheme/bootstrap.php
vendored
Normal file
|
@ -0,0 +1,57 @@
|
|||
<?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\Intl\Grapheme as p;
|
||||
|
||||
if (\PHP_VERSION_ID >= 80000) {
|
||||
return require __DIR__.'/bootstrap80.php';
|
||||
}
|
||||
|
||||
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_extract')) {
|
||||
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, $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); }
|
||||
}
|
||||
if (!function_exists('grapheme_strpos')) {
|
||||
function grapheme_strpos($haystack, $needle, $offset = 0) { return p\Grapheme::grapheme_strpos($haystack, $needle, $offset); }
|
||||
}
|
||||
if (!function_exists('grapheme_strripos')) {
|
||||
function grapheme_strripos($haystack, $needle, $offset = 0) { return p\Grapheme::grapheme_strripos($haystack, $needle, $offset); }
|
||||
}
|
||||
if (!function_exists('grapheme_strrpos')) {
|
||||
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, $beforeNeedle = false) { return p\Grapheme::grapheme_strstr($haystack, $needle, $beforeNeedle); }
|
||||
}
|
||||
if (!function_exists('grapheme_substr')) {
|
||||
function grapheme_substr($string, $offset, $length = null) { return p\Grapheme::grapheme_substr($string, $offset, $length); }
|
||||
}
|
||||
if (!function_exists('grapheme_str_split')) {
|
||||
function grapheme_str_split($string, $length = 1) { return p\Grapheme::grapheme_str_split($string, $length); }
|
||||
}
|
58
include/thirdparty/polyfills/Intl/Grapheme/bootstrap80.php
vendored
Normal file
58
include/thirdparty/polyfills/Intl/Grapheme/bootstrap80.php
vendored
Normal file
|
@ -0,0 +1,58 @@
|
|||
<?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\Intl\Grapheme as p;
|
||||
|
||||
if (!function_exists('grapheme_str_split')) {
|
||||
function grapheme_str_split(string $string, int $length = 1): array|false { return p\Grapheme::grapheme_str_split($string, $length); }
|
||||
}
|
||||
|
||||
if (extension_loaded('intl')) {
|
||||
return;
|
||||
}
|
||||
|
||||
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_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((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((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((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) $string); }
|
||||
}
|
||||
if (!function_exists('grapheme_strpos')) {
|
||||
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((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((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((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) $string, (int) $offset, $length); }
|
||||
}
|
262
include/thirdparty/polyfills/Intl/Icu/Collator.php
vendored
Normal file
262
include/thirdparty/polyfills/Intl/Icu/Collator.php
vendored
Normal file
|
@ -0,0 +1,262 @@
|
|||
<?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.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Intl\Icu;
|
||||
|
||||
use Symfony\Polyfill\Intl\Icu\Exception\MethodArgumentValueNotImplementedException;
|
||||
use Symfony\Polyfill\Intl\Icu\Exception\MethodNotImplementedException;
|
||||
|
||||
/**
|
||||
* Replacement for PHP's native {@link \Collator} class.
|
||||
*
|
||||
* The only methods currently supported in this class are:
|
||||
*
|
||||
* - {@link \__construct}
|
||||
* - {@link create}
|
||||
* - {@link asort}
|
||||
* - {@link getErrorCode}
|
||||
* - {@link getErrorMessage}
|
||||
* - {@link getLocale}
|
||||
*
|
||||
* @author Igor Wiedler <igor@wiedler.ch>
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
abstract class Collator
|
||||
{
|
||||
/* Attribute constants */
|
||||
public const FRENCH_COLLATION = 0;
|
||||
public const ALTERNATE_HANDLING = 1;
|
||||
public const CASE_FIRST = 2;
|
||||
public const CASE_LEVEL = 3;
|
||||
public const NORMALIZATION_MODE = 4;
|
||||
public const STRENGTH = 5;
|
||||
public const HIRAGANA_QUATERNARY_MODE = 6;
|
||||
public const NUMERIC_COLLATION = 7;
|
||||
|
||||
/* Attribute constants values */
|
||||
public const DEFAULT_VALUE = -1;
|
||||
|
||||
public const PRIMARY = 0;
|
||||
public const SECONDARY = 1;
|
||||
public const TERTIARY = 2;
|
||||
public const DEFAULT_STRENGTH = 2;
|
||||
public const QUATERNARY = 3;
|
||||
public const IDENTICAL = 15;
|
||||
|
||||
public const OFF = 16;
|
||||
public const ON = 17;
|
||||
|
||||
public const SHIFTED = 20;
|
||||
public const NON_IGNORABLE = 21;
|
||||
|
||||
public const LOWER_FIRST = 24;
|
||||
public const UPPER_FIRST = 25;
|
||||
|
||||
/* Sorting options */
|
||||
public const SORT_REGULAR = 0;
|
||||
public const SORT_NUMERIC = 2;
|
||||
public const SORT_STRING = 1;
|
||||
|
||||
/**
|
||||
* @param string|null $locale The locale code. The only currently supported locale is "en" (or null using the default locale, i.e. "en")
|
||||
*
|
||||
* @throws MethodArgumentValueNotImplementedException When $locale different than "en" or null is passed
|
||||
*/
|
||||
public function __construct(?string $locale)
|
||||
{
|
||||
if ('en' !== $locale && null !== $locale) {
|
||||
throw new MethodArgumentValueNotImplementedException(__METHOD__, 'locale', $locale, 'Only the locale "en" is supported');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Static constructor.
|
||||
*
|
||||
* @param string|null $locale The locale code. The only currently supported locale is "en" (or null using the default locale, i.e. "en")
|
||||
*
|
||||
* @return static
|
||||
*
|
||||
* @throws MethodArgumentValueNotImplementedException When $locale different than "en" or null is passed
|
||||
*/
|
||||
public static function create(?string $locale)
|
||||
{
|
||||
return new static($locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort array maintaining index association.
|
||||
*
|
||||
* @param array &$array Input array
|
||||
* @param int $flags Flags for sorting, can be one of the following:
|
||||
* Collator::SORT_REGULAR - compare items normally (don't change types)
|
||||
* Collator::SORT_NUMERIC - compare items numerically
|
||||
* Collator::SORT_STRING - compare items as strings
|
||||
*
|
||||
* @return bool True on success or false on failure
|
||||
*/
|
||||
public function asort(array &$array, int $flags = self::SORT_REGULAR)
|
||||
{
|
||||
$intlToPlainFlagMap = [
|
||||
self::SORT_REGULAR => \SORT_REGULAR,
|
||||
self::SORT_NUMERIC => \SORT_NUMERIC,
|
||||
self::SORT_STRING => \SORT_STRING,
|
||||
];
|
||||
|
||||
$plainSortFlag = $intlToPlainFlagMap[$flags] ?? self::SORT_REGULAR;
|
||||
|
||||
return asort($array, $plainSortFlag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Not supported. Compare two Unicode strings.
|
||||
*
|
||||
* @return int|false
|
||||
*
|
||||
* @see https://php.net/collator.compare
|
||||
*
|
||||
* @throws MethodNotImplementedException
|
||||
*/
|
||||
public function compare(string $string1, string $string2)
|
||||
{
|
||||
throw new MethodNotImplementedException(__METHOD__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Not supported. Get a value of an integer collator attribute.
|
||||
*
|
||||
* @return int|false The attribute value on success or false on error
|
||||
*
|
||||
* @see https://php.net/collator.getattribute
|
||||
*
|
||||
* @throws MethodNotImplementedException
|
||||
*/
|
||||
public function getAttribute(int $attribute)
|
||||
{
|
||||
throw new MethodNotImplementedException(__METHOD__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns collator's last error code. Always returns the U_ZERO_ERROR class constant value.
|
||||
*
|
||||
* @return int|false The error code from last collator call
|
||||
*/
|
||||
public function getErrorCode()
|
||||
{
|
||||
return Icu::U_ZERO_ERROR;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns collator's last error message. Always returns the U_ZERO_ERROR_MESSAGE class constant value.
|
||||
*
|
||||
* @return string|false The error message from last collator call
|
||||
*/
|
||||
public function getErrorMessage()
|
||||
{
|
||||
return 'U_ZERO_ERROR';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the collator's locale.
|
||||
*
|
||||
* @return string|false The locale used to create the collator. Currently
|
||||
* always returns "en".
|
||||
*/
|
||||
public function getLocale(int $type = Locale::ACTUAL_LOCALE)
|
||||
{
|
||||
return 'en';
|
||||
}
|
||||
|
||||
/**
|
||||
* Not supported. Get sorting key for a string.
|
||||
*
|
||||
* @return string|false The collation key for $string
|
||||
*
|
||||
* @see https://php.net/collator.getsortkey
|
||||
*
|
||||
* @throws MethodNotImplementedException
|
||||
*/
|
||||
public function getSortKey(string $string)
|
||||
{
|
||||
throw new MethodNotImplementedException(__METHOD__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Not supported. Get current collator's strength.
|
||||
*
|
||||
* @return int The current collator's strength or false on failure
|
||||
*
|
||||
* @see https://php.net/collator.getstrength
|
||||
*
|
||||
* @throws MethodNotImplementedException
|
||||
*/
|
||||
public function getStrength()
|
||||
{
|
||||
throw new MethodNotImplementedException(__METHOD__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Not supported. Set a collator's attribute.
|
||||
*
|
||||
* @return bool True on success or false on failure
|
||||
*
|
||||
* @see https://php.net/collator.setattribute
|
||||
*
|
||||
* @throws MethodNotImplementedException
|
||||
*/
|
||||
public function setAttribute(int $attribute, int $value)
|
||||
{
|
||||
throw new MethodNotImplementedException(__METHOD__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Not supported. Set the collator's strength.
|
||||
*
|
||||
* @return bool True on success or false on failure
|
||||
*
|
||||
* @see https://php.net/collator.setstrength
|
||||
*
|
||||
* @throws MethodNotImplementedException
|
||||
*/
|
||||
public function setStrength(int $strength)
|
||||
{
|
||||
throw new MethodNotImplementedException(__METHOD__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Not supported. Sort array using specified collator and sort keys.
|
||||
*
|
||||
* @return bool True on success or false on failure
|
||||
*
|
||||
* @see https://php.net/collator.sortwithsortkeys
|
||||
*
|
||||
* @throws MethodNotImplementedException
|
||||
*/
|
||||
public function sortWithSortKeys(array &$array)
|
||||
{
|
||||
throw new MethodNotImplementedException(__METHOD__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Not supported. Sort array using specified collator.
|
||||
*
|
||||
* @return bool True on success or false on failure
|
||||
*
|
||||
* @see https://php.net/collator.sort
|
||||
*
|
||||
* @throws MethodNotImplementedException
|
||||
*/
|
||||
public function sort(array &$array, int $flags = self::SORT_REGULAR)
|
||||
{
|
||||
throw new MethodNotImplementedException(__METHOD__);
|
||||
}
|
||||
}
|
43
include/thirdparty/polyfills/Intl/Icu/Currencies.php
vendored
Normal file
43
include/thirdparty/polyfills/Intl/Icu/Currencies.php
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?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.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Intl\Icu;
|
||||
|
||||
/**
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Currencies
|
||||
{
|
||||
private static $data;
|
||||
|
||||
public static function getSymbol(string $currency): ?string
|
||||
{
|
||||
$data = self::$data ?? self::$data = require __DIR__.'/Resources/currencies.php';
|
||||
|
||||
return $data[$currency][0] ?? $data[strtoupper($currency)][0] ?? null;
|
||||
}
|
||||
|
||||
public static function getFractionDigits(string $currency): int
|
||||
{
|
||||
$data = self::$data ?? self::$data = require __DIR__.'/Resources/currencies.php';
|
||||
|
||||
return $data[$currency][1] ?? $data[strtoupper($currency)][1] ?? $data['DEFAULT'][1];
|
||||
}
|
||||
|
||||
public static function getRoundingIncrement(string $currency): int
|
||||
{
|
||||
$data = self::$data ?? self::$data = require __DIR__.'/Resources/currencies.php';
|
||||
|
||||
return $data[$currency][2] ?? $data[strtoupper($currency)][2] ?? $data['DEFAULT'][2];
|
||||
}
|
||||
}
|
39
include/thirdparty/polyfills/Intl/Icu/DateFormat/AmPmTransformer.php
vendored
Normal file
39
include/thirdparty/polyfills/Intl/Icu/DateFormat/AmPmTransformer.php
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?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.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Intl\Icu\DateFormat;
|
||||
|
||||
/**
|
||||
* Parser and formatter for AM/PM markers format.
|
||||
*
|
||||
* @author Igor Wiedler <igor@wiedler.ch>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class AmPmTransformer extends Transformer
|
||||
{
|
||||
public function format(\DateTime $dateTime, int $length): string
|
||||
{
|
||||
return $dateTime->format('A');
|
||||
}
|
||||
|
||||
public function getReverseMatchingRegExp(int $length): string
|
||||
{
|
||||
return 'AM|PM';
|
||||
}
|
||||
|
||||
public function extractDateOptions(string $matched, int $length): array
|
||||
{
|
||||
return [
|
||||
'marker' => $matched,
|
||||
];
|
||||
}
|
||||
}
|
56
include/thirdparty/polyfills/Intl/Icu/DateFormat/DayOfWeekTransformer.php
vendored
Normal file
56
include/thirdparty/polyfills/Intl/Icu/DateFormat/DayOfWeekTransformer.php
vendored
Normal file
|
@ -0,0 +1,56 @@
|
|||
<?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.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Intl\Icu\DateFormat;
|
||||
|
||||
/**
|
||||
* Parser and formatter for day of week format.
|
||||
*
|
||||
* @author Igor Wiedler <igor@wiedler.ch>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class DayOfWeekTransformer extends Transformer
|
||||
{
|
||||
public function format(\DateTime $dateTime, int $length): string
|
||||
{
|
||||
$dayOfWeek = $dateTime->format('l');
|
||||
switch ($length) {
|
||||
case 4:
|
||||
return $dayOfWeek;
|
||||
case 5:
|
||||
return $dayOfWeek[0];
|
||||
case 6:
|
||||
return substr($dayOfWeek, 0, 2);
|
||||
default:
|
||||
return substr($dayOfWeek, 0, 3);
|
||||
}
|
||||
}
|
||||
|
||||
public function getReverseMatchingRegExp(int $length): string
|
||||
{
|
||||
switch ($length) {
|
||||
case 4:
|
||||
return 'Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday';
|
||||
case 5:
|
||||
return '[MTWFS]';
|
||||
case 6:
|
||||
return 'Mo|Tu|We|Th|Fr|Sa|Su';
|
||||
default:
|
||||
return 'Mon|Tue|Wed|Thu|Fri|Sat|Sun';
|
||||
}
|
||||
}
|
||||
|
||||
public function extractDateOptions(string $matched, int $length): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
39
include/thirdparty/polyfills/Intl/Icu/DateFormat/DayOfYearTransformer.php
vendored
Normal file
39
include/thirdparty/polyfills/Intl/Icu/DateFormat/DayOfYearTransformer.php
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?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.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Intl\Icu\DateFormat;
|
||||
|
||||
/**
|
||||
* Parser and formatter for day of year format.
|
||||
*
|
||||
* @author Igor Wiedler <igor@wiedler.ch>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class DayOfYearTransformer extends Transformer
|
||||
{
|
||||
public function format(\DateTime $dateTime, int $length): string
|
||||
{
|
||||
$dayOfYear = (int) $dateTime->format('z') + 1;
|
||||
|
||||
return $this->padLeft($dayOfYear, $length);
|
||||
}
|
||||
|
||||
public function getReverseMatchingRegExp(int $length): string
|
||||
{
|
||||
return '\d{'.$length.'}';
|
||||
}
|
||||
|
||||
public function extractDateOptions(string $matched, int $length): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
39
include/thirdparty/polyfills/Intl/Icu/DateFormat/DayTransformer.php
vendored
Normal file
39
include/thirdparty/polyfills/Intl/Icu/DateFormat/DayTransformer.php
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?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.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Intl\Icu\DateFormat;
|
||||
|
||||
/**
|
||||
* Parser and formatter for day format.
|
||||
*
|
||||
* @author Igor Wiedler <igor@wiedler.ch>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class DayTransformer extends Transformer
|
||||
{
|
||||
public function format(\DateTime $dateTime, int $length): string
|
||||
{
|
||||
return $this->padLeft($dateTime->format('j'), $length);
|
||||
}
|
||||
|
||||
public function getReverseMatchingRegExp(int $length): string
|
||||
{
|
||||
return 1 === $length ? '\d{1,2}' : '\d{1,'.$length.'}';
|
||||
}
|
||||
|
||||
public function extractDateOptions(string $matched, int $length): array
|
||||
{
|
||||
return [
|
||||
'day' => (int) $matched,
|
||||
];
|
||||
}
|
||||
}
|
312
include/thirdparty/polyfills/Intl/Icu/DateFormat/FullTransformer.php
vendored
Normal file
312
include/thirdparty/polyfills/Intl/Icu/DateFormat/FullTransformer.php
vendored
Normal file
|
@ -0,0 +1,312 @@
|
|||
<?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.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Intl\Icu\DateFormat;
|
||||
|
||||
use Symfony\Polyfill\Intl\Icu\Exception\NotImplementedException;
|
||||
use Symfony\Polyfill\Intl\Icu\Icu;
|
||||
|
||||
/**
|
||||
* Parser and formatter for date formats.
|
||||
*
|
||||
* @author Igor Wiedler <igor@wiedler.ch>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class FullTransformer
|
||||
{
|
||||
private $quoteMatch = "'(?:[^']+|'')*'";
|
||||
private $implementedChars = 'MLydQqhDEaHkKmsz';
|
||||
private $notImplementedChars = 'GYuwWFgecSAZvVW';
|
||||
private $regExp;
|
||||
|
||||
/**
|
||||
* @var Transformer[]
|
||||
*/
|
||||
private $transformers;
|
||||
|
||||
private $pattern;
|
||||
private $timezone;
|
||||
|
||||
/**
|
||||
* @param string $pattern The pattern to be used to format and/or parse values
|
||||
* @param string $timezone The timezone to perform the date/time calculations
|
||||
*/
|
||||
public function __construct(string $pattern, string $timezone)
|
||||
{
|
||||
$this->pattern = $pattern;
|
||||
$this->timezone = $timezone;
|
||||
|
||||
$implementedCharsMatch = $this->buildCharsMatch($this->implementedChars);
|
||||
$notImplementedCharsMatch = $this->buildCharsMatch($this->notImplementedChars);
|
||||
$this->regExp = "/($this->quoteMatch|$implementedCharsMatch|$notImplementedCharsMatch)/";
|
||||
|
||||
$this->transformers = [
|
||||
'M' => new MonthTransformer(),
|
||||
'L' => new MonthTransformer(),
|
||||
'y' => new YearTransformer(),
|
||||
'd' => new DayTransformer(),
|
||||
'q' => new QuarterTransformer(),
|
||||
'Q' => new QuarterTransformer(),
|
||||
'h' => new Hour1201Transformer(),
|
||||
'D' => new DayOfYearTransformer(),
|
||||
'E' => new DayOfWeekTransformer(),
|
||||
'a' => new AmPmTransformer(),
|
||||
'H' => new Hour2400Transformer(),
|
||||
'K' => new Hour1200Transformer(),
|
||||
'k' => new Hour2401Transformer(),
|
||||
'm' => new MinuteTransformer(),
|
||||
's' => new SecondTransformer(),
|
||||
'z' => new TimezoneTransformer(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a DateTime using ICU dateformat pattern.
|
||||
*
|
||||
* @return string The formatted value
|
||||
*/
|
||||
public function format(\DateTime $dateTime): string
|
||||
{
|
||||
$formatted = preg_replace_callback($this->regExp, function ($matches) use ($dateTime) {
|
||||
return $this->formatReplace($matches[0], $dateTime);
|
||||
}, $this->pattern);
|
||||
|
||||
return $formatted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the formatted ICU value for the matched date characters.
|
||||
*
|
||||
* @throws NotImplementedException When it encounters a not implemented date character
|
||||
*/
|
||||
private function formatReplace(string $dateChars, \DateTime $dateTime): string
|
||||
{
|
||||
$length = \strlen($dateChars);
|
||||
|
||||
if ($this->isQuoteMatch($dateChars)) {
|
||||
return $this->replaceQuoteMatch($dateChars);
|
||||
}
|
||||
|
||||
if (isset($this->transformers[$dateChars[0]])) {
|
||||
$transformer = $this->transformers[$dateChars[0]];
|
||||
|
||||
return $transformer->format($dateTime, $length);
|
||||
}
|
||||
|
||||
// handle unimplemented characters
|
||||
if (false !== strpos($this->notImplementedChars, $dateChars[0])) {
|
||||
throw new NotImplementedException(sprintf('Unimplemented date character "%s" in format "%s".', $dateChars[0], $this->pattern));
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a pattern based string to a timestamp value.
|
||||
*
|
||||
* @param \DateTime $dateTime A configured DateTime object to use to perform the date calculation
|
||||
* @param string $value String to convert to a time value
|
||||
*
|
||||
* @return int|false The corresponding Unix timestamp
|
||||
*
|
||||
* @throws \InvalidArgumentException When the value can not be matched with pattern
|
||||
*/
|
||||
public function parse(\DateTime $dateTime, string $value)
|
||||
{
|
||||
$reverseMatchingRegExp = $this->getReverseMatchingRegExp($this->pattern);
|
||||
$reverseMatchingRegExp = '/^'.$reverseMatchingRegExp.'$/';
|
||||
|
||||
$options = [];
|
||||
|
||||
if (preg_match($reverseMatchingRegExp, $value, $matches)) {
|
||||
$matches = $this->normalizeArray($matches);
|
||||
|
||||
foreach ($this->transformers as $char => $transformer) {
|
||||
if (isset($matches[$char])) {
|
||||
$length = \strlen($matches[$char]['pattern']);
|
||||
$options = array_merge($options, $transformer->extractDateOptions($matches[$char]['value'], $length));
|
||||
}
|
||||
}
|
||||
|
||||
// reset error code and message
|
||||
Icu::setError(Icu::U_ZERO_ERROR);
|
||||
|
||||
return $this->calculateUnixTimestamp($dateTime, $options);
|
||||
}
|
||||
|
||||
// behave like the intl extension
|
||||
Icu::setError(Icu::U_PARSE_ERROR, 'Date parsing failed');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a regular expression to match with a formatted value.
|
||||
*
|
||||
* @return string The reverse matching regular expression with named captures being formed by the
|
||||
* transformer index in the $transformer array
|
||||
*/
|
||||
private function getReverseMatchingRegExp(string $pattern): string
|
||||
{
|
||||
$escapedPattern = preg_quote($pattern, '/');
|
||||
|
||||
// ICU 4.8 recognizes slash ("/") in a value to be parsed as a dash ("-") and vice-versa
|
||||
// when parsing a date/time value
|
||||
$escapedPattern = preg_replace('/\\\[\-|\/]/', '[\/\-]', $escapedPattern);
|
||||
|
||||
$reverseMatchingRegExp = preg_replace_callback($this->regExp, function ($matches) {
|
||||
$length = \strlen($matches[0]);
|
||||
$transformerIndex = $matches[0][0];
|
||||
|
||||
$dateChars = $matches[0];
|
||||
if ($this->isQuoteMatch($dateChars)) {
|
||||
return $this->replaceQuoteMatch($dateChars);
|
||||
}
|
||||
|
||||
if (isset($this->transformers[$transformerIndex])) {
|
||||
$transformer = $this->transformers[$transformerIndex];
|
||||
$captureName = str_repeat($transformerIndex, $length);
|
||||
|
||||
return "(?P<$captureName>".$transformer->getReverseMatchingRegExp($length).')';
|
||||
}
|
||||
|
||||
return null;
|
||||
}, $escapedPattern);
|
||||
|
||||
return $reverseMatchingRegExp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the first char of a string is a single quote.
|
||||
*/
|
||||
private function isQuoteMatch(string $quoteMatch): bool
|
||||
{
|
||||
return "'" === $quoteMatch[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces single quotes at the start or end of a string with two single quotes.
|
||||
*/
|
||||
private function replaceQuoteMatch(string $quoteMatch): string
|
||||
{
|
||||
if (preg_match("/^'+$/", $quoteMatch)) {
|
||||
return str_replace("''", "'", $quoteMatch);
|
||||
}
|
||||
|
||||
return str_replace("''", "'", substr($quoteMatch, 1, -1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a chars match regular expression.
|
||||
*/
|
||||
private function buildCharsMatch(string $specialChars): string
|
||||
{
|
||||
$specialCharsArray = str_split($specialChars);
|
||||
|
||||
$specialCharsMatch = implode('|', array_map(function ($char) {
|
||||
return $char.'+';
|
||||
}, $specialCharsArray));
|
||||
|
||||
return $specialCharsMatch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize a preg_replace match array, removing the numeric keys and returning an associative array
|
||||
* with the value and pattern values for the matched Transformer.
|
||||
*/
|
||||
private function normalizeArray(array $data): array
|
||||
{
|
||||
$ret = [];
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
if (!\is_string($key)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$ret[$key[0]] = [
|
||||
'value' => $value,
|
||||
'pattern' => $key,
|
||||
];
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the Unix timestamp based on the matched values by the reverse matching regular
|
||||
* expression of parse().
|
||||
*
|
||||
* @return bool|int The calculated timestamp or false if matched date is invalid
|
||||
*/
|
||||
private function calculateUnixTimestamp(\DateTime $dateTime, array $options)
|
||||
{
|
||||
$options = $this->getDefaultValueForOptions($options);
|
||||
|
||||
$year = $options['year'];
|
||||
$month = $options['month'];
|
||||
$day = $options['day'];
|
||||
$hour = $options['hour'];
|
||||
$hourInstance = $options['hourInstance'];
|
||||
$minute = $options['minute'];
|
||||
$second = $options['second'];
|
||||
$marker = $options['marker'];
|
||||
$timezone = $options['timezone'];
|
||||
|
||||
// If month is false, return immediately (intl behavior)
|
||||
if (false === $month) {
|
||||
Icu::setError(Icu::U_PARSE_ERROR, 'Date parsing failed');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Normalize hour
|
||||
if ($hourInstance instanceof HourTransformer) {
|
||||
$hour = $hourInstance->normalizeHour($hour, $marker);
|
||||
}
|
||||
|
||||
// Set the timezone if different from the default one
|
||||
if (null !== $timezone && $timezone !== $this->timezone) {
|
||||
$dateTime->setTimezone(new \DateTimeZone($timezone));
|
||||
}
|
||||
|
||||
// Normalize yy year
|
||||
preg_match_all($this->regExp, $this->pattern, $matches);
|
||||
if (\in_array('yy', $matches[0])) {
|
||||
$dateTime->setTimestamp(time());
|
||||
$year = $year > (int) $dateTime->format('y') + 20 ? 1900 + $year : 2000 + $year;
|
||||
}
|
||||
|
||||
$dateTime->setDate($year, $month, $day);
|
||||
$dateTime->setTime($hour, $minute, $second);
|
||||
|
||||
return $dateTime->getTimestamp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add sensible default values for missing items in the extracted date/time options array. The values
|
||||
* are base in the beginning of the Unix era.
|
||||
*/
|
||||
private function getDefaultValueForOptions(array $options): array
|
||||
{
|
||||
return [
|
||||
'year' => $options['year'] ?? 1970,
|
||||
'month' => $options['month'] ?? 1,
|
||||
'day' => $options['day'] ?? 1,
|
||||
'hour' => $options['hour'] ?? 0,
|
||||
'hourInstance' => $options['hourInstance'] ?? null,
|
||||
'minute' => $options['minute'] ?? 0,
|
||||
'second' => $options['second'] ?? 0,
|
||||
'marker' => $options['marker'] ?? null,
|
||||
'timezone' => $options['timezone'] ?? null,
|
||||
];
|
||||
}
|
||||
}
|
52
include/thirdparty/polyfills/Intl/Icu/DateFormat/Hour1200Transformer.php
vendored
Normal file
52
include/thirdparty/polyfills/Intl/Icu/DateFormat/Hour1200Transformer.php
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
<?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.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Intl\Icu\DateFormat;
|
||||
|
||||
/**
|
||||
* Parser and formatter for 12 hour format (0-11).
|
||||
*
|
||||
* @author Igor Wiedler <igor@wiedler.ch>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Hour1200Transformer extends HourTransformer
|
||||
{
|
||||
public function format(\DateTime $dateTime, int $length): string
|
||||
{
|
||||
$hourOfDay = $dateTime->format('g');
|
||||
$hourOfDay = '12' === $hourOfDay ? '0' : $hourOfDay;
|
||||
|
||||
return $this->padLeft($hourOfDay, $length);
|
||||
}
|
||||
|
||||
public function normalizeHour(int $hour, ?string $marker = null): int
|
||||
{
|
||||
if ('PM' === $marker) {
|
||||
$hour += 12;
|
||||
}
|
||||
|
||||
return $hour;
|
||||
}
|
||||
|
||||
public function getReverseMatchingRegExp(int $length): string
|
||||
{
|
||||
return '\d{1,2}';
|
||||
}
|
||||
|
||||
public function extractDateOptions(string $matched, int $length): array
|
||||
{
|
||||
return [
|
||||
'hour' => (int) $matched,
|
||||
'hourInstance' => $this,
|
||||
];
|
||||
}
|
||||
}
|
52
include/thirdparty/polyfills/Intl/Icu/DateFormat/Hour1201Transformer.php
vendored
Normal file
52
include/thirdparty/polyfills/Intl/Icu/DateFormat/Hour1201Transformer.php
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
<?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.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Intl\Icu\DateFormat;
|
||||
|
||||
/**
|
||||
* Parser and formatter for 12 hour format (1-12).
|
||||
*
|
||||
* @author Igor Wiedler <igor@wiedler.ch>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Hour1201Transformer extends HourTransformer
|
||||
{
|
||||
public function format(\DateTime $dateTime, int $length): string
|
||||
{
|
||||
return $this->padLeft($dateTime->format('g'), $length);
|
||||
}
|
||||
|
||||
public function normalizeHour(int $hour, ?string $marker = null): int
|
||||
{
|
||||
if ('PM' !== $marker && 12 === $hour) {
|
||||
$hour = 0;
|
||||
} elseif ('PM' === $marker && 12 !== $hour) {
|
||||
// If PM and hour is not 12 (1-12), sum 12 hour
|
||||
$hour += 12;
|
||||
}
|
||||
|
||||
return $hour;
|
||||
}
|
||||
|
||||
public function getReverseMatchingRegExp(int $length): string
|
||||
{
|
||||
return '\d{1,2}';
|
||||
}
|
||||
|
||||
public function extractDateOptions(string $matched, int $length): array
|
||||
{
|
||||
return [
|
||||
'hour' => (int) $matched,
|
||||
'hourInstance' => $this,
|
||||
];
|
||||
}
|
||||
}
|
51
include/thirdparty/polyfills/Intl/Icu/DateFormat/Hour2400Transformer.php
vendored
Normal file
51
include/thirdparty/polyfills/Intl/Icu/DateFormat/Hour2400Transformer.php
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?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.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Intl\Icu\DateFormat;
|
||||
|
||||
/**
|
||||
* Parser and formatter for 24 hour format (0-23).
|
||||
*
|
||||
* @author Igor Wiedler <igor@wiedler.ch>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Hour2400Transformer extends HourTransformer
|
||||
{
|
||||
public function format(\DateTime $dateTime, int $length): string
|
||||
{
|
||||
return $this->padLeft($dateTime->format('G'), $length);
|
||||
}
|
||||
|
||||
public function normalizeHour(int $hour, ?string $marker = null): int
|
||||
{
|
||||
if ('AM' === $marker) {
|
||||
$hour = 0;
|
||||
} elseif ('PM' === $marker) {
|
||||
$hour = 12;
|
||||
}
|
||||
|
||||
return $hour;
|
||||
}
|
||||
|
||||
public function getReverseMatchingRegExp(int $length): string
|
||||
{
|
||||
return '\d{1,2}';
|
||||
}
|
||||
|
||||
public function extractDateOptions(string $matched, int $length): array
|
||||
{
|
||||
return [
|
||||
'hour' => (int) $matched,
|
||||
'hourInstance' => $this,
|
||||
];
|
||||
}
|
||||
}
|
54
include/thirdparty/polyfills/Intl/Icu/DateFormat/Hour2401Transformer.php
vendored
Normal file
54
include/thirdparty/polyfills/Intl/Icu/DateFormat/Hour2401Transformer.php
vendored
Normal file
|
@ -0,0 +1,54 @@
|
|||
<?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.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Intl\Icu\DateFormat;
|
||||
|
||||
/**
|
||||
* Parser and formatter for 24 hour format (1-24).
|
||||
*
|
||||
* @author Igor Wiedler <igor@wiedler.ch>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Hour2401Transformer extends HourTransformer
|
||||
{
|
||||
public function format(\DateTime $dateTime, int $length): string
|
||||
{
|
||||
$hourOfDay = $dateTime->format('G');
|
||||
$hourOfDay = '0' === $hourOfDay ? '24' : $hourOfDay;
|
||||
|
||||
return $this->padLeft($hourOfDay, $length);
|
||||
}
|
||||
|
||||
public function normalizeHour(int $hour, ?string $marker = null): int
|
||||
{
|
||||
if ((null === $marker && 24 === $hour) || 'AM' === $marker) {
|
||||
$hour = 0;
|
||||
} elseif ('PM' === $marker) {
|
||||
$hour = 12;
|
||||
}
|
||||
|
||||
return $hour;
|
||||
}
|
||||
|
||||
public function getReverseMatchingRegExp(int $length): string
|
||||
{
|
||||
return '\d{1,2}';
|
||||
}
|
||||
|
||||
public function extractDateOptions(string $matched, int $length): array
|
||||
{
|
||||
return [
|
||||
'hour' => (int) $matched,
|
||||
'hourInstance' => $this,
|
||||
];
|
||||
}
|
||||
}
|
32
include/thirdparty/polyfills/Intl/Icu/DateFormat/HourTransformer.php
vendored
Normal file
32
include/thirdparty/polyfills/Intl/Icu/DateFormat/HourTransformer.php
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?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.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Intl\Icu\DateFormat;
|
||||
|
||||
/**
|
||||
* Base class for hour transformers.
|
||||
*
|
||||
* @author Eriksen Costa <eriksen.costa@infranology.com.br>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
abstract class HourTransformer extends Transformer
|
||||
{
|
||||
/**
|
||||
* Returns a normalized hour value suitable for the hour transformer type.
|
||||
*
|
||||
* @param int $hour The hour value
|
||||
* @param string $marker An optional AM/PM marker
|
||||
*
|
||||
* @return int The normalized hour value
|
||||
*/
|
||||
abstract public function normalizeHour(int $hour, ?string $marker = null): int;
|
||||
}
|
41
include/thirdparty/polyfills/Intl/Icu/DateFormat/MinuteTransformer.php
vendored
Normal file
41
include/thirdparty/polyfills/Intl/Icu/DateFormat/MinuteTransformer.php
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?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.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Intl\Icu\DateFormat;
|
||||
|
||||
/**
|
||||
* Parser and formatter for minute format.
|
||||
*
|
||||
* @author Igor Wiedler <igor@wiedler.ch>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class MinuteTransformer extends Transformer
|
||||
{
|
||||
public function format(\DateTime $dateTime, int $length): string
|
||||
{
|
||||
$minuteOfHour = (int) $dateTime->format('i');
|
||||
|
||||
return $this->padLeft($minuteOfHour, $length);
|
||||
}
|
||||
|
||||
public function getReverseMatchingRegExp(int $length): string
|
||||
{
|
||||
return 1 === $length ? '\d{1,2}' : '\d{'.$length.'}';
|
||||
}
|
||||
|
||||
public function extractDateOptions(string $matched, int $length): array
|
||||
{
|
||||
return [
|
||||
'minute' => (int) $matched,
|
||||
];
|
||||
}
|
||||
}
|
127
include/thirdparty/polyfills/Intl/Icu/DateFormat/MonthTransformer.php
vendored
Normal file
127
include/thirdparty/polyfills/Intl/Icu/DateFormat/MonthTransformer.php
vendored
Normal file
|
@ -0,0 +1,127 @@
|
|||
<?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.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Intl\Icu\DateFormat;
|
||||
|
||||
/**
|
||||
* Parser and formatter for month format.
|
||||
*
|
||||
* @author Igor Wiedler <igor@wiedler.ch>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class MonthTransformer extends Transformer
|
||||
{
|
||||
protected static $months = [
|
||||
'January',
|
||||
'February',
|
||||
'March',
|
||||
'April',
|
||||
'May',
|
||||
'June',
|
||||
'July',
|
||||
'August',
|
||||
'September',
|
||||
'October',
|
||||
'November',
|
||||
'December',
|
||||
];
|
||||
|
||||
/**
|
||||
* Short months names (first 3 letters).
|
||||
*/
|
||||
protected static $shortMonths = [];
|
||||
|
||||
/**
|
||||
* Flipped $months array, $name => $index.
|
||||
*/
|
||||
protected static $flippedMonths = [];
|
||||
|
||||
/**
|
||||
* Flipped $shortMonths array, $name => $index.
|
||||
*/
|
||||
protected static $flippedShortMonths = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
if (0 === \count(self::$shortMonths)) {
|
||||
self::$shortMonths = array_map(function ($month) {
|
||||
return substr($month, 0, 3);
|
||||
}, self::$months);
|
||||
|
||||
self::$flippedMonths = array_flip(self::$months);
|
||||
self::$flippedShortMonths = array_flip(self::$shortMonths);
|
||||
}
|
||||
}
|
||||
|
||||
public function format(\DateTime $dateTime, int $length): string
|
||||
{
|
||||
$matchLengthMap = [
|
||||
1 => 'n',
|
||||
2 => 'm',
|
||||
3 => 'M',
|
||||
4 => 'F',
|
||||
];
|
||||
|
||||
if (isset($matchLengthMap[$length])) {
|
||||
return $dateTime->format($matchLengthMap[$length]);
|
||||
}
|
||||
|
||||
if (5 === $length) {
|
||||
return substr($dateTime->format('M'), 0, 1);
|
||||
}
|
||||
|
||||
return $this->padLeft($dateTime->format('m'), $length);
|
||||
}
|
||||
|
||||
public function getReverseMatchingRegExp(int $length): string
|
||||
{
|
||||
switch ($length) {
|
||||
case 1:
|
||||
$regExp = '\d{1,2}';
|
||||
break;
|
||||
case 3:
|
||||
$regExp = implode('|', self::$shortMonths);
|
||||
break;
|
||||
case 4:
|
||||
$regExp = implode('|', self::$months);
|
||||
break;
|
||||
case 5:
|
||||
$regExp = '[JFMASOND]';
|
||||
break;
|
||||
default:
|
||||
$regExp = '\d{1,'.$length.'}';
|
||||
break;
|
||||
}
|
||||
|
||||
return $regExp;
|
||||
}
|
||||
|
||||
public function extractDateOptions(string $matched, int $length): array
|
||||
{
|
||||
if (!is_numeric($matched)) {
|
||||
if (3 === $length) {
|
||||
$matched = self::$flippedShortMonths[$matched] + 1;
|
||||
} elseif (4 === $length) {
|
||||
$matched = self::$flippedMonths[$matched] + 1;
|
||||
} elseif (5 === $length) {
|
||||
// IntlDateFormatter::parse() always returns false for MMMMM or LLLLL
|
||||
$matched = false;
|
||||
}
|
||||
} else {
|
||||
$matched = (int) $matched;
|
||||
}
|
||||
|
||||
return [
|
||||
'month' => $matched,
|
||||
];
|
||||
}
|
||||
}
|
65
include/thirdparty/polyfills/Intl/Icu/DateFormat/QuarterTransformer.php
vendored
Normal file
65
include/thirdparty/polyfills/Intl/Icu/DateFormat/QuarterTransformer.php
vendored
Normal file
|
@ -0,0 +1,65 @@
|
|||
<?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.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Intl\Icu\DateFormat;
|
||||
|
||||
/**
|
||||
* Parser and formatter for quarter format.
|
||||
*
|
||||
* @author Igor Wiedler <igor@wiedler.ch>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class QuarterTransformer extends Transformer
|
||||
{
|
||||
public function format(\DateTime $dateTime, int $length): string
|
||||
{
|
||||
$month = (int) $dateTime->format('n');
|
||||
$quarter = (int) floor(($month - 1) / 3) + 1;
|
||||
switch ($length) {
|
||||
case 1:
|
||||
case 2:
|
||||
return $this->padLeft($quarter, $length);
|
||||
case 3:
|
||||
return 'Q'.$quarter;
|
||||
case 4:
|
||||
$map = [1 => '1st quarter', 2 => '2nd quarter', 3 => '3rd quarter', 4 => '4th quarter'];
|
||||
|
||||
return $map[$quarter];
|
||||
default:
|
||||
if (\defined('INTL_ICU_VERSION') && version_compare(\INTL_ICU_VERSION, '70.1', '<')) {
|
||||
$map = [1 => '1st quarter', 2 => '2nd quarter', 3 => '3rd quarter', 4 => '4th quarter'];
|
||||
|
||||
return $map[$quarter];
|
||||
} else {
|
||||
return $quarter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getReverseMatchingRegExp(int $length): string
|
||||
{
|
||||
switch ($length) {
|
||||
case 1:
|
||||
case 2:
|
||||
return '\d{'.$length.'}';
|
||||
case 3:
|
||||
return 'Q\d';
|
||||
default:
|
||||
return '(?:1st|2nd|3rd|4th) quarter';
|
||||
}
|
||||
}
|
||||
|
||||
public function extractDateOptions(string $matched, int $length): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
41
include/thirdparty/polyfills/Intl/Icu/DateFormat/SecondTransformer.php
vendored
Normal file
41
include/thirdparty/polyfills/Intl/Icu/DateFormat/SecondTransformer.php
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?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.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Intl\Icu\DateFormat;
|
||||
|
||||
/**
|
||||
* Parser and formatter for the second format.
|
||||
*
|
||||
* @author Igor Wiedler <igor@wiedler.ch>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class SecondTransformer extends Transformer
|
||||
{
|
||||
public function format(\DateTime $dateTime, int $length): string
|
||||
{
|
||||
$secondOfMinute = (int) $dateTime->format('s');
|
||||
|
||||
return $this->padLeft($secondOfMinute, $length);
|
||||
}
|
||||
|
||||
public function getReverseMatchingRegExp(int $length): string
|
||||
{
|
||||
return 1 === $length ? '\d{1,2}' : '\d{'.$length.'}';
|
||||
}
|
||||
|
||||
public function extractDateOptions(string $matched, int $length): array
|
||||
{
|
||||
return [
|
||||
'second' => (int) $matched,
|
||||
];
|
||||
}
|
||||
}
|
108
include/thirdparty/polyfills/Intl/Icu/DateFormat/TimezoneTransformer.php
vendored
Normal file
108
include/thirdparty/polyfills/Intl/Icu/DateFormat/TimezoneTransformer.php
vendored
Normal file
|
@ -0,0 +1,108 @@
|
|||
<?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.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Intl\Icu\DateFormat;
|
||||
|
||||
use Symfony\Polyfill\Intl\Icu\Exception\NotImplementedException;
|
||||
|
||||
/**
|
||||
* Parser and formatter for time zone format.
|
||||
*
|
||||
* @author Igor Wiedler <igor@wiedler.ch>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class TimezoneTransformer extends Transformer
|
||||
{
|
||||
/**
|
||||
* @throws NotImplementedException When time zone is different than UTC or GMT (Etc/GMT)
|
||||
*/
|
||||
public function format(\DateTime $dateTime, int $length): string
|
||||
{
|
||||
$timeZone = substr($dateTime->getTimezone()->getName(), 0, 3);
|
||||
|
||||
if (!\in_array($timeZone, ['Etc', 'UTC', 'GMT'])) {
|
||||
throw new NotImplementedException('Time zone different than GMT or UTC is not supported as a formatting output.');
|
||||
}
|
||||
|
||||
if ('Etc' === $timeZone) {
|
||||
// i.e. Etc/GMT+1, Etc/UTC, Etc/Zulu
|
||||
$timeZone = substr($dateTime->getTimezone()->getName(), 4);
|
||||
}
|
||||
|
||||
// From ICU >= 59.1 GMT and UTC are no longer unified
|
||||
if (\in_array($timeZone, ['UTC', 'UCT', 'Universal', 'Zulu'])) {
|
||||
// offset is not supported with UTC
|
||||
return $length > 3 ? 'Coordinated Universal Time' : 'UTC';
|
||||
}
|
||||
|
||||
$offset = (int) $dateTime->format('O');
|
||||
|
||||
// From ICU >= 4.8, the zero offset is no more used, example: GMT instead of GMT+00:00
|
||||
if (0 === $offset) {
|
||||
return $length > 3 ? 'Greenwich Mean Time' : 'GMT';
|
||||
}
|
||||
|
||||
if ($length > 3) {
|
||||
return $dateTime->format('\G\M\TP');
|
||||
}
|
||||
|
||||
return sprintf('GMT%s%d', $offset >= 0 ? '+' : '', $offset / 100);
|
||||
}
|
||||
|
||||
public function getReverseMatchingRegExp(int $length): string
|
||||
{
|
||||
return 'GMT[+-]\d{2}:?\d{2}';
|
||||
}
|
||||
|
||||
public function extractDateOptions(string $matched, int $length): array
|
||||
{
|
||||
return [
|
||||
'timezone' => self::getEtcTimeZoneId($matched),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an Etc/GMT timezone identifier for the specified timezone.
|
||||
*
|
||||
* The PHP documentation for timezones states to not use the 'Other' time zones because them exists
|
||||
* "for backwards compatibility". However all Etc/GMT time zones are in the tz database 'etcetera' file,
|
||||
* which indicates they are not deprecated (neither are old names).
|
||||
*
|
||||
* Only GMT, Etc/Universal, Etc/Zulu, Etc/Greenwich, Etc/GMT-0, Etc/GMT+0 and Etc/GMT0 are old names and
|
||||
* are linked to Etc/GMT or Etc/UTC.
|
||||
*
|
||||
* @param string $formattedTimeZone A GMT timezone string (GMT-03:00, e.g.)
|
||||
*
|
||||
* @return string A timezone identifier
|
||||
*
|
||||
* @see https://php.net/timezones.others
|
||||
*
|
||||
* @throws NotImplementedException When the GMT time zone have minutes offset different than zero
|
||||
* @throws \InvalidArgumentException When the value can not be matched with pattern
|
||||
*/
|
||||
public static function getEtcTimeZoneId(string $formattedTimeZone): string
|
||||
{
|
||||
if (preg_match('/GMT(?P<signal>[+-])(?P<hours>\d{2}):?(?P<minutes>\d{2})/', $formattedTimeZone, $matches)) {
|
||||
$hours = (int) $matches['hours'];
|
||||
$minutes = (int) $matches['minutes'];
|
||||
$signal = '-' === $matches['signal'] ? '+' : '-';
|
||||
|
||||
if (0 < $minutes) {
|
||||
throw new NotImplementedException(sprintf('It is not possible to use a GMT time zone with minutes offset different than zero (0). GMT time zone tried: "%s".', $formattedTimeZone));
|
||||
}
|
||||
|
||||
return 'Etc/GMT'.(0 !== $hours ? $signal.$hours : '');
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException(sprintf('The GMT time zone "%s" does not match with the supported formats GMT[+-]HH:MM or GMT[+-]HHMM.', $formattedTimeZone));
|
||||
}
|
||||
}
|
65
include/thirdparty/polyfills/Intl/Icu/DateFormat/Transformer.php
vendored
Normal file
65
include/thirdparty/polyfills/Intl/Icu/DateFormat/Transformer.php
vendored
Normal file
|
@ -0,0 +1,65 @@
|
|||
<?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.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Intl\Icu\DateFormat;
|
||||
|
||||
/**
|
||||
* Parser and formatter for date formats.
|
||||
*
|
||||
* @author Igor Wiedler <igor@wiedler.ch>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
abstract class Transformer
|
||||
{
|
||||
/**
|
||||
* Format a value using a configured DateTime as date/time source.
|
||||
*
|
||||
* @param \DateTime $dateTime A DateTime object to be used to generate the formatted value
|
||||
* @param int $length The formatted value string length
|
||||
*
|
||||
* @return string The formatted value
|
||||
*/
|
||||
abstract public function format(\DateTime $dateTime, int $length): string;
|
||||
|
||||
/**
|
||||
* Returns a reverse matching regular expression of a string generated by format().
|
||||
*
|
||||
* @param int $length The length of the value to be reverse matched
|
||||
*
|
||||
* @return string The reverse matching regular expression
|
||||
*/
|
||||
abstract public function getReverseMatchingRegExp(int $length): string;
|
||||
|
||||
/**
|
||||
* Extract date options from a matched value returned by the processing of the reverse matching
|
||||
* regular expression.
|
||||
*
|
||||
* @param string $matched The matched value
|
||||
* @param int $length The length of the Transformer pattern string
|
||||
*
|
||||
* @return array An associative array
|
||||
*/
|
||||
abstract public function extractDateOptions(string $matched, int $length): array;
|
||||
|
||||
/**
|
||||
* Pad a string with zeros to the left.
|
||||
*
|
||||
* @param string $value The string to be padded
|
||||
* @param int $length The length to pad
|
||||
*
|
||||
* @return string The padded string
|
||||
*/
|
||||
protected function padLeft(string $value, int $length): string
|
||||
{
|
||||
return str_pad($value, $length, '0', \STR_PAD_LEFT);
|
||||
}
|
||||
}
|
43
include/thirdparty/polyfills/Intl/Icu/DateFormat/YearTransformer.php
vendored
Normal file
43
include/thirdparty/polyfills/Intl/Icu/DateFormat/YearTransformer.php
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?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.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Intl\Icu\DateFormat;
|
||||
|
||||
/**
|
||||
* Parser and formatter for year format.
|
||||
*
|
||||
* @author Igor Wiedler <igor@wiedler.ch>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class YearTransformer extends Transformer
|
||||
{
|
||||
public function format(\DateTime $dateTime, int $length): string
|
||||
{
|
||||
if (2 === $length) {
|
||||
return $dateTime->format('y');
|
||||
}
|
||||
|
||||
return $this->padLeft($dateTime->format('Y'), $length);
|
||||
}
|
||||
|
||||
public function getReverseMatchingRegExp(int $length): string
|
||||
{
|
||||
return 2 === $length ? '\d{2}' : '\d{1,4}';
|
||||
}
|
||||
|
||||
public function extractDateOptions(string $matched, int $length): array
|
||||
{
|
||||
return [
|
||||
'year' => (int) $matched,
|
||||
];
|
||||
}
|
||||
}
|
21
include/thirdparty/polyfills/Intl/Icu/Exception/ExceptionInterface.php
vendored
Normal file
21
include/thirdparty/polyfills/Intl/Icu/Exception/ExceptionInterface.php
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?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.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Intl\Icu\Exception;
|
||||
|
||||
/**
|
||||
* Base ExceptionInterface for the Intl component.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
interface ExceptionInterface extends \Throwable
|
||||
{
|
||||
}
|
28
include/thirdparty/polyfills/Intl/Icu/Exception/MethodArgumentNotImplementedException.php
vendored
Normal file
28
include/thirdparty/polyfills/Intl/Icu/Exception/MethodArgumentNotImplementedException.php
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?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.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Intl\Icu\Exception;
|
||||
|
||||
/**
|
||||
* @author Eriksen Costa <eriksen.costa@infranology.com.br>
|
||||
*/
|
||||
class MethodArgumentNotImplementedException extends NotImplementedException
|
||||
{
|
||||
/**
|
||||
* @param string $methodName The method name that raised the exception
|
||||
* @param string $argName The argument name that is not implemented
|
||||
*/
|
||||
public function __construct(string $methodName, string $argName)
|
||||
{
|
||||
$message = sprintf('The %s() method\'s argument $%s behavior is not implemented.', $methodName, $argName);
|
||||
parent::__construct($message);
|
||||
}
|
||||
}
|
37
include/thirdparty/polyfills/Intl/Icu/Exception/MethodArgumentValueNotImplementedException.php
vendored
Normal file
37
include/thirdparty/polyfills/Intl/Icu/Exception/MethodArgumentValueNotImplementedException.php
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?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.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Intl\Icu\Exception;
|
||||
|
||||
/**
|
||||
* @author Eriksen Costa <eriksen.costa@infranology.com.br>
|
||||
*/
|
||||
class MethodArgumentValueNotImplementedException extends NotImplementedException
|
||||
{
|
||||
/**
|
||||
* @param string $methodName The method name that raised the exception
|
||||
* @param string $argName The argument name
|
||||
* @param mixed $argValue The argument value that is not implemented
|
||||
* @param string $additionalMessage An optional additional message to append to the exception message
|
||||
*/
|
||||
public function __construct(string $methodName, string $argName, $argValue, string $additionalMessage = '')
|
||||
{
|
||||
$message = sprintf(
|
||||
'The %s() method\'s argument $%s value %s behavior is not implemented.%s',
|
||||
$methodName,
|
||||
$argName,
|
||||
var_export($argValue, true),
|
||||
'' !== $additionalMessage ? ' '.$additionalMessage.'. ' : ''
|
||||
);
|
||||
|
||||
parent::__construct($message);
|
||||
}
|
||||
}
|
26
include/thirdparty/polyfills/Intl/Icu/Exception/MethodNotImplementedException.php
vendored
Normal file
26
include/thirdparty/polyfills/Intl/Icu/Exception/MethodNotImplementedException.php
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?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.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Intl\Icu\Exception;
|
||||
|
||||
/**
|
||||
* @author Eriksen Costa <eriksen.costa@infranology.com.br>
|
||||
*/
|
||||
class MethodNotImplementedException extends NotImplementedException
|
||||
{
|
||||
/**
|
||||
* @param string $methodName The name of the method
|
||||
*/
|
||||
public function __construct(string $methodName)
|
||||
{
|
||||
parent::__construct(sprintf('The %s() is not implemented.', $methodName));
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue