forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrayValuesRuleTest.php
More file actions
97 lines (88 loc) · 2.46 KB
/
ArrayValuesRuleTest.php
File metadata and controls
97 lines (88 loc) · 2.46 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php declare(strict_types = 1);
namespace PHPStan\Rules\Functions;
use PHPStan\Rules\Rule;
use PHPStan\Testing\RuleTestCase;
use const PHP_VERSION_ID;
/**
* @extends RuleTestCase<ArrayValuesRule>
*/
class ArrayValuesRuleTest extends RuleTestCase
{
protected function getRule(): Rule
{
return new ArrayValuesRule(
self::createReflectionProvider(),
$this->shouldTreatPhpDocTypesAsCertain(),
true,
);
}
public function testFile(): void
{
$tipText = 'Because the type is coming from a PHPDoc, you can turn off this check by setting <fg=cyan>treatPhpDocTypesAsCertain: false</> in your <fg=cyan>%configurationFile%</>.';
$expectedErrors = [
[
'Parameter #1 $array (array{0, 1, 3}) of array_values is already a list, call has no effect.',
8,
],
[
'Parameter #1 $array (array{1, 3}) of array_values is already a list, call has no effect.',
9,
],
[
'Parameter #1 $array (array{\'test\'}) of array_values is already a list, call has no effect.',
10,
],
[
'Parameter #1 $array (array{\'\', \'test\'}) of array_values is already a list, call has no effect.',
12,
],
[
'Parameter #1 $array (list<int>) of array_values is already a list, call has no effect.',
14,
$tipText,
],
[
'Parameter #1 $array (array{0}) of array_values is already a list, call has no effect.',
17,
],
[
'Parameter #1 $array (array{null, null}) of array_values is already a list, call has no effect.',
19,
],
[
'Parameter #1 $array (array{null, 0}) of array_values is already a list, call has no effect.',
20,
],
[
'Parameter #1 $array (array{}) to function array_values is empty, call has no effect.',
21,
],
[
'Parameter #1 $array (array{}) to function array_values is empty, call has no effect.',
25,
$tipText,
],
];
if (PHP_VERSION_ID >= 80000) {
$expectedErrors[] = [
'Parameter #1 $array (list<int>) of array_values is already a list, call has no effect.',
28,
$tipText,
];
} else {
$expectedErrors[] = [
'Parameter #1 $array (true) to function array_values is empty, call has no effect.',
27,
];
$expectedErrors[] = [
'Parameter #1 $array (true) to function array_values is empty, call has no effect.',
28,
];
}
$this->analyse([__DIR__ . '/data/array_values_list.php'], $expectedErrors);
}
public function testBug13629(): void
{
$this->analyse([__DIR__ . '/../../Analyser/nsrt/bug-13629.php'], []);
}
}