-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathUseSafeClassesRuleTest.php
More file actions
31 lines (27 loc) · 1.04 KB
/
UseSafeClassesRuleTest.php
File metadata and controls
31 lines (27 loc) · 1.04 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
<?php
namespace TheCodingMachine\Safe\PHPStan\Rules;
use PHPStan\Rules\Rule;
use PHPStan\Testing\RuleTestCase;
/**
* @template-extends RuleTestCase<UseSafeClassesRule>
*/
class UseSafeClassesRuleTest extends RuleTestCase
{
protected function getRule(): Rule
{
return new UseSafeClassesRule();
}
public function testDateTime(): void
{
$this->analyse([__DIR__ . '/UseSafeClassesRule/datetime.php'], [
[
"Class DateTime is unsafe to use. Its methods can return FALSE instead of throwing an exception. Please add 'use Safe\DateTime;' at the beginning of the file to use the variant provided by the 'thecodingmachine/safe' library.",
3,
],
[
"Class DateTimeImmutable is unsafe to use. Its methods can return FALSE instead of throwing an exception. Please add 'use Safe\DateTimeImmutable;' at the beginning of the file to use the variant provided by the 'thecodingmachine/safe' library.",
4,
],
]);
}
}