mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-08 17:07:03 +03:00
More params and returns to PHP 7.3+
This commit is contained in:
parent
3d246ae842
commit
26c38b3ec9
95 changed files with 1028 additions and 4865 deletions
|
|
@ -65,9 +65,7 @@ class Net_IDNA2
|
|||
* These Unicode codepoints are
|
||||
* mapped to nothing, See RFC3454 for details
|
||||
*
|
||||
* @static
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
private static $_np_map_nothing = array(
|
||||
0xAD,
|
||||
|
|
@ -102,9 +100,7 @@ class Net_IDNA2
|
|||
/**
|
||||
* Prohibited codepints
|
||||
*
|
||||
* @static
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
private static $_general_prohibited = array(
|
||||
0,
|
||||
|
|
@ -175,9 +171,7 @@ class Net_IDNA2
|
|||
|
||||
/**
|
||||
* Codepints prohibited by Nameprep
|
||||
* @static
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
private static $_np_prohibit = array(
|
||||
0xA0,
|
||||
|
|
@ -269,9 +263,7 @@ class Net_IDNA2
|
|||
/**
|
||||
* Codepoint ranges prohibited by nameprep
|
||||
*
|
||||
* @static
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
private static $_np_prohibit_ranges = array(
|
||||
array(0x80, 0x9F ),
|
||||
|
|
@ -289,9 +281,7 @@ class Net_IDNA2
|
|||
/**
|
||||
* Replacement mappings (casemapping, replacement sequences, ...)
|
||||
*
|
||||
* @static
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
private static $_np_replacemaps = array(
|
||||
0x41 => array(0x61),
|
||||
|
|
@ -1702,9 +1692,7 @@ class Net_IDNA2
|
|||
* Normalization Combining Classes; Code Points not listed
|
||||
* got Combining Class 0.
|
||||
*
|
||||
* @static
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
private static $_np_norm_combcls = array(
|
||||
0x334 => 1,
|
||||
|
|
@ -2054,103 +2042,85 @@ class Net_IDNA2
|
|||
// {{{ properties
|
||||
/**
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
private $_punycode_prefix = 'xn--';
|
||||
|
||||
/**
|
||||
* @access private
|
||||
*/
|
||||
private $_invalid_ucs = 0x80000000;
|
||||
|
||||
/**
|
||||
* @access private
|
||||
*/
|
||||
private $_max_ucs = 0x10FFFF;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
* @access private
|
||||
*/
|
||||
private $_base = 36;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
* @access private
|
||||
*/
|
||||
private $_tmin = 1;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
* @access private
|
||||
*/
|
||||
private $_tmax = 26;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
* @access private
|
||||
*/
|
||||
private $_skew = 38;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
* @access private
|
||||
*/
|
||||
private $_damp = 700;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
* @access private
|
||||
*/
|
||||
private $_initial_bias = 72;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
* @access private
|
||||
*/
|
||||
private $_initial_n = 0x80;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
* @access private
|
||||
*/
|
||||
private $_slast;
|
||||
|
||||
/**
|
||||
* @access private
|
||||
*/
|
||||
private $_sbase = 0xAC00;
|
||||
|
||||
/**
|
||||
* @access private
|
||||
*/
|
||||
private $_lbase = 0x1100;
|
||||
|
||||
/**
|
||||
* @access private
|
||||
*/
|
||||
private $_vbase = 0x1161;
|
||||
|
||||
/**
|
||||
* @access private
|
||||
*/
|
||||
private $_tbase = 0x11a7;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
* @access private
|
||||
*/
|
||||
private $_lcount = 19;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
* @access private
|
||||
*/
|
||||
private $_vcount = 21;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
* @access private
|
||||
*/
|
||||
private $_tcount = 28;
|
||||
|
||||
|
|
@ -2158,7 +2128,6 @@ class Net_IDNA2
|
|||
* vcount * tcount
|
||||
*
|
||||
* @var int
|
||||
* @access private
|
||||
*/
|
||||
private $_ncount = 588;
|
||||
|
||||
|
|
@ -2166,7 +2135,6 @@ class Net_IDNA2
|
|||
* lcount * tcount * vcount
|
||||
*
|
||||
* @var int
|
||||
* @access private
|
||||
*/
|
||||
private $_scount = 11172;
|
||||
|
||||
|
|
@ -2176,7 +2144,6 @@ class Net_IDNA2
|
|||
* See {@link setParams()} for how to select these
|
||||
*
|
||||
* @var bool
|
||||
* @access private
|
||||
*/
|
||||
private $_api_encoding = 'utf8';
|
||||
|
||||
|
|
@ -2184,7 +2151,6 @@ class Net_IDNA2
|
|||
* Overlong UTF-8 encodings are forbidden
|
||||
*
|
||||
* @var bool
|
||||
* @access private
|
||||
*/
|
||||
private $_allow_overlong = false;
|
||||
|
||||
|
|
@ -2192,7 +2158,6 @@ class Net_IDNA2
|
|||
* Behave strict or not
|
||||
*
|
||||
* @var bool
|
||||
* @access private
|
||||
*/
|
||||
private $_strict_mode = false;
|
||||
|
||||
|
|
@ -2206,7 +2171,6 @@ class Net_IDNA2
|
|||
* please switch to 2008 first before encoding.
|
||||
*
|
||||
* @var bool
|
||||
* @access private
|
||||
*/
|
||||
private $_version = '2003';
|
||||
|
||||
|
|
@ -2227,9 +2191,6 @@ class Net_IDNA2
|
|||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param array $options Options to initialise the object with
|
||||
*
|
||||
* @access public
|
||||
* @see setParams()
|
||||
*/
|
||||
public function __construct($options = null)
|
||||
|
|
@ -2262,12 +2223,9 @@ class Net_IDNA2
|
|||
* by silently ignoring errors and returning the original input instead]
|
||||
*
|
||||
* @param mixed $option Parameter to set (string: single parameter; array of Parameter => Value pairs)
|
||||
* @param string $value Value to use (if parameter 1 is a string)
|
||||
*
|
||||
* @return boolean true on success, false otherwise
|
||||
* @access public
|
||||
*/
|
||||
public function setParams($option, $value = false)
|
||||
public function setParams($option, $value = false) : bool
|
||||
{
|
||||
if (!is_array($option)) {
|
||||
$option = array($option => $value);
|
||||
|
|
@ -2316,14 +2274,10 @@ class Net_IDNA2
|
|||
/**
|
||||
* Encode a given UTF-8 domain name.
|
||||
*
|
||||
* @param string $decoded Domain name (UTF-8 or UCS-4)
|
||||
* @param string $one_time_encoding Desired input encoding, see {@link set_parameter}
|
||||
* If not given will use default-encoding
|
||||
*
|
||||
* @return string Encoded Domain name (ACE string)
|
||||
* @return mixed processed string
|
||||
* @throws Exception
|
||||
* @access public
|
||||
*/
|
||||
public function encode($decoded, $one_time_encoding = false)
|
||||
{
|
||||
|
|
@ -2406,12 +2360,7 @@ class Net_IDNA2
|
|||
/**
|
||||
* Decode a given ACE domain name.
|
||||
*
|
||||
* @param string $input Domain name (ACE string)
|
||||
* @param string $one_time_encoding Desired output encoding, see {@link set_parameter}
|
||||
*
|
||||
* @return string Decoded Domain name (UTF-8 or UCS-4)
|
||||
* @throws Exception
|
||||
* @access public
|
||||
*/
|
||||
public function decode($input, $one_time_encoding = false)
|
||||
{
|
||||
|
|
@ -2495,13 +2444,8 @@ class Net_IDNA2
|
|||
* Opposite function to parse_url()
|
||||
*
|
||||
* Inspired by code from comments of php.net-documentation for parse_url()
|
||||
*
|
||||
* @param array $parts_arr parts (strings) as returned by parse_url()
|
||||
*
|
||||
* @return string
|
||||
* @access private
|
||||
*/
|
||||
private function _unparse_url($parts_arr)
|
||||
private function _unparse_url($parts_arr) : string
|
||||
{
|
||||
if (!empty($parts_arr['scheme'])) {
|
||||
$ret_url = $parts_arr['scheme'];
|
||||
|
|
@ -2530,13 +2474,9 @@ class Net_IDNA2
|
|||
/**
|
||||
* The actual encoding algorithm.
|
||||
*
|
||||
* @param string $decoded Decoded string which should be encoded
|
||||
*
|
||||
* @return string Encoded string
|
||||
* @throws Exception
|
||||
* @access private
|
||||
*/
|
||||
private function _encode($decoded)
|
||||
private function _encode($decoded) : string
|
||||
{
|
||||
// We cannot encode a domain name containing the Punycode prefix
|
||||
$extract = self::_byteLength($this->_punycode_prefix);
|
||||
|
|
@ -2661,13 +2601,9 @@ class Net_IDNA2
|
|||
/**
|
||||
* The actual decoding algorithm.
|
||||
*
|
||||
* @param string $encoded Encoded string which should be decoded
|
||||
*
|
||||
* @return string Decoded string
|
||||
* @throws Exception
|
||||
* @access private
|
||||
*/
|
||||
private function _decode($encoded)
|
||||
private function _decode($encoded) : string
|
||||
{
|
||||
// We do need to find the Punycode prefix
|
||||
if (!preg_match('!^' . preg_quote($this->_punycode_prefix, '!') . '!', $encoded)) {
|
||||
|
|
@ -2737,15 +2673,8 @@ class Net_IDNA2
|
|||
|
||||
/**
|
||||
* Adapt the bias according to the current code point and position.
|
||||
*
|
||||
* @param int $delta ...
|
||||
* @param int $npoints ...
|
||||
* @param boolean $is_first ...
|
||||
*
|
||||
* @return int
|
||||
* @access private
|
||||
*/
|
||||
private function _adapt($delta, $npoints, $is_first)
|
||||
private function _adapt($delta, $npoints, $is_first) : int
|
||||
{
|
||||
$delta = (int) ($is_first ? ($delta / $this->_damp) : ($delta / 2));
|
||||
$delta += (int) ($delta / $npoints);
|
||||
|
|
@ -2760,10 +2689,7 @@ class Net_IDNA2
|
|||
/**
|
||||
* Encoding a certain digit.
|
||||
*
|
||||
* @param int $d One digit to encode
|
||||
*
|
||||
* @return char Encoded digit
|
||||
* @access private
|
||||
*/
|
||||
private function _encodeDigit($d)
|
||||
{
|
||||
|
|
@ -2774,11 +2700,8 @@ class Net_IDNA2
|
|||
* Decode a certain digit.
|
||||
*
|
||||
* @param char $cp One digit (character) to decode
|
||||
*
|
||||
* @return int Decoded digit
|
||||
* @access private
|
||||
*/
|
||||
private function _decodeDigit($cp)
|
||||
private function _decodeDigit($cp) : int
|
||||
{
|
||||
$cp = ord($cp);
|
||||
return ($cp - 48 < 10)? $cp - 22 : (($cp - 65 < 26)? $cp - 65 : (($cp - 97 < 26)? $cp - 97 : $this->_base));
|
||||
|
|
@ -2787,13 +2710,9 @@ class Net_IDNA2
|
|||
/**
|
||||
* Do Nameprep according to RFC3491 and RFC3454.
|
||||
*
|
||||
* @param array $input Unicode Characters
|
||||
*
|
||||
* @return string Unicode Characters, Nameprep'd
|
||||
* @throws Exception
|
||||
* @access private
|
||||
*/
|
||||
private function _nameprep($input)
|
||||
private function _nameprep($input) : string
|
||||
{
|
||||
$output = array();
|
||||
|
||||
|
|
@ -2885,13 +2804,9 @@ class Net_IDNA2
|
|||
* Decomposes a Hangul syllable
|
||||
* (see http://www.unicode.org/unicode/reports/tr15/#Hangul).
|
||||
*
|
||||
* @param integer $char 32bit UCS4 code point
|
||||
*
|
||||
* @return array Either Hangul Syllable decomposed or original 32bit
|
||||
* value as one value array
|
||||
* @access private
|
||||
*/
|
||||
private function _hangulDecompose($char)
|
||||
private function _hangulDecompose($char) : array
|
||||
{
|
||||
$sindex = $char - $this->_sbase;
|
||||
|
||||
|
|
@ -2914,13 +2829,8 @@ class Net_IDNA2
|
|||
/**
|
||||
* Ccomposes a Hangul syllable
|
||||
* (see http://www.unicode.org/unicode/reports/tr15/#Hangul).
|
||||
*
|
||||
* @param array $input Decomposed UCS4 sequence
|
||||
*
|
||||
* @return array UCS4 sequence with syllables composed
|
||||
* @access private
|
||||
*/
|
||||
private function _hangulCompose($input)
|
||||
private function _hangulCompose($input) : array
|
||||
{
|
||||
$inp_len = count($input);
|
||||
|
||||
|
|
@ -2979,26 +2889,16 @@ class Net_IDNA2
|
|||
|
||||
/**
|
||||
* Returns the combining class of a certain wide char.
|
||||
*
|
||||
* @param integer $char Wide char to check (32bit integer)
|
||||
*
|
||||
* @return integer Combining class if found, else 0
|
||||
* @access private
|
||||
*/
|
||||
private function _getCombiningClass($char)
|
||||
private function _getCombiningClass($char) : int
|
||||
{
|
||||
return isset(self::$_np_norm_combcls[$char])? self::$_np_norm_combcls[$char] : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apllies the cannonical ordering of a decomposed UCS4 sequence.
|
||||
*
|
||||
* @param array $input Decomposed UCS4 sequence
|
||||
*
|
||||
* @return array Ordered USC4 sequence
|
||||
* @access private
|
||||
*/
|
||||
private function _applyCannonicalOrdering($input)
|
||||
private function _applyCannonicalOrdering($input) : array
|
||||
{
|
||||
$swap = true;
|
||||
$size = count($input);
|
||||
|
|
@ -3036,13 +2936,8 @@ class Net_IDNA2
|
|||
|
||||
/**
|
||||
* Do composition of a sequence of starter and non-starter.
|
||||
*
|
||||
* @param array $input UCS4 Decomposed sequence
|
||||
*
|
||||
* @return array Ordered USC4 sequence
|
||||
* @access private
|
||||
*/
|
||||
private function _combine($input)
|
||||
private function _combine($input) : array
|
||||
{
|
||||
$inp_len = count($input);
|
||||
|
||||
|
|
@ -3101,13 +2996,9 @@ class Net_IDNA2
|
|||
*
|
||||
* Each x represents a bit that can be used to store character data.
|
||||
*
|
||||
* @param string $input utf8-encoded string
|
||||
*
|
||||
* @return array ucs4-encoded array
|
||||
* @throws Exception
|
||||
* @access private
|
||||
*/
|
||||
private function _utf8_to_ucs4($input)
|
||||
private function _utf8_to_ucs4($input) : array
|
||||
{
|
||||
$output = array();
|
||||
$out_len = 0;
|
||||
|
|
@ -3178,13 +3069,9 @@ class Net_IDNA2
|
|||
/**
|
||||
* Convert UCS-4 array into UTF-8 string
|
||||
*
|
||||
* @param array $input ucs4-encoded array
|
||||
*
|
||||
* @return string utf8-encoded string
|
||||
* @throws Exception
|
||||
* @access private
|
||||
*/
|
||||
private function _ucs4_to_utf8($input)
|
||||
private function _ucs4_to_utf8($input) : string
|
||||
{
|
||||
$output = '';
|
||||
|
||||
|
|
@ -3235,13 +3122,9 @@ class Net_IDNA2
|
|||
/**
|
||||
* Convert UCS-4 array into UCS-4 string
|
||||
*
|
||||
* @param array $input ucs4-encoded array
|
||||
*
|
||||
* @return string ucs4-encoded string
|
||||
* @throws Exception
|
||||
* @access private
|
||||
*/
|
||||
private function _ucs4_to_ucs4_string($input)
|
||||
private function _ucs4_to_ucs4_string($input) : string
|
||||
{
|
||||
$output = '';
|
||||
// Take array values and split output to 4 bytes per value
|
||||
|
|
@ -3255,13 +3138,9 @@ class Net_IDNA2
|
|||
/**
|
||||
* Convert UCS-4 string into UCS-4 array
|
||||
*
|
||||
* @param string $input ucs4-encoded string
|
||||
*
|
||||
* @return array ucs4-encoded array
|
||||
* @throws InvalidArgumentException
|
||||
* @access private
|
||||
*/
|
||||
private function _ucs4_string_to_ucs4($input)
|
||||
private function _ucs4_string_to_ucs4($input) : array
|
||||
{
|
||||
$output = array();
|
||||
|
||||
|
|
@ -3289,9 +3168,6 @@ class Net_IDNA2
|
|||
|
||||
/**
|
||||
* Echo hex representation of UCS4 sequence.
|
||||
*
|
||||
* @param array $input UCS4 sequence
|
||||
* @param boolean $include_bit Include bitmask in output
|
||||
*/
|
||||
private static function _showHex($input, $include_bit = false) : void
|
||||
{
|
||||
|
|
@ -3309,14 +3185,8 @@ class Net_IDNA2
|
|||
/**
|
||||
* Gives you a bit representation of given Byte (8 bits), Word (16 bits) or DWord (32 bits)
|
||||
* Output width is automagically determined
|
||||
*
|
||||
* @param int $octet ...
|
||||
*
|
||||
* @return string Bitmask-representation
|
||||
* @static
|
||||
* @access private
|
||||
*/
|
||||
private static function _showBitmask($octet)
|
||||
private static function _showBitmask($octet) : string
|
||||
{
|
||||
if ($octet >= (1 << 16)) {
|
||||
$w = 31;
|
||||
|
|
@ -3339,13 +3209,9 @@ class Net_IDNA2
|
|||
* Gets the length of a string in bytes even if mbstring function
|
||||
* overloading is turned on
|
||||
*
|
||||
* @param string $string the string for which to get the length.
|
||||
*
|
||||
* @return integer the length of the string in bytes.
|
||||
*
|
||||
* @see Net_IDNA2::$_mb_string_overload
|
||||
*/
|
||||
private static function _byteLength($string)
|
||||
private static function _byteLength($string) : int
|
||||
{
|
||||
if (self::$_mb_string_overload) {
|
||||
return mb_strlen($string, '8bit');
|
||||
|
|
@ -3359,10 +3225,7 @@ class Net_IDNA2
|
|||
/**
|
||||
* Attempts to return a concrete IDNA instance for either php4 or php5.
|
||||
*
|
||||
* @param array $params Set of paramaters
|
||||
*
|
||||
* @return Net_IDNA2
|
||||
* @access public
|
||||
*/
|
||||
function getInstance($params = array())
|
||||
{
|
||||
|
|
@ -3376,10 +3239,7 @@ class Net_IDNA2
|
|||
* only creating a new instance if no IDNA instance with the same
|
||||
* parameters currently exists.
|
||||
*
|
||||
* @param array $params Set of paramaters
|
||||
*
|
||||
* @return object Net_IDNA2
|
||||
* @access public
|
||||
*/
|
||||
function singleton($params = array())
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue