-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathUseSafeCallablesRuleTest.php
More file actions
42 lines (35 loc) · 1.13 KB
/
UseSafeCallablesRuleTest.php
File metadata and controls
42 lines (35 loc) · 1.13 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
<?php
namespace TheCodingMachine\Safe\PHPStan\Rules;
use PHPStan\Rules\Rule;
use PHPStan\Testing\RuleTestCase;
/**
* @template-extends RuleTestCase<UseSafeCallablesRule>
*/
class UseSafeCallablesRuleTest extends RuleTestCase
{
protected function getRule(): Rule
{
return new UseSafeCallablesRule();
}
public function testUnsafe(): void
{
$this->analyse([__DIR__ . '/UseSafeCallablesRule/unsafe.php'], [
[
"Function json_encode is unsafe to use. It can return FALSE instead of throwing an exception. Please add 'use function Safe\\json_encode;' at the beginning of the file to use the variant provided by the 'thecodingmachine/safe' library.",
3,
],
]);
}
public function testUseSafe(): void
{
$this->analyse([__DIR__ . '/UseSafeCallablesRule/use_safe.php'], []);
}
public function testNativeSafe(): void
{
$this->analyse([__DIR__ . '/UseSafeCallablesRule/native_safe.php'], []);
}
public function testExpr(): void
{
$this->analyse([__DIR__ . '/UseSafeCallablesRule/expr.php'], []);
}
}