Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like DeprecatedFunctionsSniffTest often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use DeprecatedFunctionsSniffTest, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
16 | class DeprecatedFunctionsSniffTest extends BaseSniffTest |
||
17 | { |
||
18 | /** |
||
19 | * Test call user method |
||
20 | * |
||
21 | * @return void |
||
22 | */ |
||
23 | View Code Duplication | public function testCallUserMethod() |
|
|
|||
24 | { |
||
25 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php', '5.6'); |
||
26 | $this->assertWarning($file, 3, 'The use of function call_user_method is discouraged from PHP version 5.3; use call_user_func instead'); |
||
27 | |||
28 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php', '7.0'); |
||
29 | $this->assertError($file, 3, 'The use of function call_user_method is discouraged from PHP version 5.3 and forbidden from PHP version 7.0; use call_user_func instead'); |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * Test call user method array |
||
34 | * |
||
35 | * @return void |
||
36 | */ |
||
37 | View Code Duplication | public function testCallUserMethodArray() |
|
38 | { |
||
39 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php', '5.6'); |
||
40 | $this->assertWarning($file, 4, 'The use of function call_user_method_array is discouraged from PHP version 5.3; use call_user_func_array instead'); |
||
41 | |||
42 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php', '7.0'); |
||
43 | $this->assertError($file, 4, 'The use of function call_user_method_array is discouraged from PHP version 5.3 and forbidden from PHP version 7.0; use call_user_func_array instead'); |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * Test define syslog variables |
||
48 | * |
||
49 | * @return void |
||
50 | */ |
||
51 | public function testDefineSyslogVariables() |
||
52 | { |
||
53 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php'); |
||
54 | $this->assertError($file, 5, 'The use of'); |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * Test dl |
||
59 | * |
||
60 | * @return void |
||
61 | */ |
||
62 | public function testDl() |
||
63 | { |
||
64 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php'); |
||
65 | |||
66 | $this->assertWarning($file, 6, 'The use of function dl is discouraged from PHP version 5.3'); |
||
67 | } |
||
68 | |||
69 | /** |
||
70 | * Test ereg |
||
71 | * |
||
72 | * @return void |
||
73 | */ |
||
74 | public function testEreg() |
||
75 | { |
||
76 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php'); |
||
77 | |||
78 | $this->assertWarning($file, 7, 'The use of function ereg is discouraged from PHP version 5.3'); |
||
79 | } |
||
80 | |||
81 | /** |
||
82 | * Test ereg_replace |
||
83 | * |
||
84 | * @return void |
||
85 | */ |
||
86 | public function testEregReplace() |
||
87 | { |
||
88 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php'); |
||
89 | |||
90 | $this->assertWarning($file, 8, 'The use of function ereg_replace is discouraged from PHP version 5.3'); |
||
91 | } |
||
92 | |||
93 | /** |
||
94 | * Test eregi |
||
95 | * |
||
96 | * @return void |
||
97 | */ |
||
98 | public function testEregi() |
||
99 | { |
||
100 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php'); |
||
101 | |||
102 | $this->assertWarning($file, 9, 'The use of function eregi is discouraged from PHP version 5.3'); |
||
103 | } |
||
104 | |||
105 | /** |
||
106 | * Test eregi_replace |
||
107 | * |
||
108 | * @return void |
||
109 | */ |
||
110 | public function testEregiReplace() |
||
111 | { |
||
112 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php'); |
||
113 | |||
114 | $this->assertWarning($file, 10, 'The use of function eregi_replace is discouraged from PHP version 5.3'); |
||
115 | } |
||
116 | |||
117 | /** |
||
118 | * Test import_request_variables |
||
119 | * |
||
120 | * @return void |
||
121 | */ |
||
122 | public function testImportRequestVariables() |
||
123 | { |
||
124 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php'); |
||
125 | |||
126 | $this->assertError($file, 11, 'The use of function import_request_variables is forbidden from PHP version 5.4'); |
||
127 | } |
||
128 | |||
129 | /** |
||
130 | * Test mcrypt_generic_end |
||
131 | * |
||
132 | * @return void |
||
133 | */ |
||
134 | View Code Duplication | public function testMcryptGenericEnd() |
|
135 | { |
||
136 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php', '5.6'); |
||
137 | $this->assertWarning($file, 12, 'The use of function mcrypt_generic_end is discouraged from PHP version 5.4; use mcrypt_generic_deinit instead'); |
||
138 | |||
139 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php', '7.0'); |
||
140 | $this->assertError($file, 12, 'The use of function mcrypt_generic_end is discouraged from PHP version 5.4 and forbidden from PHP version 7.0; use mcrypt_generic_deinit instead'); |
||
141 | } |
||
142 | |||
143 | /** |
||
144 | * Test mysql_db_query |
||
145 | * |
||
146 | * @return void |
||
147 | */ |
||
148 | public function testMysqlDbQuery() |
||
149 | { |
||
150 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php'); |
||
151 | |||
152 | $this->assertWarning($file, 13, 'The use of function mysql_db_query is discouraged from PHP version 5.3; use mysql_select_db and mysql_query instead'); |
||
153 | } |
||
154 | |||
155 | /** |
||
156 | * Test mysql_escape_string |
||
157 | * |
||
158 | * @return void |
||
159 | */ |
||
160 | public function testMysqlEscapeString() |
||
161 | { |
||
162 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php'); |
||
163 | |||
164 | $this->assertWarning($file, 14, 'The use of function mysql_escape_string is discouraged from PHP version 5.3; use mysql_real_escape_string instead'); |
||
165 | } |
||
166 | |||
167 | /** |
||
168 | * Test mysql_list_dbs |
||
169 | * |
||
170 | * @return void |
||
171 | */ |
||
172 | public function testMysqlListDbs() |
||
173 | { |
||
174 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php'); |
||
175 | |||
176 | $this->assertWarning($file, 15, 'The use of function mysql_list_dbs is discouraged from PHP version 5.4'); |
||
177 | } |
||
178 | |||
179 | /** |
||
180 | * Test mysqli_bind_param |
||
181 | * |
||
182 | * @return void |
||
183 | */ |
||
184 | public function testMysqliBindParam() |
||
185 | { |
||
186 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php'); |
||
187 | |||
188 | $this->assertError($file, 16, 'The use of function mysqli_bind_param is forbidden from PHP version 5.4; use mysqli_stmt_bind_param instead'); |
||
189 | } |
||
190 | |||
191 | /** |
||
192 | * Test mysqli_bind_result |
||
193 | * |
||
194 | * @return void |
||
195 | */ |
||
196 | public function testMysqliBindResult() |
||
197 | { |
||
198 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php'); |
||
199 | |||
200 | $this->assertError($file, 17, 'The use of function mysqli_bind_result is forbidden from PHP version 5.4; use mysqli_stmt_bind_result instead'); |
||
201 | } |
||
202 | |||
203 | /** |
||
204 | * Test mysqli_client_encoding |
||
205 | * |
||
206 | * @return void |
||
207 | */ |
||
208 | public function testMysqliClientEncoding() |
||
209 | { |
||
210 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php'); |
||
211 | |||
212 | $this->assertError($file, 18, 'The use of function mysqli_client_encoding is forbidden from PHP version 5.4; use mysqli_character_set_name instead'); |
||
213 | } |
||
214 | |||
215 | /** |
||
216 | * Test mysqli_fetch |
||
217 | * |
||
218 | * @return void |
||
219 | */ |
||
220 | public function testMysqliFetch() |
||
221 | { |
||
222 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php'); |
||
223 | |||
224 | $this->assertError($file, 19, 'The use of function mysqli_fetch is forbidden from PHP version 5.4; use mysqli_stmt_fetch instead'); |
||
225 | } |
||
226 | |||
227 | /** |
||
228 | * Test mysqli_param_count |
||
229 | * |
||
230 | * @return void |
||
231 | */ |
||
232 | public function testMysqliParamCount() |
||
233 | { |
||
234 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php'); |
||
235 | |||
236 | $this->assertError($file, 20, 'The use of function mysqli_param_count is forbidden from PHP version 5.4; use mysqli_stmt_param_count instead'); |
||
237 | } |
||
238 | |||
239 | /** |
||
240 | * Test mysqli_get_metadata |
||
241 | * |
||
242 | * @return void |
||
243 | */ |
||
244 | public function testMysqliGetMetadata() |
||
245 | { |
||
246 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php'); |
||
247 | |||
248 | $this->assertError($file, 21, 'The use of function mysqli_get_metadata is forbidden from PHP version 5.4; use mysqli_stmt_result_metadata instead'); |
||
249 | } |
||
250 | |||
251 | /** |
||
252 | * Test mysqli_send_long_data |
||
253 | * |
||
254 | * @return void |
||
255 | */ |
||
256 | public function testMysqliSendLongData() |
||
257 | { |
||
258 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php'); |
||
259 | |||
260 | $this->assertError($file, 22, 'The use of function mysqli_send_long_data is forbidden from PHP version 5.4; use mysqli_stmt_send_long_data instead'); |
||
261 | } |
||
262 | |||
263 | /** |
||
264 | * Test magic_quotes_runtime |
||
265 | * |
||
266 | * @return void |
||
267 | */ |
||
268 | View Code Duplication | public function testMagicQuotesRuntime() |
|
269 | { |
||
270 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php', '5.6'); |
||
271 | $this->assertWarning($file, 23, 'The use of function magic_quotes_runtime is discouraged from PHP version 5.3'); |
||
272 | |||
273 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php', '7.0'); |
||
274 | $this->assertError($file, 23, 'The use of function magic_quotes_runtime is discouraged from PHP version 5.3 and forbidden from PHP version 7.0'); |
||
275 | } |
||
276 | |||
277 | /** |
||
278 | * Test session_register |
||
279 | * |
||
280 | * @return void |
||
281 | */ |
||
282 | public function testSessionRegister() |
||
283 | { |
||
284 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php'); |
||
285 | |||
286 | $this->assertError($file, 24, 'The use of function session_register is discouraged from PHP version 5.3 and forbidden from PHP version 5.4; use $_SESSION instead'); |
||
287 | } |
||
288 | |||
289 | /** |
||
290 | * Test session_unregister |
||
291 | * |
||
292 | * @return void |
||
293 | */ |
||
294 | public function testSessionUnregister() |
||
295 | { |
||
296 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php'); |
||
297 | |||
298 | $this->assertError($file, 25, 'The use of function session_unregister is discouraged from PHP version 5.3 and forbidden from PHP version 5.4; use $_SESSION instead'); |
||
299 | } |
||
300 | |||
301 | /** |
||
302 | * Test session_is_registered |
||
303 | * |
||
304 | * @return void |
||
305 | */ |
||
306 | public function testSessionIsRegistered() |
||
307 | { |
||
308 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php'); |
||
309 | |||
310 | $this->assertError($file, 26, 'The use of function session_is_registered is discouraged from PHP version 5.3 and forbidden from PHP version 5.4; use $_SESSION instead'); |
||
311 | } |
||
312 | |||
313 | /** |
||
314 | * Test set_magic_quotes_runtime |
||
315 | * |
||
316 | * @return void |
||
317 | */ |
||
318 | View Code Duplication | public function testSetMagicQuotesRuntime() |
|
319 | { |
||
320 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php', '5.6'); |
||
321 | $this->assertWarning($file, 27, 'The use of function set_magic_quotes_runtime is discouraged from PHP version 5.3'); |
||
322 | |||
323 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php', '7.0'); |
||
324 | $this->assertError($file, 27, 'The use of function set_magic_quotes_runtime is discouraged from PHP version 5.3 and forbidden from PHP version 7.0'); |
||
325 | } |
||
326 | |||
327 | /** |
||
328 | * Test set_socket_blocking |
||
329 | * |
||
330 | * @return void |
||
331 | */ |
||
332 | View Code Duplication | public function testSetSocketBlocking() |
|
333 | { |
||
334 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php', '5.6'); |
||
335 | $this->assertWarning($file, 28, 'The use of function set_socket_blocking is discouraged from PHP version 5.3; use stream_set_blocking instead'); |
||
336 | |||
337 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php', '7.0'); |
||
338 | $this->assertError($file, 28, 'The use of function set_socket_blocking is discouraged from PHP version 5.3 and forbidden from PHP version 7.0; use stream_set_blocking instead'); |
||
339 | } |
||
340 | |||
341 | /** |
||
342 | * Test split |
||
343 | * |
||
344 | * @return void |
||
345 | */ |
||
346 | public function testSplit() |
||
347 | { |
||
348 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php'); |
||
349 | |||
350 | $this->assertWarning($file, 29, 'The use of function split is discouraged from PHP version 5.3; use preg_split instead'); |
||
351 | } |
||
352 | |||
353 | /** |
||
354 | * Test spliti |
||
355 | * |
||
356 | * @return void |
||
357 | */ |
||
358 | public function testSpliti() |
||
359 | { |
||
360 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php'); |
||
361 | |||
362 | $this->assertWarning($file, 30, 'The use of function spliti is discouraged from PHP version 5.3; use preg_split instead'); |
||
363 | } |
||
364 | |||
365 | /** |
||
366 | * Test sql_regcase |
||
367 | * |
||
368 | * @return void |
||
369 | */ |
||
370 | public function testSqlRegcase() |
||
371 | { |
||
372 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php'); |
||
373 | |||
374 | $this->assertWarning($file, 31, 'The use of function sql_regcase is discouraged from PHP version 5.3'); |
||
375 | } |
||
376 | |||
377 | /** |
||
378 | * Test php_logo_guid |
||
379 | * |
||
380 | * @return void |
||
381 | */ |
||
382 | public function testPhpLogoGuid() |
||
383 | { |
||
384 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php'); |
||
385 | |||
386 | $this->assertError($file, 32, 'The use of function php_logo_guid is forbidden from PHP version 5.5'); |
||
387 | } |
||
388 | |||
389 | /** |
||
390 | * Test php_egg_logo_guid |
||
391 | * |
||
392 | * @return void |
||
393 | */ |
||
394 | public function testPhpEggLogoGuid() |
||
395 | { |
||
396 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php'); |
||
397 | |||
398 | $this->assertError($file, 33, 'The use of function php_egg_logo_guid is forbidden from PHP version 5.5'); |
||
399 | } |
||
400 | |||
401 | /** |
||
402 | * Test php_real_logo_guid |
||
403 | * |
||
404 | * @return void |
||
405 | */ |
||
406 | public function testPhpRealLogoGuid() |
||
407 | { |
||
408 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php'); |
||
409 | |||
410 | $this->assertError($file, 34, 'The use of function php_real_logo_guid is forbidden from PHP version 5.5'); |
||
411 | } |
||
412 | |||
413 | /** |
||
414 | * Test zend_logo_guid |
||
415 | * |
||
416 | * @return void |
||
417 | */ |
||
418 | public function testZendLogoGuid() |
||
419 | { |
||
420 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php'); |
||
421 | |||
422 | $this->assertError($file, 35, 'The use of function zend_logo_guid is forbidden from PHP version 5.5'); |
||
423 | } |
||
424 | |||
425 | /** |
||
426 | * Test datefmt_set_timezone_id |
||
427 | * |
||
428 | * @return void |
||
429 | */ |
||
430 | View Code Duplication | public function testDateFmtSetTimezone() |
|
431 | { |
||
432 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php', '5.6'); |
||
433 | $this->assertWarning($file, 36, 'The use of function datefmt_set_timezone_id is discouraged from PHP version 5.5; use datefmt_set_timezone instead'); |
||
434 | |||
435 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php', '7.0'); |
||
436 | $this->assertError($file, 36, 'The use of function datefmt_set_timezone_id is discouraged from PHP version 5.5 and forbidden from PHP version 7.0; use datefmt_set_timezone instead'); |
||
437 | } |
||
438 | |||
439 | /** |
||
440 | * Test mcrypt_ecb |
||
441 | * |
||
442 | * @return void |
||
443 | */ |
||
444 | View Code Duplication | public function testMcryptEcb() |
|
445 | { |
||
446 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php', '5.6'); |
||
447 | $this->assertWarning($file, 37, 'The use of function mcrypt_ecb is discouraged from PHP version 5.5'); |
||
448 | |||
449 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php', '7.0'); |
||
450 | $this->assertError($file, 37, 'The use of function mcrypt_ecb is discouraged from PHP version 5.5 and forbidden from PHP version 7.0'); |
||
451 | } |
||
452 | |||
453 | /** |
||
454 | * Test mcrypt_cbc |
||
455 | * |
||
456 | * @return void |
||
457 | */ |
||
458 | View Code Duplication | public function testMcryptCbc() |
|
459 | { |
||
460 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php', '5.6'); |
||
461 | $this->assertWarning($file, 38, 'The use of function mcrypt_cbc is discouraged from PHP version 5.5'); |
||
462 | |||
463 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php', '7.0'); |
||
464 | $this->assertError($file, 38, 'The use of function mcrypt_cbc is discouraged from PHP version 5.5 and forbidden from PHP version 7.0'); |
||
465 | } |
||
466 | |||
467 | /** |
||
468 | * Test mcrypt_cfb |
||
469 | * |
||
470 | * @return void |
||
471 | */ |
||
472 | View Code Duplication | public function testMcryptCfb() |
|
473 | { |
||
474 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php', '5.6'); |
||
475 | $this->assertWarning($file, 39, 'The use of function mcrypt_cfb is discouraged from PHP version 5.5'); |
||
476 | |||
477 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php', '7.0'); |
||
478 | $this->assertError($file, 39, 'The use of function mcrypt_cfb is discouraged from PHP version 5.5 and forbidden from PHP version 7.0'); |
||
479 | } |
||
480 | |||
481 | /** |
||
482 | * Test mcrypt_ofb |
||
483 | * |
||
484 | * @return void |
||
485 | */ |
||
486 | View Code Duplication | public function testMcryptOfb() |
|
487 | { |
||
488 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php', '5.6'); |
||
489 | $this->assertWarning($file, 40, 'The use of function mcrypt_ofb is discouraged from PHP version 5.5'); |
||
490 | |||
491 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php', '7.0'); |
||
492 | $this->assertError($file, 40, 'The use of function mcrypt_ofb is discouraged from PHP version 5.5 and forbidden from PHP version 7.0'); |
||
493 | } |
||
494 | |||
495 | /** |
||
496 | * Test ocibindbyname |
||
497 | * |
||
498 | * @return void |
||
499 | */ |
||
500 | public function testOcibindbyname() |
||
506 | |||
507 | /** |
||
508 | * Test ocicancel |
||
509 | * |
||
510 | * @return void |
||
511 | */ |
||
512 | public function testOcicancel() |
||
518 | |||
519 | /** |
||
520 | * Test ocicloselob |
||
521 | * |
||
522 | * @return void |
||
523 | */ |
||
524 | public function testOcicloselob() |
||
530 | |||
531 | /** |
||
532 | * Test ocicollappend |
||
533 | * |
||
534 | * @return void |
||
535 | */ |
||
536 | public function testOcicollappend() |
||
542 | |||
543 | /** |
||
544 | * Test ocicollassign |
||
545 | * |
||
546 | * @return void |
||
547 | */ |
||
548 | public function testOcicollassign() |
||
554 | |||
555 | /** |
||
556 | * Test ocicollassignelem |
||
557 | * |
||
558 | * @return void |
||
559 | */ |
||
560 | public function testOcicollassignelem() |
||
566 | |||
567 | /** |
||
568 | * Test ocicollgetelem |
||
569 | * |
||
570 | * @return void |
||
571 | */ |
||
572 | public function testOcicollgetelem() |
||
578 | |||
579 | /** |
||
580 | * Test ocicollmax |
||
581 | * |
||
582 | * @return void |
||
583 | */ |
||
584 | public function testOcicollmax() |
||
590 | |||
591 | /** |
||
592 | * Test ocicollsize |
||
593 | * |
||
594 | * @return void |
||
595 | */ |
||
596 | public function testOcicollsize() |
||
602 | |||
603 | /** |
||
604 | * Test ocicolltrim |
||
605 | * |
||
606 | * @return void |
||
607 | */ |
||
608 | public function testOcicolltrim() |
||
614 | |||
615 | /** |
||
616 | * Test ocicolumnisnull |
||
617 | * |
||
618 | * @return void |
||
619 | */ |
||
620 | public function testOcicolumnisnull() |
||
626 | |||
627 | /** |
||
628 | * Test ocicolumnname |
||
629 | * |
||
630 | * @return void |
||
631 | */ |
||
632 | public function testOcicolumnname() |
||
638 | |||
639 | /** |
||
640 | * Test ocicolumnprecision |
||
641 | * |
||
642 | * @return void |
||
643 | */ |
||
644 | public function testOcicolumnprecision() |
||
650 | |||
651 | /** |
||
652 | * Test ocicolumnscale |
||
653 | * |
||
654 | * @return void |
||
655 | */ |
||
656 | public function testOcicolumnscale() |
||
662 | |||
663 | /** |
||
664 | * Test ocicolumnsize |
||
665 | * |
||
666 | * @return void |
||
667 | */ |
||
668 | public function testOcicolumnsize() |
||
674 | |||
675 | /** |
||
676 | * Test ocicolumntype |
||
677 | * |
||
678 | * @return void |
||
679 | */ |
||
680 | public function testOcicolumntype() |
||
686 | |||
687 | /** |
||
688 | * Test ocicolumntyperaw |
||
689 | * |
||
690 | * @return void |
||
691 | */ |
||
692 | public function testOcicolumntyperaw() |
||
698 | |||
699 | /** |
||
700 | * Test ocicommit |
||
701 | * |
||
702 | * @return void |
||
703 | */ |
||
704 | public function testOcicommit() |
||
710 | |||
711 | /** |
||
712 | * Test ocidefinebyname |
||
713 | * |
||
714 | * @return void |
||
715 | */ |
||
716 | public function testOcidefinebyname() |
||
722 | |||
723 | /** |
||
724 | * Test ocierror |
||
725 | * |
||
726 | * @return void |
||
727 | */ |
||
728 | public function testOcierror() |
||
734 | |||
735 | /** |
||
736 | * Test ociexecute |
||
737 | * |
||
738 | * @return void |
||
739 | */ |
||
740 | public function testOciexecute() |
||
746 | |||
747 | /** |
||
748 | * Test ocifetch |
||
749 | * |
||
750 | * @return void |
||
751 | */ |
||
752 | public function testOcifetch() |
||
758 | |||
759 | /** |
||
760 | * Test ocifetchinto |
||
761 | * |
||
762 | * @return void |
||
763 | */ |
||
764 | public function testOcifetchinto() |
||
770 | |||
771 | /** |
||
772 | * Test ocifetchstatement |
||
773 | * |
||
774 | * @return void |
||
775 | */ |
||
776 | public function testOcifetchstatement() |
||
782 | |||
783 | /** |
||
784 | * Test ocifreecollection |
||
785 | * |
||
786 | * @return void |
||
787 | */ |
||
788 | public function testOcifreecollection() |
||
794 | |||
795 | /** |
||
796 | * Test ocifreecursor |
||
797 | * |
||
798 | * @return void |
||
799 | */ |
||
800 | public function testOcifreecursor() |
||
806 | |||
807 | /** |
||
808 | * Test ocifreedesc |
||
809 | * |
||
810 | * @return void |
||
811 | */ |
||
812 | public function testOcifreedesc() |
||
818 | |||
819 | /** |
||
820 | * Test ocifreestatement |
||
821 | * |
||
822 | * @return void |
||
823 | */ |
||
824 | public function testOcifreestatement() |
||
830 | |||
831 | /** |
||
832 | * Test ociinternaldebug |
||
833 | * |
||
834 | * @return void |
||
835 | */ |
||
836 | public function testOciinternaldebug() |
||
842 | |||
843 | /** |
||
844 | * Test ociloadlob |
||
845 | * |
||
846 | * @return void |
||
847 | */ |
||
848 | public function testOciloadlob() |
||
854 | |||
855 | /** |
||
856 | * Test ocilogoff |
||
857 | * |
||
858 | * @return void |
||
859 | */ |
||
860 | public function testOcilogoff() |
||
866 | |||
867 | /** |
||
868 | * Test ocilogon |
||
869 | * |
||
870 | * @return void |
||
871 | */ |
||
872 | public function testOcilogon() |
||
878 | |||
879 | /** |
||
880 | * Test ocinewcollection |
||
881 | * |
||
882 | * @return void |
||
883 | */ |
||
884 | public function testOcinewcollection() |
||
890 | |||
891 | /** |
||
892 | * Test ocinewcursor |
||
893 | * |
||
894 | * @return void |
||
895 | */ |
||
896 | public function testOcinewcursor() |
||
902 | |||
903 | /** |
||
904 | * Test ocinewdescriptor |
||
905 | * |
||
906 | * @return void |
||
907 | */ |
||
908 | public function testOcinewdescriptor() |
||
914 | |||
915 | /** |
||
916 | * Test ocinlogon |
||
917 | * |
||
918 | * @return void |
||
919 | */ |
||
920 | public function testOcinlogon() |
||
926 | |||
927 | /** |
||
928 | * Test ocinumcols |
||
929 | * |
||
930 | * @return void |
||
931 | */ |
||
932 | public function testOcinumcols() |
||
938 | |||
939 | /** |
||
940 | * Test ociparse |
||
941 | * |
||
942 | * @return void |
||
943 | */ |
||
944 | public function testOciparse() |
||
950 | |||
951 | /** |
||
952 | * Test ociplogon |
||
953 | * |
||
954 | * @return void |
||
955 | */ |
||
956 | public function testOciplogon() |
||
962 | |||
963 | /** |
||
964 | * Test ociresult |
||
965 | * |
||
966 | * @return void |
||
967 | */ |
||
968 | public function testOciresult() |
||
974 | |||
975 | /** |
||
976 | * Test ocirollback |
||
977 | * |
||
978 | * @return void |
||
979 | */ |
||
980 | public function testOcirollback() |
||
986 | |||
987 | /** |
||
988 | * Test ocirowcount |
||
989 | * |
||
990 | * @return void |
||
991 | */ |
||
992 | public function testOcirowcount() |
||
998 | |||
999 | /** |
||
1000 | * Test ocisavelob |
||
1001 | * |
||
1002 | * @return void |
||
1003 | */ |
||
1004 | public function testOcisavelob() |
||
1010 | |||
1011 | /** |
||
1012 | * Test ocisavelobfile |
||
1013 | * |
||
1014 | * @return void |
||
1015 | */ |
||
1016 | public function testOcisavelobfile() |
||
1022 | |||
1023 | /** |
||
1024 | * Test ociserverversion |
||
1025 | * |
||
1026 | * @return void |
||
1027 | */ |
||
1028 | public function testOciserverversion() |
||
1034 | |||
1035 | /** |
||
1036 | * Test ocisetprefetch |
||
1037 | * |
||
1038 | * @return void |
||
1039 | */ |
||
1040 | public function testOcisetprefetch() |
||
1046 | |||
1047 | /** |
||
1048 | * Test ocistatementtype |
||
1049 | * |
||
1050 | * @return void |
||
1051 | */ |
||
1052 | public function testOcistatementtype() |
||
1058 | |||
1059 | /** |
||
1060 | * Test ociwritelobtofile |
||
1061 | * |
||
1062 | * @return void |
||
1063 | */ |
||
1064 | public function testOciwritelobtofile() |
||
1070 | |||
1071 | /** |
||
1072 | * Test ociwritetemporarylob |
||
1073 | * |
||
1074 | * @return void |
||
1075 | */ |
||
1076 | public function testOciwritetemporarylob() |
||
1082 | |||
1083 | /** |
||
1084 | * Test ldap_sort |
||
1085 | * |
||
1086 | * @return void |
||
1087 | */ |
||
1088 | public function testLdapSort() |
||
1089 | { |
||
1090 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php'); |
||
1091 | |||
1092 | $this->assertWarning($file, 97, 'The use of function ldap_sort is forbidden from PHP version 7.0'); |
||
1093 | } |
||
1094 | |||
1095 | /** |
||
1096 | * GD Type 1 PostScript functions |
||
1097 | * |
||
1098 | * @return void |
||
1099 | */ |
||
1100 | public function testGDType1() |
||
1101 | { |
||
1102 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php', '5.6'); |
||
1103 | $this->assertNoViolation($file, 90); |
||
1104 | $this->assertNoViolation($file, 91); |
||
1105 | $this->assertNoViolation($file, 92); |
||
1106 | $this->assertNoViolation($file, 93); |
||
1107 | $this->assertNoViolation($file, 94); |
||
1108 | $this->assertNoViolation($file, 95); |
||
1109 | $this->assertNoViolation($file, 96); |
||
1110 | |||
1111 | $file = $this->sniffFile('sniff-examples/deprecated_functions.php', '7.0'); |
||
1112 | $this->assertError($file, 90, 'The use of function imagepsbbox is forbidden from PHP version 7.0'); |
||
1113 | $this->assertError($file, 91, 'The use of function imagepsencodefont is forbidden from PHP version 7.0'); |
||
1114 | $this->assertError($file, 92, 'The use of function imagepsextendfont is forbidden from PHP version 7.0'); |
||
1115 | $this->assertError($file, 93, 'The use of function imagepsfreefont is forbidden from PHP version 7.0'); |
||
1116 | $this->assertError($file, 94, 'The use of function imagepsloadfont is forbidden from PHP version 7.0'); |
||
1117 | $this->assertError($file, 95, 'The use of function imagepsslantfont is forbidden from PHP version 7.0'); |
||
1118 | $this->assertError($file, 96, 'The use of function imagepstext is forbidden from PHP version 7.0'); |
||
1119 | } |
||
1120 | |||
1121 | /** |
||
1122 | * Test when setting the testVersion |
||
1123 | * |
||
1124 | * @return void |
||
1125 | */ |
||
1126 | public function testSettingTestVersion() |
||
1132 | } |
||
1133 | |||
1134 |
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.