forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbug-11054.php
More file actions
58 lines (48 loc) · 1.15 KB
/
bug-11054.php
File metadata and controls
58 lines (48 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php declare(strict_types = 1);
namespace Bug11054;
class XXX {
public const DEF_VALUE = [NAN];
public const NO_VALUE = [NAN];
}
class YYY
{
public const LOSSLESS = [NAN];
/**
* @param string|int|mixed $substituteChar
*/
public static function convertEncoding (
string $str,
string $sourceEncoding,
string $targetEncoding,
$substituteChar = XXX::DEF_VALUE,
$defValue = XXX::NO_VALUE
): string {
if ($substituteChar === XXX::DEF_VALUE) { // no error expected
return mb_convert_encoding($str, $targetEncoding, $sourceEncoding);
}
if ($substituteChar === self::LOSSLESS) { // no error expected
return $str;
}
return $str;
}
}
class InfTest {
public const DEF_VALUE = [INF];
public const NO_VALUE = [INF];
/** @param mixed $v */
public static function test($v): void
{
if ($v === self::DEF_VALUE) { // no error expected
return;
}
if ($v === self::NO_VALUE) {} // error expected - INF === INF is true, so narrowing is correct
}
}
class SimpleTest {
/** @param mixed $v */
public static function test($v): void
{
if ($v === [NAN]) {} // no error expected
if ($v === [INF]) {} // no error expected
}
}