|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* New Functions Parameter Sniff test file |
|
4
|
|
|
* |
|
5
|
|
|
* @package PHPCompatibility |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* New Functions Parameter Sniff tests |
|
11
|
|
|
* |
|
12
|
|
|
* @uses BaseSniffTest |
|
13
|
|
|
* @package PHPCompatibility |
|
14
|
|
|
* @author Wim Godden <[email protected]> |
|
15
|
|
|
*/ |
|
16
|
|
|
class NewFunctionParameterSniffTest extends BaseSniffTest |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* Test dirname() depth parameter |
|
20
|
|
|
* |
|
21
|
|
|
* @return void |
|
22
|
|
|
*/ |
|
23
|
|
|
public function testDirnameDepth() |
|
24
|
|
|
{ |
|
25
|
|
|
$file = $this->sniffFile('sniff-examples/new_function_parameter.php', '5.6'); |
|
26
|
|
|
$this->assertError($file, 3, "The function dirname does not have a parameter depth in PHP version 5.6 or earlier"); |
|
27
|
|
|
$this->assertNoViolation($file, 5); |
|
28
|
|
|
$this->assertNoViolation($file, 7); |
|
29
|
|
|
$this->assertError($file, 9, "The function dirname does not have a parameter depth in PHP version 5.6 or earlier"); |
|
30
|
|
|
|
|
31
|
|
|
$file = $this->sniffFile('sniff-examples/new_function_parameter.php', '7.0'); |
|
32
|
|
|
$this->assertNoViolation($file, 3); |
|
33
|
|
|
$this->assertNoViolation($file, 5); |
|
34
|
|
|
$this->assertNoViolation($file, 7); |
|
35
|
|
|
$this->assertNoViolation($file, 9); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Test unserialize() options parameter |
|
40
|
|
|
* |
|
41
|
|
|
* @return void |
|
42
|
|
|
*/ |
|
43
|
|
|
public function testUnserializeOptions() |
|
44
|
|
|
{ |
|
45
|
|
|
$file = $this->sniffFile('sniff-examples/new_function_parameter.php', '5.6'); |
|
46
|
|
|
$this->assertError($file, 11, "The function unserialize does not have a parameter options in PHP version 5.6 or earlier"); |
|
47
|
|
|
|
|
48
|
|
|
$file = $this->sniffFile('sniff-examples/new_function_parameter.php', '7.0'); |
|
49
|
|
|
$this->assertNoViolation($file, 11); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Test session_start() options parameter |
|
54
|
|
|
* |
|
55
|
|
|
* @return void |
|
56
|
|
|
*/ |
|
57
|
|
|
public function testSessionStartOptions() |
|
58
|
|
|
{ |
|
59
|
|
|
$file = $this->sniffFile('sniff-examples/new_function_parameter.php', '5.6'); |
|
60
|
|
|
$this->assertError($file, 13, "The function session_start does not have a parameter options in PHP version 5.6 or earlier"); |
|
61
|
|
|
|
|
62
|
|
|
$file = $this->sniffFile('sniff-examples/new_function_parameter.php', '7.0'); |
|
63
|
|
|
$this->assertNoViolation($file, 13); |
|
64
|
|
|
|
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Test strstr() before_needle parameter |
|
69
|
|
|
* |
|
70
|
|
|
* @return void |
|
71
|
|
|
*/ |
|
72
|
|
|
public function testStrstrBeforeNeedleOptions() |
|
73
|
|
|
{ |
|
74
|
|
|
$file = $this->sniffFile('sniff-examples/new_function_parameter.php', '5.2'); |
|
75
|
|
|
$this->assertError($file, 15, "The function strstr does not have a parameter before_needle in PHP version 5.2 or earlier"); |
|
76
|
|
|
|
|
77
|
|
|
$file = $this->sniffFile('sniff-examples/new_function_parameter.php', '5.3'); |
|
78
|
|
|
$this->assertNoViolation($file, 15); |
|
79
|
|
|
|
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
} |
|
83
|
|
|
|