* В Украине сейчас идет война. Силами РФ наносятся удары по гражданской инфраструктуре в [Харькове][1], [Киеве][2], [Чернигове][3], [Сумах][4], [Ирпене][5] и десятках других городов. Гибнут люди - и гражданское население, и военные, в том числе российские призывники, которых бросили воевать. Чтобы лишить собственный народ доступа к информации, правительство РФ запретило называть войну войной, закрыло независимые СМИ и принимает сейчас ряд диктаторских законов. Эти законы призваны заткнуть рот всем, кто против войны. За обычный призыв к миру сейчас можно получить несколько лет тюрьмы.
10
* Не молчите! Молчание - знак вашего согласия с политикой российского правительства.
11
* **Вы можете сделать выбор НЕ МОЛЧАТЬ.**
12
* ---
13
* ## 🇺🇸 To people of Russia
14
* There is a war in Ukraine right now. The forces of the Russian Federation are attacking civilian infrastructure in [Kharkiv][1], [Kyiv][2], [Chernihiv][3], [Sumy][4], [Irpin][5] and dozens of other cities. People are dying – both civilians and military servicemen, including Russian conscripts who were thrown into the fighting. In order to deprive its own people of access to information, the government of the Russian Federation has forbidden calling a war a war, shut down independent media and is passing a number of dictatorial laws. These laws are meant to silence all those who are against war. You can be jailed for multiple years for simply calling for peace.
15
* Do not be silent! Silence is a sign that you accept the Russian government's policy.
16
* **You can choose NOT TO BE SILENT.**
17
* ---
18
* - [1] https://cloudfront-us-east-2.images.arcpublishing.com/reuters/P7K2MSZDGFMIJPDD7CI2GIROJI.jpg "Kharkiv under attack"
19
* - [2] https://gdb.voanews.com/01bd0000-0aff-0242-fad0-08d9fc92c5b3_cx0_cy5_cw0_w1023_r1_s.jpg "Kyiv under attack"
20
* - [3] https://ichef.bbci.co.uk/news/976/cpsprodpb/163DD/production/_123510119_hi074310744.jpg "Chernihiv under attack"
21
* - [4] https://www.youtube.com/watch?v=8K-bkqKKf2A "Sumy under attack"
22
* - [5] https://cloudfront-us-east-2.images.arcpublishing.com/reuters/K4MTMLEHTRKGFK3GSKAT4GR3NE.jpg "Irpin under attack"
The expression return self::str_split($str) returns an array which contains values of type string[] which are incompatible with the documented value type string.
Loading history...
511
}
512
513
/**
514
* This method will auto-detect your server environment for UTF-8 support.
515
*
516
* @return true|null
517
*
518
* @internal <p>You don't need to run it manually, it will be triggered if it's needed.</p>
519
*/
520
4
public static function checkForSupport()
521
{
522
4
if (!isset(self::$SUPPORT['already_checked_via_portable_utf8'])) {
The expression return mb_convert_encodi...TF-8', 'HTML-ENTITIES') could return the type array which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
1206
}
1207
1208
/**
1209
* Decodes a MIME header field
1210
*
1211
* @param string $str
1212
* @param string $encoding [optional] <p>Set the charset for e.g. "mb_" function</p>
1213
*
1214
* @psalm-pure
1215
*
1216
* @return false|string
1217
* <p>A decoded MIME field on success,
1218
* or false if an error occurs during the decoding.</p>
1219
*/
1220
2
public static function decode_mimeheader($str, string $encoding = 'UTF-8')
1221
{
1222
2
if ($encoding !== 'UTF-8' && $encoding !== 'CP850') {
The expression return self::filter($a) also could return the type object|string which is incompatible with the documented return type array<string,mixed>|false|null.
Loading history...
2081
}
2082
2083
/**
2084
* "filter_var()"-wrapper with normalizes to UTF-8 NFC, converting from WINDOWS-1252 when needed.
It seems like $options can also be of type null; however, parameter $options of filter_var() does only seem to accept array|integer, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the ignore-type annotation
It seems like $definition can also be of type null; however, parameter $options of filter_var_array() does only seem to accept array|integer, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the ignore-type annotation
The expression return self::filter($a) also could return the type object|string which is incompatible with the documented return type array<string,mixed>|false|null.
Loading history...
2234
}
2235
2236
/**
2237
* Checks whether finfo is available on the server.
2238
*
2239
* @psalm-pure
2240
*
2241
* @return bool
2242
* <p><strong>true</strong> if available, <strong>false</strong> otherwise</p>
2243
*
2244
* @internal <p>Please do not use it anymore, we will make is private in next major version.</p>
2245
*/
2246
public static function finfo_loaded(): bool
2247
{
2248
return \class_exists('finfo');
2249
}
2250
2251
/**
2252
* Returns the first $n characters of the string.
2253
*
2254
* @param string $str <p>The input string.</p>
2255
* @param int $n <p>Number of characters to retrieve from the start.</p>
2256
* @param string $encoding [optional] <p>Set the charset for e.g. "mb_" function</p>
This check compares calls to functions or methods with their respective definitions.
If the call has less 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.
It seems like $test3 can also be of type array; however, parameter $str of voku\helper\UTF8::count_chars() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the ignore-type annotation
It seems like $test3 can also be of type array; however, parameter $str of voku\helper\UTF8::count_chars() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the ignore-type annotation
* @param string $str <p>The string to be normalized.</p>
4706
* @param bool $keep_non_breaking_space [optional] <p>Set to true, to keep non-breaking-spaces.</p>
4707
* @param bool $keep_bidi_unicode_controls [optional] <p>Set to true, to keep non-printable (for the web)
4708
* bidirectional text chars.</p>
4709
* @param bool $normalize_control_characters [optional] <p>Set to true, to convert e.g. LINE-, PARAGRAPH-SEPARATOR with "\n" and LINE TABULATION with "\t".</p>
4710
*
4711
* @psalm-pure
4712
*
4713
* @return string
4714
* <p>A string with normalized whitespace.</p>
4715
*/
4716
61
public static function normalize_whitespace(
4717
string $str,
4718
bool $keep_non_breaking_space = false,
4719
bool $keep_bidi_unicode_controls = false,
4720
bool $normalize_control_characters = false
4721
): string {
4722
61
return ASCII::normalize_whitespace(
4723
$str,
4724
$keep_non_breaking_space,
4725
$keep_bidi_unicode_controls,
4726
$normalize_control_characters
4727
);
4728
}
4729
4730
/**
4731
* Calculates Unicode code point of the given UTF-8 encoded character.
4732
*
4733
* INFO: opposite to UTF8::chr()
4734
*
4735
* EXAMPLE: <code>UTF8::ord('☃'); // 0x2603</code>
4736
*
4737
* @param string $chr <p>The character of which to calculate code point.<p/>
4738
* @param string $encoding [optional] <p>Set the charset for e.g. "mb_" function</p>
4739
*
4740
* @psalm-pure
4741
*
4742
* @return int
4743
* <p>Unicode code point of the given character,<br>
4744
* 0 on invalid UTF-8 byte sequence</p>
4745
*/
4746
27
public static function ord($chr, string $encoding = 'UTF-8'): int
4747
{
4748
/**
4749
* @psalm-suppress ImpureStaticVariable
4750
*
4751
* @var array<string,int>
4752
*/
4753
27
static $CHAR_CACHE = [];
4754
4755
// init
4756
27
$chr = (string) $chr;
4757
4758
27
if ($encoding !== 'UTF-8' && $encoding !== 'CP850') {
The expression $code of type integer|null is loosely compared to true; this is ambiguous if the integer can be 0. You might want to explicitly use !== null instead.
In PHP, under loose comparison (like ==, or !=, or switch conditions),
values of different types might be equal.
For integer values, zero is a special case, in particular the following
results might be unexpected:
0==false// true0==null// true123==false// false123==null// false// It is often better to use strict comparison0===false// false0===null// false
The expression return self::str_ireplac...ch, $replacement, $str) could return the type string[] which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
5310
}
5311
5312
/**
5313
* Replaces all occurrences of $search in $str by $replacement.
5314
*
5315
* @param string $str <p>The input string.</p>
5316
* @param string[] $search <p>The elements to search for.</p>
5317
* @param string|string[] $replacement <p>The string to replace with.</p>
5318
* @param bool $case_sensitive [optional] <p>Whether or not to enforce case-sensitivity. Default: true</p>
The expression return self::str_ireplac...ch, $replacement, $str) could return the type string[] which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
5336
}
5337
5338
/**
5339
* Replace the diamond question mark (�) and invalid-UTF8 chars with the replacement.
It seems like you do not handle an error condition for mb_substitute_character(). This can introduce security issues, and is generally not recommended.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the ignore-unhandled annotation
If you suppress an error, we recommend checking for the error condition explicitly:
// For example instead of@mkdir($dir);// Better useif(@mkdir($dir)===false){thrownew\RuntimeException('The directory '.$dir.' could not be created.');}
Loading history...
5380
// the polyfill maybe return false, so cast to string
It seems like $save can also be of type true; however, parameter $substitute_character of mb_substitute_character() does only seem to accept integer|null|string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the ignore-type annotation
The expression return self::str_split_a...ry_to_use_mb_functions) returns the type array<mixed,string[]> which is incompatible with the documented return type string[].
The expression return mb_convert_encodi...TF-8', 'HTML-ENTITIES') could return the type array which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
9263
}
9264
9265
/**
9266
* Checks if string starts with "BOM" (Byte Order Mark Character) character.
* @param string|string[] $to [optional] <p>The string being translated to to.</p>
11211
*
11212
* @psalm-pure
11213
*
11214
* @return string
11215
* <p>This function returns a copy of str, translating all occurrences of each character in "from"
11216
* to the corresponding character in "to".</p>
11217
*/
11218
2
public static function strtr(string $str, $from, $to = ''): string
11219
{
11220
2
if ($str === '') {
11221
return '';
11222
}
11223
11224
2
if ($from === $to) {
11225
return $str;
11226
}
11227
11228
2
if ($to !== '') {
11229
2
if (!\is_array($from)) {
11230
2
$from = self::str_split($from);
11231
}
11232
11233
2
if (!\is_array($to)) {
11234
2
$to = self::str_split($to);
11235
}
11236
11237
2
$count_from = \count($from);
11238
2
$count_to = \count($to);
11239
11240
2
if ($count_from !== $count_to) {
11241
2
if ($count_from > $count_to) {
11242
2
$from = \array_slice($from, 0, $count_to);
11243
2
} elseif ($count_from < $count_to) {
11244
2
$to = \array_slice($to, 0, $count_from);
11245
}
11246
}
11247
11248
2
$from = \array_combine($from, $to);
11249
2
if ($from === false) {
11250
throw new \InvalidArgumentException('The number of elements for each array isn\'t equal or the arrays are empty: (from: ' . \print_r($from, true) . ' | to: ' . \print_r($to, true) . ')');
Are you sure print_r($to, true) of type string|true can be used in concatenation?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the ignore-type annotation
11250
throw new \InvalidArgumentException('The number of elements for each array isn\'t equal or the arrays are empty: (from: ' . \print_r($from, true) . ' | to: ' . /** @scrutinizer ignore-type */ \print_r($to, true) . ')');
Are you sure print_r($from, true) of type string|true can be used in concatenation?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the ignore-type annotation
11250
throw new \InvalidArgumentException('The number of elements for each array isn\'t equal or the arrays are empty: (from: ' . /** @scrutinizer ignore-type */ \print_r($from, true) . ' | to: ' . \print_r($to, true) . ')');
It seems like $to can also be of type array<mixed,string[]>; however, parameter $replace of str_replace() does only seem to accept string|string[], maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the ignore-type annotation
The expression $length of type integer|null is loosely compared to false; this is ambiguous if the integer can be 0. You might want to explicitly use === null instead.
In PHP, under loose comparison (like ==, or !=, or switch conditions),
values of different types might be equal.
For integer values, zero is a special case, in particular the following
results might be unexpected:
0==false// true0==null// true123==false// false123==null// false// It is often better to use strict comparison0===false// false0===null// false
Loading history...
11409
return '';
11410
}
11411
11412
// impossible
11413
4
if ($offset && $offset > $str_length) {
11414
return '';
11415
}
11416
11417
4
$length = $length ?? $str_length;
11418
11419
if (
11420
4
$encoding !== 'UTF-8'
11421
&&
11422
4
self::$SUPPORT['mbstring'] === false
11423
) {
11424
/**
11425
* @psalm-suppress ImpureFunctionCall - is is only a warning
It seems like $str can also be of type false; however, parameter $string of utf8_encode() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the ignore-type annotation
$class_array was never initialized. Although not strictly required by PHP, it is generally a good practice to add $class_array = array(); before regardless.