-
Notifications
You must be signed in to change notification settings - Fork 568
Expand file tree
/
Copy pathInterpolatedStringRuleTest.php
More file actions
55 lines (48 loc) · 1.3 KB
/
InterpolatedStringRuleTest.php
File metadata and controls
55 lines (48 loc) · 1.3 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
<?php declare(strict_types = 1);
namespace PHPStan\Rules\String;
use PHPStan\Php\PhpVersion;
use PHPStan\Rules\Rule as TRule;
use PHPStan\Testing\RuleTestCase;
use PHPUnit\Framework\Attributes\RequiresPhp;
use const PHP_VERSION_ID;
/**
* @extends RuleTestCase<InterpolatedStringRule>
*/
class InterpolatedStringRuleTest extends RuleTestCase
{
protected function getRule(): TRule
{
return new InterpolatedStringRule(new PhpVersion(PHP_VERSION_ID));
}
#[RequiresPhp('>= 8.2')]
public function testRule(): void
{
$this->analyse([__DIR__ . '/data/interpolated-string.php'], [
[
'Using ${var} in strings is deprecated in PHP 8.2. Use {$var} instead.',
17,
],
[
'Using ${expr} (variable variables) in strings is deprecated in PHP 8.2. Use {${expr}} instead.',
18,
],
[
'Using ${expr} (variable variables) in strings is deprecated in PHP 8.2. Use {${expr}} instead.',
19,
],
[
'Using ${var} in strings is deprecated in PHP 8.2. Use {$var} instead.',
20,
],
[
'Using ${expr} (variable variables) in strings is deprecated in PHP 8.2. Use {${expr}} instead.',
23,
],
]);
}
#[RequiresPhp('>= 8.2')]
public function testFix(): void
{
$this->fix(__DIR__ . '/data/interpolated-string.php', __DIR__ . '/data/interpolated-string.php.fixed');
}
}