Edit File by line
/home/barbar84/www/wp-conte.../plugins/updraftp.../vendor/symfony/polyfill...
File: Php72.php
<?php
[0] Fix | Delete
[1] Fix | Delete
/*
[2] Fix | Delete
* This file is part of the Symfony package.
[3] Fix | Delete
*
[4] Fix | Delete
* (c) Fabien Potencier <fabien@symfony.com>
[5] Fix | Delete
*
[6] Fix | Delete
* For the full copyright and license information, please view the LICENSE
[7] Fix | Delete
* file that was distributed with this source code.
[8] Fix | Delete
*/
[9] Fix | Delete
[10] Fix | Delete
namespace Symfony\Polyfill\Php72;
[11] Fix | Delete
[12] Fix | Delete
/**
[13] Fix | Delete
* @author Nicolas Grekas <p@tchwork.com>
[14] Fix | Delete
* @author Dariusz RumiƄski <dariusz.ruminski@gmail.com>
[15] Fix | Delete
*
[16] Fix | Delete
* @internal
[17] Fix | Delete
*/
[18] Fix | Delete
final class Php72
[19] Fix | Delete
{
[20] Fix | Delete
private static $hashMask;
[21] Fix | Delete
[22] Fix | Delete
public static function utf8_encode($s)
[23] Fix | Delete
{
[24] Fix | Delete
$s .= $s;
[25] Fix | Delete
$len = \strlen($s);
[26] Fix | Delete
[27] Fix | Delete
for ($i = $len >> 1, $j = 0; $i < $len; ++$i, ++$j) {
[28] Fix | Delete
switch (true) {
[29] Fix | Delete
case $s[$i] < "\x80": $s[$j] = $s[$i]; break;
[30] Fix | Delete
case $s[$i] < "\xC0": $s[$j] = "\xC2"; $s[++$j] = $s[$i]; break;
[31] Fix | Delete
default: $s[$j] = "\xC3"; $s[++$j] = \chr(\ord($s[$i]) - 64); break;
[32] Fix | Delete
}
[33] Fix | Delete
}
[34] Fix | Delete
[35] Fix | Delete
return substr($s, 0, $j);
[36] Fix | Delete
}
[37] Fix | Delete
[38] Fix | Delete
public static function utf8_decode($s)
[39] Fix | Delete
{
[40] Fix | Delete
$s = (string) $s;
[41] Fix | Delete
$len = \strlen($s);
[42] Fix | Delete
[43] Fix | Delete
for ($i = 0, $j = 0; $i < $len; ++$i, ++$j) {
[44] Fix | Delete
switch ($s[$i] & "\xF0") {
[45] Fix | Delete
case "\xC0":
[46] Fix | Delete
case "\xD0":
[47] Fix | Delete
$c = (\ord($s[$i] & "\x1F") << 6) | \ord($s[++$i] & "\x3F");
[48] Fix | Delete
$s[$j] = $c < 256 ? \chr($c) : '?';
[49] Fix | Delete
break;
[50] Fix | Delete
[51] Fix | Delete
case "\xF0":
[52] Fix | Delete
++$i;
[53] Fix | Delete
// no break
[54] Fix | Delete
[55] Fix | Delete
case "\xE0":
[56] Fix | Delete
$s[$j] = '?';
[57] Fix | Delete
$i += 2;
[58] Fix | Delete
break;
[59] Fix | Delete
[60] Fix | Delete
default:
[61] Fix | Delete
$s[$j] = $s[$i];
[62] Fix | Delete
}
[63] Fix | Delete
}
[64] Fix | Delete
[65] Fix | Delete
return substr($s, 0, $j);
[66] Fix | Delete
}
[67] Fix | Delete
[68] Fix | Delete
public static function php_os_family()
[69] Fix | Delete
{
[70] Fix | Delete
if ('\\' === \DIRECTORY_SEPARATOR) {
[71] Fix | Delete
return 'Windows';
[72] Fix | Delete
}
[73] Fix | Delete
[74] Fix | Delete
$map = array(
[75] Fix | Delete
'Darwin' => 'Darwin',
[76] Fix | Delete
'DragonFly' => 'BSD',
[77] Fix | Delete
'FreeBSD' => 'BSD',
[78] Fix | Delete
'NetBSD' => 'BSD',
[79] Fix | Delete
'OpenBSD' => 'BSD',
[80] Fix | Delete
'Linux' => 'Linux',
[81] Fix | Delete
'SunOS' => 'Solaris',
[82] Fix | Delete
);
[83] Fix | Delete
[84] Fix | Delete
return isset($map[PHP_OS]) ? $map[PHP_OS] : 'Unknown';
[85] Fix | Delete
}
[86] Fix | Delete
[87] Fix | Delete
public static function spl_object_id($object)
[88] Fix | Delete
{
[89] Fix | Delete
if (null === self::$hashMask) {
[90] Fix | Delete
self::initHashMask();
[91] Fix | Delete
}
[92] Fix | Delete
if (null === $hash = spl_object_hash($object)) {
[93] Fix | Delete
return;
[94] Fix | Delete
}
[95] Fix | Delete
[96] Fix | Delete
// On 32-bit systems, PHP_INT_SIZE is 4,
[97] Fix | Delete
return self::$hashMask ^ hexdec(substr($hash, 16 - (\PHP_INT_SIZE * 2 - 1), (\PHP_INT_SIZE * 2 - 1)));
[98] Fix | Delete
}
[99] Fix | Delete
[100] Fix | Delete
public static function sapi_windows_vt100_support($stream, $enable = null)
[101] Fix | Delete
{
[102] Fix | Delete
if (!\is_resource($stream)) {
[103] Fix | Delete
trigger_error('sapi_windows_vt100_support() expects parameter 1 to be resource, '.\gettype($stream).' given', E_USER_WARNING);
[104] Fix | Delete
[105] Fix | Delete
return false;
[106] Fix | Delete
}
[107] Fix | Delete
[108] Fix | Delete
$meta = stream_get_meta_data($stream);
[109] Fix | Delete
[110] Fix | Delete
if ('STDIO' !== $meta['stream_type']) {
[111] Fix | Delete
trigger_error('sapi_windows_vt100_support() was not able to analyze the specified stream', E_USER_WARNING);
[112] Fix | Delete
[113] Fix | Delete
return false;
[114] Fix | Delete
}
[115] Fix | Delete
[116] Fix | Delete
// We cannot actually disable vt100 support if it is set
[117] Fix | Delete
if (false === $enable || !self::stream_isatty($stream)) {
[118] Fix | Delete
return false;
[119] Fix | Delete
}
[120] Fix | Delete
[121] Fix | Delete
// The native function does not apply to stdin
[122] Fix | Delete
$meta = array_map('strtolower', $meta);
[123] Fix | Delete
$stdin = 'php://stdin' === $meta['uri'] || 'php://fd/0' === $meta['uri'];
[124] Fix | Delete
[125] Fix | Delete
return !$stdin
[126] Fix | Delete
&& (false !== getenv('ANSICON')
[127] Fix | Delete
|| 'ON' === getenv('ConEmuANSI')
[128] Fix | Delete
|| 'xterm' === getenv('TERM')
[129] Fix | Delete
|| 'Hyper' === getenv('TERM_PROGRAM'));
[130] Fix | Delete
}
[131] Fix | Delete
[132] Fix | Delete
public static function stream_isatty($stream)
[133] Fix | Delete
{
[134] Fix | Delete
if (!\is_resource($stream)) {
[135] Fix | Delete
trigger_error('stream_isatty() expects parameter 1 to be resource, '.\gettype($stream).' given', E_USER_WARNING);
[136] Fix | Delete
[137] Fix | Delete
return false;
[138] Fix | Delete
}
[139] Fix | Delete
[140] Fix | Delete
if ('\\' === \DIRECTORY_SEPARATOR) {
[141] Fix | Delete
$stat = @fstat($stream);
[142] Fix | Delete
// Check if formatted mode is S_IFCHR
[143] Fix | Delete
return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
[144] Fix | Delete
}
[145] Fix | Delete
[146] Fix | Delete
return \function_exists('posix_isatty') && @posix_isatty($stream);
[147] Fix | Delete
}
[148] Fix | Delete
[149] Fix | Delete
private static function initHashMask()
[150] Fix | Delete
{
[151] Fix | Delete
$obj = (object) array();
[152] Fix | Delete
self::$hashMask = -1;
[153] Fix | Delete
[154] Fix | Delete
// check if we are nested in an output buffering handler to prevent a fatal error with ob_start() below
[155] Fix | Delete
$obFuncs = array('ob_clean', 'ob_end_clean', 'ob_flush', 'ob_end_flush', 'ob_get_contents', 'ob_get_flush');
[156] Fix | Delete
foreach (debug_backtrace(\PHP_VERSION_ID >= 50400 ? DEBUG_BACKTRACE_IGNORE_ARGS : false) as $frame) {
[157] Fix | Delete
if (isset($frame['function'][0]) && !isset($frame['class']) && 'o' === $frame['function'][0] && \in_array($frame['function'], $obFuncs)) {
[158] Fix | Delete
$frame['line'] = 0;
[159] Fix | Delete
break;
[160] Fix | Delete
}
[161] Fix | Delete
}
[162] Fix | Delete
if (!empty($frame['line'])) {
[163] Fix | Delete
ob_start();
[164] Fix | Delete
debug_zval_dump($obj);
[165] Fix | Delete
self::$hashMask = (int) substr(ob_get_clean(), 17);
[166] Fix | Delete
}
[167] Fix | Delete
[168] Fix | Delete
self::$hashMask ^= hexdec(substr(spl_object_hash($obj), 16 - (\PHP_INT_SIZE * 2 - 1), (\PHP_INT_SIZE * 2 - 1)));
[169] Fix | Delete
}
[170] Fix | Delete
[171] Fix | Delete
public static function mb_chr($code, $encoding = null)
[172] Fix | Delete
{
[173] Fix | Delete
if (0x80 > $code %= 0x200000) {
[174] Fix | Delete
$s = \chr($code);
[175] Fix | Delete
} elseif (0x800 > $code) {
[176] Fix | Delete
$s = \chr(0xC0 | $code >> 6).\chr(0x80 | $code & 0x3F);
[177] Fix | Delete
} elseif (0x10000 > $code) {
[178] Fix | Delete
$s = \chr(0xE0 | $code >> 12).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
[179] Fix | Delete
} else {
[180] Fix | Delete
$s = \chr(0xF0 | $code >> 18).\chr(0x80 | $code >> 12 & 0x3F).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
[181] Fix | Delete
}
[182] Fix | Delete
[183] Fix | Delete
if ('UTF-8' !== $encoding) {
[184] Fix | Delete
$s = mb_convert_encoding($s, $encoding, 'UTF-8');
[185] Fix | Delete
}
[186] Fix | Delete
[187] Fix | Delete
return $s;
[188] Fix | Delete
}
[189] Fix | Delete
[190] Fix | Delete
public static function mb_ord($s, $encoding = null)
[191] Fix | Delete
{
[192] Fix | Delete
if (null === $encoding) {
[193] Fix | Delete
$s = mb_convert_encoding($s, 'UTF-8');
[194] Fix | Delete
} elseif ('UTF-8' !== $encoding) {
[195] Fix | Delete
$s = mb_convert_encoding($s, 'UTF-8', $encoding);
[196] Fix | Delete
}
[197] Fix | Delete
[198] Fix | Delete
if (1 === \strlen($s)) {
[199] Fix | Delete
return \ord($s);
[200] Fix | Delete
}
[201] Fix | Delete
[202] Fix | Delete
$code = ($s = unpack('C*', substr($s, 0, 4))) ? $s[1] : 0;
[203] Fix | Delete
if (0xF0 <= $code) {
[204] Fix | Delete
return (($code - 0xF0) << 18) + (($s[2] - 0x80) << 12) + (($s[3] - 0x80) << 6) + $s[4] - 0x80;
[205] Fix | Delete
}
[206] Fix | Delete
if (0xE0 <= $code) {
[207] Fix | Delete
return (($code - 0xE0) << 12) + (($s[2] - 0x80) << 6) + $s[3] - 0x80;
[208] Fix | Delete
}
[209] Fix | Delete
if (0xC0 <= $code) {
[210] Fix | Delete
return (($code - 0xC0) << 6) + $s[2] - 0x80;
[211] Fix | Delete
}
[212] Fix | Delete
[213] Fix | Delete
return $code;
[214] Fix | Delete
}
[215] Fix | Delete
}
[216] Fix | Delete
[217] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function