1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Deprecated ini directives sniff test file |
4
|
|
|
* |
5
|
|
|
* @package PHPCompatibility |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Deprecated ini directives sniff tests |
11
|
|
|
* |
12
|
|
|
* @uses BaseSniffTest |
13
|
|
|
* @package PHPCompatibility |
14
|
|
|
* @author Jansen Price <[email protected]> |
15
|
|
|
*/ |
16
|
|
|
class DeprecatedIniDirectivesSniffTest extends BaseSniffTest |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* Test define_syslog_variables |
20
|
|
|
* |
21
|
|
|
* @return void |
22
|
|
|
*/ |
23
|
|
|
public function testDefineSyslogVariables() |
24
|
|
|
{ |
25
|
|
|
$file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php'); |
26
|
|
|
|
27
|
|
|
$this->assertWarning($file, 3, "INI directive 'define_syslog_variables' is deprecated from PHP 5.3 and forbidden from PHP 5.4"); |
28
|
|
|
$this->assertWarning($file, 4, "INI directive 'define_syslog_variables' is deprecated from PHP 5.3 and forbidden from PHP 5.4"); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Test register_globals |
33
|
|
|
* |
34
|
|
|
* @return void |
35
|
|
|
*/ |
36
|
|
|
public function testRegisterGlobals() |
37
|
|
|
{ |
38
|
|
|
$file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php'); |
39
|
|
|
|
40
|
|
|
$this->assertWarning($file, 6, "INI directive 'register_globals' is deprecated from PHP 5.3 and forbidden from PHP 5.4"); |
41
|
|
|
$this->assertWarning($file, 7, "INI directive 'register_globals' is deprecated from PHP 5.3 and forbidden from PHP 5.4"); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Test register_long_arrays |
46
|
|
|
* |
47
|
|
|
* @return void |
48
|
|
|
*/ |
49
|
|
|
public function testRegisterLongArrays() |
50
|
|
|
{ |
51
|
|
|
$file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php'); |
52
|
|
|
|
53
|
|
|
$this->assertWarning($file, 9, "INI directive 'register_long_arrays' is deprecated from PHP 5.3 and forbidden from PHP 5.4"); |
54
|
|
|
$this->assertWarning($file, 10, "INI directive 'register_long_arrays' is deprecated from PHP 5.3 and forbidden from PHP 5.4"); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Test magic_quotes_gpc |
59
|
|
|
* |
60
|
|
|
* @return void |
61
|
|
|
*/ |
62
|
|
|
public function testMagicQuotesGpc() |
63
|
|
|
{ |
64
|
|
|
$file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php'); |
65
|
|
|
|
66
|
|
|
$this->assertWarning($file, 12, "INI directive 'magic_quotes_gpc' is deprecated from PHP 5.3 and forbidden from PHP 5.4"); |
67
|
|
|
$this->assertWarning($file, 13, "INI directive 'magic_quotes_gpc' is deprecated from PHP 5.3 and forbidden from PHP 5.4"); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Test magic_quotes_runtime |
72
|
|
|
* |
73
|
|
|
* @return void |
74
|
|
|
*/ |
75
|
|
|
public function testMagicQuotesRuntime() |
76
|
|
|
{ |
77
|
|
|
$file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php'); |
78
|
|
|
|
79
|
|
|
$this->assertWarning($file, 15, "INI directive 'magic_quotes_runtime' is deprecated from PHP 5.3 and forbidden from PHP 5.4"); |
80
|
|
|
$this->assertWarning($file, 16, "INI directive 'magic_quotes_runtime' is deprecated from PHP 5.3 and forbidden from PHP 5.4"); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* Test magic_quotes_sybase |
85
|
|
|
* |
86
|
|
|
* @return void |
87
|
|
|
*/ |
88
|
|
|
public function testMagicQuotesSybase() |
89
|
|
|
{ |
90
|
|
|
$file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php'); |
91
|
|
|
|
92
|
|
|
$this->assertWarning($file, 18, "INI directive 'magic_quotes_sybase' is deprecated from PHP 5.3 and forbidden from PHP 5.4"); |
93
|
|
|
$this->assertWarning($file, 19, "INI directive 'magic_quotes_sybase' is deprecated from PHP 5.3 and forbidden from PHP 5.4"); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Test allow_call_time_pass_reference |
98
|
|
|
* |
99
|
|
|
* @return void |
100
|
|
|
*/ |
101
|
|
|
public function testAllowCallTimePassReference() |
102
|
|
|
{ |
103
|
|
|
$file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php'); |
104
|
|
|
|
105
|
|
|
$this->assertWarning($file, 21, "INI directive 'allow_call_time_pass_reference' is deprecated from PHP 5.3 and forbidden from PHP 5.4"); |
106
|
|
|
$this->assertWarning($file, 22, "INI directive 'allow_call_time_pass_reference' is deprecated from PHP 5.3 and forbidden from PHP 5.4"); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* Test highlight.bg |
111
|
|
|
* |
112
|
|
|
* @return void |
113
|
|
|
*/ |
114
|
|
|
public function testHighlightBg() |
115
|
|
|
{ |
116
|
|
|
$file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php'); |
117
|
|
|
|
118
|
|
|
$this->assertWarning($file, 24, "INI directive 'highlight.bg' is deprecated from PHP 5.3 and forbidden from PHP 5.4"); |
119
|
|
|
$this->assertWarning($file, 25, "INI directive 'highlight.bg' is deprecated from PHP 5.3 and forbidden from PHP 5.4"); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* Test session.bug_compat_42 |
124
|
|
|
* |
125
|
|
|
* @return void |
126
|
|
|
*/ |
127
|
|
|
public function testSessionBugCompat42() |
128
|
|
|
{ |
129
|
|
|
$file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php'); |
130
|
|
|
|
131
|
|
|
$this->assertWarning($file, 27, "INI directive 'session.bug_compat_42' is deprecated from PHP 5.3 and forbidden from PHP 5.4"); |
132
|
|
|
$this->assertWarning($file, 28, "INI directive 'session.bug_compat_42' is deprecated from PHP 5.3 and forbidden from PHP 5.4"); |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* Test session.bug_compat_warn |
137
|
|
|
* |
138
|
|
|
* @return void |
139
|
|
|
*/ |
140
|
|
|
public function testSessionBugCompatWarn() |
141
|
|
|
{ |
142
|
|
|
$file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php'); |
143
|
|
|
|
144
|
|
|
$this->assertWarning($file, 30, "INI directive 'session.bug_compat_warn' is deprecated from PHP 5.3 and forbidden from PHP 5.4"); |
145
|
|
|
$this->assertWarning($file, 31, "INI directive 'session.bug_compat_warn' is deprecated from PHP 5.3 and forbidden from PHP 5.4"); |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* Test y2k_compliance |
150
|
|
|
* |
151
|
|
|
* @return void |
152
|
|
|
*/ |
153
|
|
|
public function testY2kCompliance() |
154
|
|
|
{ |
155
|
|
|
$file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php'); |
156
|
|
|
|
157
|
|
|
$this->assertWarning($file, 33, "INI directive 'y2k_compliance' is deprecated from PHP 5.3 and forbidden from PHP 5.4"); |
158
|
|
|
$this->assertWarning($file, 34, "INI directive 'y2k_compliance' is deprecated from PHP 5.3 and forbidden from PHP 5.4"); |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* Test zend.ze1_compatibility_mode |
163
|
|
|
* |
164
|
|
|
* @return void |
165
|
|
|
*/ |
166
|
|
|
public function testZendZe1CompatibilityMode() |
167
|
|
|
{ |
168
|
|
|
$file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php'); |
169
|
|
|
|
170
|
|
|
$this->assertWarning($file, 36, "INI directive 'zend.ze1_compatibility_mode' is deprecated from PHP 5.3 and forbidden from PHP 5.4"); |
171
|
|
|
$this->assertWarning($file, 37, "INI directive 'zend.ze1_compatibility_mode' is deprecated from PHP 5.3 and forbidden from PHP 5.4"); |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* Test safe_mode |
176
|
|
|
* |
177
|
|
|
* @return void |
178
|
|
|
*/ |
179
|
|
|
public function testSafeMode() |
180
|
|
|
{ |
181
|
|
|
$file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php'); |
182
|
|
|
|
183
|
|
|
$this->assertWarning($file, 39, "INI directive 'safe_mode' is deprecated from PHP 5.3 and forbidden from PHP 5.4"); |
184
|
|
|
$this->assertWarning($file, 40, "INI directive 'safe_mode' is deprecated from PHP 5.3 and forbidden from PHP 5.4"); |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
/** |
188
|
|
|
* Test safe_mode_gid |
189
|
|
|
* |
190
|
|
|
* @return void |
191
|
|
|
*/ |
192
|
|
|
public function testSafeModeGid() |
193
|
|
|
{ |
194
|
|
|
$file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php'); |
195
|
|
|
|
196
|
|
|
$this->assertWarning($file, 42, "INI directive 'safe_mode_gid' is deprecated from PHP 5.3 and forbidden from PHP 5.4"); |
197
|
|
|
$this->assertWarning($file, 43, "INI directive 'safe_mode_gid' is deprecated from PHP 5.3 and forbidden from PHP 5.4"); |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
/** |
201
|
|
|
* Test safe_mode_include_dir |
202
|
|
|
* |
203
|
|
|
* @return void |
204
|
|
|
*/ |
205
|
|
|
public function testSafeModeIncludeDir() |
206
|
|
|
{ |
207
|
|
|
$file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php'); |
208
|
|
|
|
209
|
|
|
$this->assertWarning($file, 45, "INI directive 'safe_mode_include_dir' is deprecated from PHP 5.3 and forbidden from PHP 5.4"); |
210
|
|
|
$this->assertWarning($file, 46, "INI directive 'safe_mode_include_dir' is deprecated from PHP 5.3 and forbidden from PHP 5.4"); |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
/** |
214
|
|
|
* Test safe_mode_exec_dir |
215
|
|
|
* |
216
|
|
|
* @return void |
217
|
|
|
*/ |
218
|
|
|
public function testSafeModeExecDir() |
219
|
|
|
{ |
220
|
|
|
$file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php'); |
221
|
|
|
|
222
|
|
|
$this->assertWarning($file, 48, "INI directive 'safe_mode_exec_dir' is deprecated from PHP 5.3 and forbidden from PHP 5.4"); |
223
|
|
|
$this->assertWarning($file, 49, "INI directive 'safe_mode_exec_dir' is deprecated from PHP 5.3 and forbidden from PHP 5.4"); |
224
|
|
|
} |
225
|
|
|
|
226
|
|
|
/** |
227
|
|
|
* Test safe_mode_allowed_env_vars |
228
|
|
|
* |
229
|
|
|
* @return void |
230
|
|
|
*/ |
231
|
|
|
public function testSafeModeAllowedEnvVars() |
232
|
|
|
{ |
233
|
|
|
$file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php'); |
234
|
|
|
|
235
|
|
|
$this->assertWarning($file, 51, "INI directive 'safe_mode_allowed_env_vars' is deprecated from PHP 5.3 and forbidden from PHP 5.4"); |
236
|
|
|
$this->assertWarning($file, 52, "INI directive 'safe_mode_allowed_env_vars' is deprecated from PHP 5.3 and forbidden from PHP 5.4"); |
237
|
|
|
} |
238
|
|
|
|
239
|
|
|
/** |
240
|
|
|
* Test safe_mode_protected_env_vars |
241
|
|
|
* |
242
|
|
|
* @return void |
243
|
|
|
*/ |
244
|
|
|
public function testSafeModeProtectedEnvVars() |
245
|
|
|
{ |
246
|
|
|
$file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php'); |
247
|
|
|
|
248
|
|
|
$this->assertWarning($file, 54, "INI directive 'safe_mode_protected_env_vars' is deprecated from PHP 5.3 and forbidden from PHP 5.4"); |
249
|
|
|
$this->assertWarning($file, 55, "INI directive 'safe_mode_protected_env_vars' is deprecated from PHP 5.3 and forbidden from PHP 5.4"); |
250
|
|
|
} |
251
|
|
|
|
252
|
|
|
/** |
253
|
|
|
* Test valid directive |
254
|
|
|
* |
255
|
|
|
* @return void |
256
|
|
|
*/ |
257
|
|
|
public function testValidDirective() |
258
|
|
|
{ |
259
|
|
|
$file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php'); |
260
|
|
|
|
261
|
|
|
$this->assertNoViolation($file, 57); |
262
|
|
|
$this->assertNoViolation($file, 58); |
263
|
|
|
} |
264
|
|
|
|
265
|
|
|
/** |
266
|
|
|
* Test iconv.input_encoding setting |
267
|
|
|
* |
268
|
|
|
* @return void |
269
|
|
|
*/ |
270
|
|
|
public function testIconvInputEncoding() |
271
|
|
|
{ |
272
|
|
|
$file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php'); |
273
|
|
|
|
274
|
|
|
$this->assertWarning($file, 62, "INI directive 'iconv.input_encoding' is deprecated from PHP 5.6"); |
275
|
|
|
$this->assertWarning($file, 63, "INI directive 'iconv.input_encoding' is deprecated from PHP 5.6"); |
276
|
|
|
} |
277
|
|
|
|
278
|
|
|
/** |
279
|
|
|
* Test iconv.output_encoding setting |
280
|
|
|
* |
281
|
|
|
* @return void |
282
|
|
|
*/ |
283
|
|
|
public function testIconvOutputEncoding() |
284
|
|
|
{ |
285
|
|
|
$file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php'); |
286
|
|
|
|
287
|
|
|
$this->assertWarning($file, 65, "INI directive 'iconv.output_encoding' is deprecated from PHP 5.6"); |
288
|
|
|
$this->assertWarning($file, 66, "INI directive 'iconv.output_encoding' is deprecated from PHP 5.6"); |
289
|
|
|
} |
290
|
|
|
|
291
|
|
|
/** |
292
|
|
|
* Test iconv.internal_encoding setting |
293
|
|
|
* |
294
|
|
|
* @return void |
295
|
|
|
*/ |
296
|
|
|
public function testIconvInternalEncoding() |
297
|
|
|
{ |
298
|
|
|
$file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php'); |
299
|
|
|
|
300
|
|
|
$this->assertWarning($file, 68, "INI directive 'iconv.internal_encoding' is deprecated from PHP 5.6"); |
301
|
|
|
$this->assertWarning($file, 69, "INI directive 'iconv.internal_encoding' is deprecated from PHP 5.6"); |
302
|
|
|
} |
303
|
|
|
|
304
|
|
|
|
305
|
|
|
/** |
306
|
|
|
* Test mbstring.http_input setting |
307
|
|
|
* |
308
|
|
|
* @return void |
309
|
|
|
*/ |
310
|
|
|
public function testMbstringHttpInput() |
311
|
|
|
{ |
312
|
|
|
$file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php'); |
313
|
|
|
|
314
|
|
|
$this->assertWarning($file, 71, "INI directive 'mbstring.http_input' is deprecated from PHP 5.6"); |
315
|
|
|
$this->assertWarning($file, 72, "INI directive 'mbstring.http_input' is deprecated from PHP 5.6"); |
316
|
|
|
} |
317
|
|
|
|
318
|
|
|
/** |
319
|
|
|
* Test mbstring.http_output setting |
320
|
|
|
* |
321
|
|
|
* @return void |
322
|
|
|
*/ |
323
|
|
|
public function testMbstringHttpOutput() |
324
|
|
|
{ |
325
|
|
|
$file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php'); |
326
|
|
|
|
327
|
|
|
$this->assertWarning($file, 74, "INI directive 'mbstring.http_output' is deprecated from PHP 5.6"); |
328
|
|
|
$this->assertWarning($file, 75, "INI directive 'mbstring.http_output' is deprecated from PHP 5.6"); |
329
|
|
|
} |
330
|
|
|
|
331
|
|
|
/** |
332
|
|
|
* Test mbstring.internal_encoding setting |
333
|
|
|
* |
334
|
|
|
* @return void |
335
|
|
|
*/ |
336
|
|
|
public function testMbstringInternalEncoding() |
337
|
|
|
{ |
338
|
|
|
$file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php'); |
339
|
|
|
|
340
|
|
|
$this->assertWarning($file, 77, "INI directive 'mbstring.internal_encoding' is deprecated from PHP 5.6"); |
341
|
|
|
$this->assertWarning($file, 78, "INI directive 'mbstring.internal_encoding' is deprecated from PHP 5.6"); |
342
|
|
|
} |
343
|
|
|
|
344
|
|
|
/** |
345
|
|
|
* Test always_populate_raw_post_data setting |
346
|
|
|
* |
347
|
|
|
* @return void |
348
|
|
|
*/ |
349
|
|
View Code Duplication |
public function testAlwaysPopulateRawPostData() |
|
|
|
|
350
|
|
|
{ |
351
|
|
|
$file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.5'); |
352
|
|
|
$this->assertNoViolation($file, 80); |
353
|
|
|
$this->assertNoViolation($file, 81); |
354
|
|
|
|
355
|
|
|
$file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.6'); |
356
|
|
|
$this->assertWarning($file, 80, "INI directive 'always_populate_raw_post_data' is deprecated from PHP 5.6"); |
357
|
|
|
$this->assertWarning($file, 81, "INI directive 'always_populate_raw_post_data' is deprecated from PHP 5.6"); |
358
|
|
|
|
359
|
|
|
$file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '7.0'); |
360
|
|
|
$this->assertError($file, 80, "INI directive 'always_populate_raw_post_data' is deprecated from PHP 5.6 and forbidden from PHP 7.0"); |
361
|
|
|
$this->assertError($file, 81, "INI directive 'always_populate_raw_post_data' is deprecated from PHP 5.6 and forbidden from PHP 7.0"); |
362
|
|
|
} |
363
|
|
|
|
364
|
|
|
/** |
365
|
|
|
* Test asp_tags setting |
366
|
|
|
* |
367
|
|
|
* @return void |
368
|
|
|
*/ |
369
|
|
|
public function testAsptags() |
370
|
|
|
{ |
371
|
|
|
$file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.6'); |
372
|
|
|
$this->assertNoViolation($file, 83); |
373
|
|
|
$this->assertNoViolation($file, 84); |
374
|
|
|
|
375
|
|
|
$file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '7.0'); |
376
|
|
|
$this->assertError($file, 83, "INI directive 'asp_tags' is deprecated from PHP 5.6 and forbidden from PHP 7.0"); |
377
|
|
|
$this->assertError($file, 84, "INI directive 'asp_tags' is deprecated from PHP 5.6 and forbidden from PHP 7.0"); |
378
|
|
|
} |
379
|
|
|
|
380
|
|
|
/** |
381
|
|
|
* Test xsl.security_prefs setting |
382
|
|
|
* |
383
|
|
|
* @return void |
384
|
|
|
*/ |
385
|
|
|
public function testXslSecurityPrefs() |
386
|
|
|
{ |
387
|
|
|
$file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.6'); |
388
|
|
|
$this->assertNoViolation($file, 86); |
389
|
|
|
$this->assertNoViolation($file, 87); |
390
|
|
|
|
391
|
|
|
$file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '7.0'); |
392
|
|
|
$this->assertError($file, 86, "INI directive 'xsl.security_prefs' is deprecated from PHP 5.6 and forbidden from PHP 7.0"); |
393
|
|
|
$this->assertError($file, 87, "INI directive 'xsl.security_prefs' is deprecated from PHP 5.6 and forbidden from PHP 7.0"); |
394
|
|
|
} |
395
|
|
|
|
396
|
|
|
|
397
|
|
|
public function testSettingTestVersion() |
398
|
|
|
{ |
399
|
|
|
$file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.3'); |
400
|
|
|
|
401
|
|
|
$this->assertWarning($file, 54, "INI directive 'safe_mode_protected_env_vars' is deprecated from PHP 5.3"); |
402
|
|
|
} |
403
|
|
|
} |
404
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.