Code Duplication    Length = 35-35 lines in 2 locations

Sniffs/PHP/RemovedExtensionsSniff.php 1 location

@@ 330-364 (lines=35) @@
327
            return;
328
        }
329
330
        foreach ($this->removedExtensions as $extension => $versionList) {
331
            if (strpos(strtolower($tokens[$stackPtr]['content']), strtolower($extension)) === 0) {
332
                $error = '';
333
                $isErrored = false;
334
                foreach ($versionList as $version => $status) {
335
                    if ($version != 'alternative') {
336
                        if ($status == -1 || $status == 0) {
337
                            if ($this->supportsAbove($version)) {
338
                                switch ($status) {
339
                                    case -1:
340
                                        $error .= 'deprecated since PHP ' . $version . ' and ';
341
                                        break;
342
                                    case 0:
343
                                        $isErrored = true;
344
                                        $error .= 'removed since PHP ' . $version . ' and ';
345
                                        break 2;
346
                                }
347
                            }
348
                        }
349
                    }
350
                }
351
                if (strlen($error) > 0) {
352
                    $error = "Extension '" . $extension . "' is " . $error;
353
                    $error = substr($error, 0, strlen($error) - 5);
354
                    if (!is_null($versionList['alternative'])) {
355
                        $error .= ' - use ' . $versionList['alternative'] . ' instead.';
356
                    }
357
                    if ($isErrored === true) {
358
                        $phpcsFile->addError($error, $stackPtr);
359
                    } else {
360
                        $phpcsFile->addWarning($error, $stackPtr);
361
                    }
362
                }
363
            }
364
        }
365
366
    }//end process()
367

Sniffs/PHP/RemovedGlobalVariablesSniff.php 1 location

@@ 61-95 (lines=35) @@
58
    {
59
        $tokens = $phpcsFile->getTokens();
60
        
61
        foreach ($this->removedGlobalVariables as $variable => $versionList) {
62
            if (strtolower($tokens[$stackPtr]['content']) == '$' . strtolower($variable)) {
63
                $error = '';
64
                $isErrored = false;
65
                foreach ($versionList as $version => $status) {
66
                    if ($version != 'alternative') {
67
                        if ($status == -1 || $status == 0) {
68
                            if ($this->supportsAbove($version)) {
69
                                switch ($status) {
70
                                    case -1:
71
                                        $error .= 'deprecated since PHP ' . $version . ' and ';
72
                                        break;
73
                                    case 0:
74
                                        $isErrored = true;
75
                                        $error .= 'removed since PHP ' . $version . ' and ';
76
                                        break 2;
77
                                }
78
                            }
79
                        }
80
                    }
81
                }
82
                if (strlen($error) > 0) {
83
                    $error = "Global variable '" . $variable . "' is " . $error;
84
                    $error = substr($error, 0, strlen($error) - 5);
85
                    if (!is_null($versionList['alternative'])) {
86
                        $error .= ' - use ' . $versionList['alternative'] . ' instead.';
87
                    }
88
                    if ($isErrored === true) {
89
                        $phpcsFile->addError($error, $stackPtr);
90
                    } else {
91
                        $phpcsFile->addWarning($error, $stackPtr);
92
                    }
93
                }
94
            }
95
        }
96
97
    }//end process()
98