1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Symfony package. |
5
|
|
|
* |
6
|
|
|
* (c) Fabien Potencier <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
use Symfony\Polyfill\Iconv as p; |
13
|
|
|
|
14
|
|
|
if (extension_loaded('iconv')) { |
15
|
|
|
return; |
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
if (!defined('ICONV_IMPL')) { |
19
|
|
|
define('ICONV_IMPL', 'Symfony'); |
20
|
|
|
} |
21
|
|
|
if (!defined('ICONV_VERSION')) { |
22
|
|
|
define('ICONV_VERSION', '1.0'); |
23
|
|
|
} |
24
|
|
|
if (!defined('ICONV_MIME_DECODE_STRICT')) { |
25
|
|
|
define('ICONV_MIME_DECODE_STRICT', 1); |
26
|
|
|
} |
27
|
|
|
if (!defined('ICONV_MIME_DECODE_CONTINUE_ON_ERROR')) { |
28
|
|
|
define('ICONV_MIME_DECODE_CONTINUE_ON_ERROR', 2); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
if (!function_exists('iconv')) { |
32
|
|
|
function iconv($from_encoding, $to_encoding, $string) { return p\Iconv::iconv($from_encoding, $to_encoding, $string); } |
33
|
|
|
} |
34
|
|
|
if (!function_exists('iconv_get_encoding')) { |
35
|
|
|
function iconv_get_encoding($type = 'all') { return p\Iconv::iconv_get_encoding($type); } |
36
|
|
|
} |
37
|
|
|
if (!function_exists('iconv_set_encoding')) { |
38
|
|
|
function iconv_set_encoding($type, $encoding) { return p\Iconv::iconv_set_encoding($type, $encoding); } |
39
|
|
|
} |
40
|
|
|
if (!function_exists('iconv_mime_encode')) { |
41
|
|
|
function iconv_mime_encode($field_name, $field_value, $options = null) { return p\Iconv::iconv_mime_encode($field_name, $field_value, $options); } |
42
|
|
|
} |
43
|
|
|
if (!function_exists('iconv_mime_decode_headers')) { |
44
|
|
|
function iconv_mime_decode_headers($headers, $mode = 0, $encoding = null) { return p\Iconv::iconv_mime_decode_headers($headers, $mode, $encoding); } |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
if (extension_loaded('mbstring')) { |
48
|
|
|
if (!function_exists('iconv_strlen')) { |
49
|
|
|
function iconv_strlen($string, $encoding = null) { null === $encoding && $encoding = p\Iconv::$internalEncoding; return mb_strlen($string, $encoding); } |
50
|
|
|
} |
51
|
|
|
if (!function_exists('iconv_strpos')) { |
52
|
|
|
function iconv_strpos($haystack, $needle, $offset = 0, $encoding = null) { null === $encoding && $encoding = p\Iconv::$internalEncoding; return mb_strpos($haystack, $needle, $offset, $encoding); } |
53
|
|
|
} |
54
|
|
|
if (!function_exists('iconv_strrpos')) { |
55
|
|
|
function iconv_strrpos($haystack, $needle, $encoding = null) { null === $encoding && $encoding = p\Iconv::$internalEncoding; return mb_strrpos($haystack, $needle, 0, $encoding); } |
56
|
|
|
} |
57
|
|
|
if (!function_exists('iconv_substr')) { |
58
|
|
|
function iconv_substr($string, $offset, $length = 2147483647, $encoding = null) { null === $encoding && $encoding = p\Iconv::$internalEncoding; return mb_substr($string, $offset, $length, $encoding); } |
59
|
|
|
} |
60
|
|
|
if (!function_exists('iconv_mime_decode')) { |
61
|
|
|
function iconv_mime_decode($string, $mode = 0, $encoding = null) { null === $encoding && $encoding = p\Iconv::$internalEncoding; return mb_decode_mimeheader($string, $mode, $encoding); } |
|
|
|
|
62
|
|
|
} |
63
|
|
|
} else { |
64
|
|
|
if (!function_exists('iconv_strlen')) { |
65
|
|
|
if (extension_loaded('xml')) { |
66
|
|
|
function iconv_strlen($string, $encoding = null) { return p\Iconv::strlen1($string, $encoding); } |
67
|
|
|
} else { |
68
|
|
|
function iconv_strlen($string, $encoding = null) { return p\Iconv::strlen2($string, $encoding); } |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
if (!function_exists('iconv_strpos')) { |
73
|
|
|
function iconv_strpos($haystack, $needle, $offset = 0, $encoding = null) { return p\Iconv::iconv_strpos($haystack, $needle, $offset, $encoding); } |
74
|
|
|
} |
75
|
|
|
if (!function_exists('iconv_strrpos')) { |
76
|
|
|
function iconv_strrpos($haystack, $needle, $encoding = null) { return p\Iconv::iconv_strrpos($haystack, $needle, $encoding); } |
77
|
|
|
} |
78
|
|
|
if (!function_exists('iconv_substr')) { |
79
|
|
|
function iconv_substr($string, $offset, $length = 2147483647, $encoding = null) { return p\Iconv::iconv_substr($string, $offset, $length, $encoding); } |
80
|
|
|
} |
81
|
|
|
if (!function_exists('iconv_mime_decode')) { |
82
|
|
|
function iconv_mime_decode($string, $mode = 0, $encoding = null) { return p\Iconv::iconv_mime_decode($string, $mode, $encoding); } |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.