Code Duplication    Length = 35-35 lines in 2 locations

Sniffs/PHP/RemovedExtensionsSniff.php 1 location

@@ 316-350 (lines=35) @@
313
            return;
314
        }
315
316
        foreach ($this->removedExtensions as $extension => $versionList) {
317
            if (strpos(strtolower($tokens[$stackPtr]['content']), strtolower($extension)) === 0) {
318
                $error = '';
319
                $isErrored = false;
320
                foreach ($versionList as $version => $status) {
321
                    if ($version != 'alternative') {
322
                        if ($status == -1 || $status == 0) {
323
                            if ($this->supportsAbove($version)) {
324
                                switch ($status) {
325
                                    case -1:
326
                                        $error .= 'deprecated since PHP ' . $version . ' and ';
327
                                        break;
328
                                    case 0:
329
                                        $isErrored = true;
330
                                        $error .= 'removed since PHP ' . $version . ' and ';
331
                                        break 2;
332
                                }
333
                            }
334
                        }
335
                    }
336
                }
337
                if (strlen($error) > 0) {
338
                    $error = "Extension '" . $extension . "' is " . $error;
339
                    $error = substr($error, 0, strlen($error) - 5);
340
                    if (!is_null($versionList['alternative'])) {
341
                        $error .= ' - use ' . $versionList['alternative'] . ' instead.';
342
                    }
343
                    if ($isErrored === true) {
344
                        $phpcsFile->addError($error, $stackPtr);
345
                    } else {
346
                        $phpcsFile->addWarning($error, $stackPtr);
347
                    }
348
                }
349
            }
350
        }
351
352
    }//end process()
353

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