forked from phpstan/phpstan-strict-rules
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrayFilterStrictRuleTest.php
More file actions
72 lines (64 loc) · 1.78 KB
/
Copy pathArrayFilterStrictRuleTest.php
File metadata and controls
72 lines (64 loc) · 1.78 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
<?php declare(strict_types = 1);
namespace PHPStan\Rules\Functions;
use PHPStan\Rules\Rule;
use PHPStan\Testing\RuleTestCase;
/**
* @extends RuleTestCase<ArrayFilterStrictRule>
*/
class ArrayFilterStrictRuleTest extends RuleTestCase
{
private bool $checkNullables;
protected function getRule(): Rule
{
return new ArrayFilterStrictRule(
$this->createReflectionProvider(),
$this->shouldTreatPhpDocTypesAsCertain(),
$this->checkNullables,
true,
);
}
public function testRule(): void
{
$this->checkNullables = true;
$this->analyse([__DIR__ . '/data/array-filter-strict.php'], [
[
'Call to function array_filter() requires parameter #2 to be passed to avoid loose comparison semantics.',
15,
],
[
'Call to function array_filter() requires parameter #2 to be passed to avoid loose comparison semantics.',
25,
],
[
'Call to function array_filter() requires parameter #2 to be passed to avoid loose comparison semantics.',
26,
],
[
'Parameter #2 of array_filter() cannot be null to avoid loose comparison semantics (null given).',
28,
],
[
'Parameter #2 of array_filter() cannot be null to avoid loose comparison semantics ((Closure)|null given).',
34,
],
]);
}
public function testRuleAllowMissingCallbackInSomeCases(): void
{
$this->checkNullables = true;
$this->analyse([__DIR__ . '/data/array-filter-allow.php'], [
[
'Call to function array_filter() requires parameter #2 to be passed to avoid loose comparison semantics.',
27,
],
[
'Call to function array_filter() requires parameter #2 to be passed to avoid loose comparison semantics.',
37,
],
[
'Call to function array_filter() requires parameter #2 to be passed to avoid loose comparison semantics.',
49,
],
]);
}
}