1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Deprecated Mbstring regex replace e modifier sniff test file. |
4
|
|
|
* |
5
|
|
|
* @package PHPCompatibility |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Deprecated Mbstring regex replace e modifier test file. |
11
|
|
|
* |
12
|
|
|
* @uses BaseSniffTest |
13
|
|
|
* @package PHPCompatibility |
14
|
|
|
* @author Juliette Reinders Folmer <[email protected]> |
15
|
|
|
*/ |
16
|
|
|
class MbstringReplaceEModifierSniffTest extends BaseSniffTest |
|
|
|
|
17
|
|
|
{ |
18
|
|
|
const TEST_FILE = 'sniff-examples/mbstring_replace_e_modifier.php'; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* testMbstringEModifier |
22
|
|
|
* |
23
|
|
|
* @group mbstringEModifier |
24
|
|
|
* |
25
|
|
|
* @dataProvider dataMbstringEModifier |
26
|
|
|
* |
27
|
|
|
* @param int $line The line number. |
28
|
|
|
* |
29
|
|
|
* @return void |
30
|
|
|
*/ |
31
|
|
|
public function testMbstringEModifier($line) |
32
|
|
|
{ |
33
|
|
|
$file = $this->sniffFile(self::TEST_FILE, '5.4'); |
34
|
|
|
$this->assertNoViolation($file, $line); |
35
|
|
|
|
36
|
|
|
$file = $this->sniffFile(self::TEST_FILE, '5.3-7.1'); |
37
|
|
|
$this->assertError($file, $line, 'The Mbstring regex "e" modifier is deprecated since PHP 7.1.'); |
38
|
|
|
|
39
|
|
|
$file = $this->sniffFile(self::TEST_FILE, '7.1'); |
40
|
|
|
$this->assertError($file, $line, 'The Mbstring regex "e" modifier is deprecated since PHP 7.1. Use mb_ereg_replace_callback() instead (PHP 5.4.1+).'); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Data provider. |
45
|
|
|
* |
46
|
|
|
* @see testMbstringEModifier() |
47
|
|
|
* |
48
|
|
|
* @return array |
49
|
|
|
*/ |
50
|
|
|
public function dataMbstringEModifier() |
51
|
|
|
{ |
52
|
|
|
return array( |
53
|
|
|
array(14), |
54
|
|
|
array(15), |
55
|
|
|
array(16), |
56
|
|
|
); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* testNoViolation |
62
|
|
|
* |
63
|
|
|
* @group mbstringEModifier |
64
|
|
|
* |
65
|
|
|
* @dataProvider dataNoViolation |
66
|
|
|
* |
67
|
|
|
* @param int $line The line number. |
68
|
|
|
* |
69
|
|
|
* @return void |
70
|
|
|
*/ |
71
|
|
|
public function testNoViolation($line) |
72
|
|
|
{ |
73
|
|
|
$file = $this->sniffFile(self::TEST_FILE, '7.1'); |
74
|
|
|
$this->assertNoViolation($file, $line); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Data provider. |
79
|
|
|
* |
80
|
|
|
* @see testNoViolation() |
81
|
|
|
* |
82
|
|
|
* @return array |
83
|
|
|
*/ |
84
|
|
View Code Duplication |
public function dataNoViolation() |
|
|
|
|
85
|
|
|
{ |
86
|
|
|
return array( |
87
|
|
|
array(4), |
88
|
|
|
array(5), |
89
|
|
|
array(6), |
90
|
|
|
array(9), |
91
|
|
|
array(10), |
92
|
|
|
array(11), |
93
|
|
|
); |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.