Completed
Branch dev (5b2722)
by
unknown
05:49 queued 10s
created
src/Standards/Generic/Sniffs/Files/OneObjectStructurePerFileSniff.php 1 patch
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -16,40 +16,40 @@
 block discarded – undo
16 16
 {
17 17
 
18 18
 
19
-    /**
20
-     * Returns an array of tokens this test wants to listen for.
21
-     *
22
-     * @return array
23
-     */
24
-    public function register()
25
-    {
26
-        return [
27
-            T_CLASS,
28
-            T_INTERFACE,
29
-            T_TRAIT,
30
-        ];
31
-
32
-    }//end register()
33
-
34
-
35
-    /**
36
-     * Processes this sniff, when one of its tokens is encountered.
37
-     *
38
-     * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
39
-     * @param int                         $stackPtr  The position of the current token in
40
-     *                                               the stack passed in $tokens.
41
-     *
42
-     * @return void
43
-     */
44
-    public function process(File $phpcsFile, $stackPtr)
45
-    {
46
-        $nextClass = $phpcsFile->findNext($this->register(), ($stackPtr + 1));
47
-        if ($nextClass !== false) {
48
-            $error = 'Only one object structure is allowed in a file';
49
-            $phpcsFile->addError($error, $nextClass, 'MultipleFound');
50
-        }
51
-
52
-    }//end process()
19
+	/**
20
+	 * Returns an array of tokens this test wants to listen for.
21
+	 *
22
+	 * @return array
23
+	 */
24
+	public function register()
25
+	{
26
+		return [
27
+			T_CLASS,
28
+			T_INTERFACE,
29
+			T_TRAIT,
30
+		];
31
+
32
+	}//end register()
33
+
34
+
35
+	/**
36
+	 * Processes this sniff, when one of its tokens is encountered.
37
+	 *
38
+	 * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
39
+	 * @param int                         $stackPtr  The position of the current token in
40
+	 *                                               the stack passed in $tokens.
41
+	 *
42
+	 * @return void
43
+	 */
44
+	public function process(File $phpcsFile, $stackPtr)
45
+	{
46
+		$nextClass = $phpcsFile->findNext($this->register(), ($stackPtr + 1));
47
+		if ($nextClass !== false) {
48
+			$error = 'Only one object structure is allowed in a file';
49
+			$phpcsFile->addError($error, $nextClass, 'MultipleFound');
50
+		}
51
+
52
+	}//end process()
53 53
 
54 54
 
55 55
 }//end class
Please login to merge, or discard this patch.
php_codesniffer/src/Standards/Generic/Sniffs/Files/OneTraitPerFileSniff.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -16,36 +16,36 @@
 block discarded – undo
16 16
 {
17 17
 
18 18
 
19
-    /**
20
-     * Returns an array of tokens this test wants to listen for.
21
-     *
22
-     * @return array
23
-     */
24
-    public function register()
25
-    {
26
-        return [T_TRAIT];
27
-
28
-    }//end register()
29
-
30
-
31
-    /**
32
-     * Processes this sniff, when one of its tokens is encountered.
33
-     *
34
-     * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
35
-     * @param int                         $stackPtr  The position of the current token in
36
-     *                                               the stack passed in $tokens.
37
-     *
38
-     * @return void
39
-     */
40
-    public function process(File $phpcsFile, $stackPtr)
41
-    {
42
-        $nextClass = $phpcsFile->findNext($this->register(), ($stackPtr + 1));
43
-        if ($nextClass !== false) {
44
-            $error = 'Only one trait is allowed in a file';
45
-            $phpcsFile->addError($error, $nextClass, 'MultipleFound');
46
-        }
47
-
48
-    }//end process()
19
+	/**
20
+	 * Returns an array of tokens this test wants to listen for.
21
+	 *
22
+	 * @return array
23
+	 */
24
+	public function register()
25
+	{
26
+		return [T_TRAIT];
27
+
28
+	}//end register()
29
+
30
+
31
+	/**
32
+	 * Processes this sniff, when one of its tokens is encountered.
33
+	 *
34
+	 * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
35
+	 * @param int                         $stackPtr  The position of the current token in
36
+	 *                                               the stack passed in $tokens.
37
+	 *
38
+	 * @return void
39
+	 */
40
+	public function process(File $phpcsFile, $stackPtr)
41
+	{
42
+		$nextClass = $phpcsFile->findNext($this->register(), ($stackPtr + 1));
43
+		if ($nextClass !== false) {
44
+			$error = 'Only one trait is allowed in a file';
45
+			$phpcsFile->addError($error, $nextClass, 'MultipleFound');
46
+		}
47
+
48
+	}//end process()
49 49
 
50 50
 
51 51
 }//end class
Please login to merge, or discard this patch.
php_codesniffer/src/Standards/Generic/Sniffs/Files/OneClassPerFileSniff.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -16,36 +16,36 @@
 block discarded – undo
16 16
 {
17 17
 
18 18
 
19
-    /**
20
-     * Returns an array of tokens this test wants to listen for.
21
-     *
22
-     * @return array
23
-     */
24
-    public function register()
25
-    {
26
-        return [T_CLASS];
27
-
28
-    }//end register()
29
-
30
-
31
-    /**
32
-     * Processes this sniff, when one of its tokens is encountered.
33
-     *
34
-     * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
35
-     * @param int                         $stackPtr  The position of the current token in
36
-     *                                               the stack passed in $tokens.
37
-     *
38
-     * @return void
39
-     */
40
-    public function process(File $phpcsFile, $stackPtr)
41
-    {
42
-        $nextClass = $phpcsFile->findNext($this->register(), ($stackPtr + 1));
43
-        if ($nextClass !== false) {
44
-            $error = 'Only one class is allowed in a file';
45
-            $phpcsFile->addError($error, $nextClass, 'MultipleFound');
46
-        }
47
-
48
-    }//end process()
19
+	/**
20
+	 * Returns an array of tokens this test wants to listen for.
21
+	 *
22
+	 * @return array
23
+	 */
24
+	public function register()
25
+	{
26
+		return [T_CLASS];
27
+
28
+	}//end register()
29
+
30
+
31
+	/**
32
+	 * Processes this sniff, when one of its tokens is encountered.
33
+	 *
34
+	 * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
35
+	 * @param int                         $stackPtr  The position of the current token in
36
+	 *                                               the stack passed in $tokens.
37
+	 *
38
+	 * @return void
39
+	 */
40
+	public function process(File $phpcsFile, $stackPtr)
41
+	{
42
+		$nextClass = $phpcsFile->findNext($this->register(), ($stackPtr + 1));
43
+		if ($nextClass !== false) {
44
+			$error = 'Only one class is allowed in a file';
45
+			$phpcsFile->addError($error, $nextClass, 'MultipleFound');
46
+		}
47
+
48
+	}//end process()
49 49
 
50 50
 
51 51
 }//end class
Please login to merge, or discard this patch.
src/Standards/Generic/Sniffs/Files/LowercasedFilenameSniff.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@
 block discarded – undo
47 47
         $filename          = basename($filename);
48 48
         $lowercaseFilename = strtolower($filename);
49 49
         if ($filename !== $lowercaseFilename) {
50
-            $data  = [
50
+            $data = [
51 51
                 $filename,
52 52
                 $lowercaseFilename,
53 53
             ];
Please login to merge, or discard this patch.
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -16,55 +16,55 @@
 block discarded – undo
16 16
 {
17 17
 
18 18
 
19
-    /**
20
-     * Returns an array of tokens this test wants to listen for.
21
-     *
22
-     * @return array
23
-     */
24
-    public function register()
25
-    {
26
-        return [
27
-            T_OPEN_TAG,
28
-            T_OPEN_TAG_WITH_ECHO,
29
-        ];
19
+	/**
20
+	 * Returns an array of tokens this test wants to listen for.
21
+	 *
22
+	 * @return array
23
+	 */
24
+	public function register()
25
+	{
26
+		return [
27
+			T_OPEN_TAG,
28
+			T_OPEN_TAG_WITH_ECHO,
29
+		];
30 30
 
31
-    }//end register()
31
+	}//end register()
32 32
 
33 33
 
34
-    /**
35
-     * Processes this sniff, when one of its tokens is encountered.
36
-     *
37
-     * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
38
-     * @param int                         $stackPtr  The position of the current token in
39
-     *                                               the stack passed in $tokens.
40
-     *
41
-     * @return int
42
-     */
43
-    public function process(File $phpcsFile, $stackPtr)
44
-    {
45
-        $filename = $phpcsFile->getFilename();
46
-        if ($filename === 'STDIN') {
47
-            return;
48
-        }
34
+	/**
35
+	 * Processes this sniff, when one of its tokens is encountered.
36
+	 *
37
+	 * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
38
+	 * @param int                         $stackPtr  The position of the current token in
39
+	 *                                               the stack passed in $tokens.
40
+	 *
41
+	 * @return int
42
+	 */
43
+	public function process(File $phpcsFile, $stackPtr)
44
+	{
45
+		$filename = $phpcsFile->getFilename();
46
+		if ($filename === 'STDIN') {
47
+			return;
48
+		}
49 49
 
50
-        $filename          = basename($filename);
51
-        $lowercaseFilename = strtolower($filename);
52
-        if ($filename !== $lowercaseFilename) {
53
-            $data  = [
54
-                $filename,
55
-                $lowercaseFilename,
56
-            ];
57
-            $error = 'Filename "%s" doesn\'t match the expected filename "%s"';
58
-            $phpcsFile->addError($error, $stackPtr, 'NotFound', $data);
59
-            $phpcsFile->recordMetric($stackPtr, 'Lowercase filename', 'no');
60
-        } else {
61
-            $phpcsFile->recordMetric($stackPtr, 'Lowercase filename', 'yes');
62
-        }
50
+		$filename          = basename($filename);
51
+		$lowercaseFilename = strtolower($filename);
52
+		if ($filename !== $lowercaseFilename) {
53
+			$data  = [
54
+				$filename,
55
+				$lowercaseFilename,
56
+			];
57
+			$error = 'Filename "%s" doesn\'t match the expected filename "%s"';
58
+			$phpcsFile->addError($error, $stackPtr, 'NotFound', $data);
59
+			$phpcsFile->recordMetric($stackPtr, 'Lowercase filename', 'no');
60
+		} else {
61
+			$phpcsFile->recordMetric($stackPtr, 'Lowercase filename', 'yes');
62
+		}
63 63
 
64
-        // Ignore the rest of the file.
65
-        return ($phpcsFile->numTokens + 1);
64
+		// Ignore the rest of the file.
65
+		return ($phpcsFile->numTokens + 1);
66 66
 
67
-    }//end process()
67
+	}//end process()
68 68
 
69 69
 
70 70
 }//end class
Please login to merge, or discard this patch.
php_codesniffer/src/Standards/Generic/Sniffs/Commenting/FixmeSniff.php 1 patch
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -17,62 +17,62 @@
 block discarded – undo
17 17
 class FixmeSniff implements Sniff
18 18
 {
19 19
 
20
-    /**
21
-     * A list of tokenizers this sniff supports.
22
-     *
23
-     * @var array
24
-     */
25
-    public $supportedTokenizers = [
26
-        'PHP',
27
-        'JS',
28
-    ];
20
+	/**
21
+	 * A list of tokenizers this sniff supports.
22
+	 *
23
+	 * @var array
24
+	 */
25
+	public $supportedTokenizers = [
26
+		'PHP',
27
+		'JS',
28
+	];
29 29
 
30 30
 
31
-    /**
32
-     * Returns an array of tokens this test wants to listen for.
33
-     *
34
-     * @return array
35
-     */
36
-    public function register()
37
-    {
38
-        return array_diff(Tokens::$commentTokens, Tokens::$phpcsCommentTokens);
31
+	/**
32
+	 * Returns an array of tokens this test wants to listen for.
33
+	 *
34
+	 * @return array
35
+	 */
36
+	public function register()
37
+	{
38
+		return array_diff(Tokens::$commentTokens, Tokens::$phpcsCommentTokens);
39 39
 
40
-    }//end register()
40
+	}//end register()
41 41
 
42 42
 
43
-    /**
44
-     * Processes this sniff, when one of its tokens is encountered.
45
-     *
46
-     * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
47
-     * @param int                         $stackPtr  The position of the current token
48
-     *                                               in the stack passed in $tokens.
49
-     *
50
-     * @return void
51
-     */
52
-    public function process(File $phpcsFile, $stackPtr)
53
-    {
54
-        $tokens = $phpcsFile->getTokens();
43
+	/**
44
+	 * Processes this sniff, when one of its tokens is encountered.
45
+	 *
46
+	 * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
47
+	 * @param int                         $stackPtr  The position of the current token
48
+	 *                                               in the stack passed in $tokens.
49
+	 *
50
+	 * @return void
51
+	 */
52
+	public function process(File $phpcsFile, $stackPtr)
53
+	{
54
+		$tokens = $phpcsFile->getTokens();
55 55
 
56
-        $content = $tokens[$stackPtr]['content'];
57
-        $matches = [];
58
-        preg_match('/(?:\A|[^\p{L}]+)fixme([^\p{L}]+(.*)|\Z)/ui', $content, $matches);
59
-        if (empty($matches) === false) {
60
-            // Clear whitespace and some common characters not required at
61
-            // the end of a fixme message to make the error more informative.
62
-            $type         = 'CommentFound';
63
-            $fixmeMessage = trim($matches[1]);
64
-            $fixmeMessage = trim($fixmeMessage, '-:[](). ');
65
-            $error        = 'Comment refers to a FIXME task';
66
-            $data         = [$fixmeMessage];
67
-            if ($fixmeMessage !== '') {
68
-                $type   = 'TaskFound';
69
-                $error .= ' "%s"';
70
-            }
56
+		$content = $tokens[$stackPtr]['content'];
57
+		$matches = [];
58
+		preg_match('/(?:\A|[^\p{L}]+)fixme([^\p{L}]+(.*)|\Z)/ui', $content, $matches);
59
+		if (empty($matches) === false) {
60
+			// Clear whitespace and some common characters not required at
61
+			// the end of a fixme message to make the error more informative.
62
+			$type         = 'CommentFound';
63
+			$fixmeMessage = trim($matches[1]);
64
+			$fixmeMessage = trim($fixmeMessage, '-:[](). ');
65
+			$error        = 'Comment refers to a FIXME task';
66
+			$data         = [$fixmeMessage];
67
+			if ($fixmeMessage !== '') {
68
+				$type   = 'TaskFound';
69
+				$error .= ' "%s"';
70
+			}
71 71
 
72
-            $phpcsFile->addError($error, $stackPtr, $type, $data);
73
-        }
72
+			$phpcsFile->addError($error, $stackPtr, $type, $data);
73
+		}
74 74
 
75
-    }//end process()
75
+	}//end process()
76 76
 
77 77
 
78 78
 }//end class
Please login to merge, or discard this patch.
php_codesniffer/src/Standards/Generic/Sniffs/Commenting/TodoSniff.php 1 patch
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -16,62 +16,62 @@
 block discarded – undo
16 16
 class TodoSniff implements Sniff
17 17
 {
18 18
 
19
-    /**
20
-     * A list of tokenizers this sniff supports.
21
-     *
22
-     * @var array
23
-     */
24
-    public $supportedTokenizers = [
25
-        'PHP',
26
-        'JS',
27
-    ];
19
+	/**
20
+	 * A list of tokenizers this sniff supports.
21
+	 *
22
+	 * @var array
23
+	 */
24
+	public $supportedTokenizers = [
25
+		'PHP',
26
+		'JS',
27
+	];
28 28
 
29 29
 
30
-    /**
31
-     * Returns an array of tokens this test wants to listen for.
32
-     *
33
-     * @return array
34
-     */
35
-    public function register()
36
-    {
37
-        return array_diff(Tokens::$commentTokens, Tokens::$phpcsCommentTokens);
30
+	/**
31
+	 * Returns an array of tokens this test wants to listen for.
32
+	 *
33
+	 * @return array
34
+	 */
35
+	public function register()
36
+	{
37
+		return array_diff(Tokens::$commentTokens, Tokens::$phpcsCommentTokens);
38 38
 
39
-    }//end register()
39
+	}//end register()
40 40
 
41 41
 
42
-    /**
43
-     * Processes this sniff, when one of its tokens is encountered.
44
-     *
45
-     * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
46
-     * @param int                         $stackPtr  The position of the current token
47
-     *                                               in the stack passed in $tokens.
48
-     *
49
-     * @return void
50
-     */
51
-    public function process(File $phpcsFile, $stackPtr)
52
-    {
53
-        $tokens = $phpcsFile->getTokens();
42
+	/**
43
+	 * Processes this sniff, when one of its tokens is encountered.
44
+	 *
45
+	 * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
46
+	 * @param int                         $stackPtr  The position of the current token
47
+	 *                                               in the stack passed in $tokens.
48
+	 *
49
+	 * @return void
50
+	 */
51
+	public function process(File $phpcsFile, $stackPtr)
52
+	{
53
+		$tokens = $phpcsFile->getTokens();
54 54
 
55
-        $content = $tokens[$stackPtr]['content'];
56
-        $matches = [];
57
-        preg_match('/(?:\A|[^\p{L}]+)todo([^\p{L}]+(.*)|\Z)/ui', $content, $matches);
58
-        if (empty($matches) === false) {
59
-            // Clear whitespace and some common characters not required at
60
-            // the end of a to-do message to make the warning more informative.
61
-            $type        = 'CommentFound';
62
-            $todoMessage = trim($matches[1]);
63
-            $todoMessage = trim($todoMessage, '-:[](). ');
64
-            $error       = 'Comment refers to a TODO task';
65
-            $data        = [$todoMessage];
66
-            if ($todoMessage !== '') {
67
-                $type   = 'TaskFound';
68
-                $error .= ' "%s"';
69
-            }
55
+		$content = $tokens[$stackPtr]['content'];
56
+		$matches = [];
57
+		preg_match('/(?:\A|[^\p{L}]+)todo([^\p{L}]+(.*)|\Z)/ui', $content, $matches);
58
+		if (empty($matches) === false) {
59
+			// Clear whitespace and some common characters not required at
60
+			// the end of a to-do message to make the warning more informative.
61
+			$type        = 'CommentFound';
62
+			$todoMessage = trim($matches[1]);
63
+			$todoMessage = trim($todoMessage, '-:[](). ');
64
+			$error       = 'Comment refers to a TODO task';
65
+			$data        = [$todoMessage];
66
+			if ($todoMessage !== '') {
67
+				$type   = 'TaskFound';
68
+				$error .= ' "%s"';
69
+			}
70 70
 
71
-            $phpcsFile->addWarning($error, $stackPtr, $type, $data);
72
-        }
71
+			$phpcsFile->addWarning($error, $stackPtr, $type, $data);
72
+		}
73 73
 
74
-    }//end process()
74
+	}//end process()
75 75
 
76 76
 
77 77
 }//end class
Please login to merge, or discard this patch.
php_codesniffer/src/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php 1 patch
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -16,85 +16,85 @@
 block discarded – undo
16 16
 class NestingLevelSniff implements Sniff
17 17
 {
18 18
 
19
-    /**
20
-     * A nesting level higher than this value will throw a warning.
21
-     *
22
-     * @var integer
23
-     */
24
-    public $nestingLevel = 5;
25
-
26
-    /**
27
-     * A nesting level higher than this value will throw an error.
28
-     *
29
-     * @var integer
30
-     */
31
-    public $absoluteNestingLevel = 10;
32
-
33
-
34
-    /**
35
-     * Returns an array of tokens this test wants to listen for.
36
-     *
37
-     * @return array
38
-     */
39
-    public function register()
40
-    {
41
-        return [T_FUNCTION];
42
-
43
-    }//end register()
44
-
45
-
46
-    /**
47
-     * Processes this test, when one of its tokens is encountered.
48
-     *
49
-     * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
50
-     * @param int                         $stackPtr  The position of the current token
51
-     *                                               in the stack passed in $tokens.
52
-     *
53
-     * @return void
54
-     */
55
-    public function process(File $phpcsFile, $stackPtr)
56
-    {
57
-        $tokens = $phpcsFile->getTokens();
58
-
59
-        // Ignore abstract methods.
60
-        if (isset($tokens[$stackPtr]['scope_opener']) === false) {
61
-            return;
62
-        }
63
-
64
-        // Detect start and end of this function definition.
65
-        $start = $tokens[$stackPtr]['scope_opener'];
66
-        $end   = $tokens[$stackPtr]['scope_closer'];
67
-
68
-        $nestingLevel = 0;
69
-
70
-        // Find the maximum nesting level of any token in the function.
71
-        for ($i = ($start + 1); $i < $end; $i++) {
72
-            $level = $tokens[$i]['level'];
73
-            if ($nestingLevel < $level) {
74
-                $nestingLevel = $level;
75
-            }
76
-        }
77
-
78
-        // We subtract the nesting level of the function itself.
79
-        $nestingLevel = ($nestingLevel - $tokens[$stackPtr]['level'] - 1);
80
-
81
-        if ($nestingLevel > $this->absoluteNestingLevel) {
82
-            $error = 'Function\'s nesting level (%s) exceeds allowed maximum of %s';
83
-            $data  = [
84
-                $nestingLevel,
85
-                $this->absoluteNestingLevel,
86
-            ];
87
-            $phpcsFile->addError($error, $stackPtr, 'MaxExceeded', $data);
88
-        } else if ($nestingLevel > $this->nestingLevel) {
89
-            $warning = 'Function\'s nesting level (%s) exceeds %s; consider refactoring the function';
90
-            $data    = [
91
-                $nestingLevel,
92
-                $this->nestingLevel,
93
-            ];
94
-            $phpcsFile->addWarning($warning, $stackPtr, 'TooHigh', $data);
95
-        }
96
-
97
-    }//end process()
19
+	/**
20
+	 * A nesting level higher than this value will throw a warning.
21
+	 *
22
+	 * @var integer
23
+	 */
24
+	public $nestingLevel = 5;
25
+
26
+	/**
27
+	 * A nesting level higher than this value will throw an error.
28
+	 *
29
+	 * @var integer
30
+	 */
31
+	public $absoluteNestingLevel = 10;
32
+
33
+
34
+	/**
35
+	 * Returns an array of tokens this test wants to listen for.
36
+	 *
37
+	 * @return array
38
+	 */
39
+	public function register()
40
+	{
41
+		return [T_FUNCTION];
42
+
43
+	}//end register()
44
+
45
+
46
+	/**
47
+	 * Processes this test, when one of its tokens is encountered.
48
+	 *
49
+	 * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
50
+	 * @param int                         $stackPtr  The position of the current token
51
+	 *                                               in the stack passed in $tokens.
52
+	 *
53
+	 * @return void
54
+	 */
55
+	public function process(File $phpcsFile, $stackPtr)
56
+	{
57
+		$tokens = $phpcsFile->getTokens();
58
+
59
+		// Ignore abstract methods.
60
+		if (isset($tokens[$stackPtr]['scope_opener']) === false) {
61
+			return;
62
+		}
63
+
64
+		// Detect start and end of this function definition.
65
+		$start = $tokens[$stackPtr]['scope_opener'];
66
+		$end   = $tokens[$stackPtr]['scope_closer'];
67
+
68
+		$nestingLevel = 0;
69
+
70
+		// Find the maximum nesting level of any token in the function.
71
+		for ($i = ($start + 1); $i < $end; $i++) {
72
+			$level = $tokens[$i]['level'];
73
+			if ($nestingLevel < $level) {
74
+				$nestingLevel = $level;
75
+			}
76
+		}
77
+
78
+		// We subtract the nesting level of the function itself.
79
+		$nestingLevel = ($nestingLevel - $tokens[$stackPtr]['level'] - 1);
80
+
81
+		if ($nestingLevel > $this->absoluteNestingLevel) {
82
+			$error = 'Function\'s nesting level (%s) exceeds allowed maximum of %s';
83
+			$data  = [
84
+				$nestingLevel,
85
+				$this->absoluteNestingLevel,
86
+			];
87
+			$phpcsFile->addError($error, $stackPtr, 'MaxExceeded', $data);
88
+		} else if ($nestingLevel > $this->nestingLevel) {
89
+			$warning = 'Function\'s nesting level (%s) exceeds %s; consider refactoring the function';
90
+			$data    = [
91
+				$nestingLevel,
92
+				$this->nestingLevel,
93
+			];
94
+			$phpcsFile->addWarning($warning, $stackPtr, 'TooHigh', $data);
95
+		}
96
+
97
+	}//end process()
98 98
 
99 99
 
100 100
 }//end class
Please login to merge, or discard this patch.
src/Standards/MySource/Tests/PHP/AjaxNullComparisonUnitTest.inc 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -25,13 +25,13 @@  discard block
 block discarded – undo
25 25
 public static function addIssue(
26 26
     $title,
27 27
     $description,
28
-    $reporter=NULL,
29
-    $projectid=NULL,
30
-    array $tags=array(),
31
-    $status=NULL,
32
-    $assignedTo=NULL,
33
-    $reportedDate=NULL,
34
-    $reportedMilestone=NULL
28
+    $reporter = NULL,
29
+    $projectid = NULL,
30
+    array $tags = array(),
31
+    $status = NULL,
32
+    $assignedTo = NULL,
33
+    $reportedDate = NULL,
34
+    $reportedMilestone = NULL
35 35
 ) {
36 36
     // Get current projectid if not specified.
37 37
     if ($projectid === NULL) {
@@ -160,13 +160,13 @@  discard block
 block discarded – undo
160 160
 public static function addIssue(
161 161
     $title,
162 162
     $description,
163
-    $reporter=NULL,
164
-    $projectid=NULL,
165
-    array $tags=array(),
166
-    $status=NULL,
167
-    $assignedTo=NULL,
168
-    $reportedDate=NULL,
169
-    $reportedMilestone=NULL
163
+    $reporter = NULL,
164
+    $projectid = NULL,
165
+    array $tags = array(),
166
+    $status = NULL,
167
+    $assignedTo = NULL,
168
+    $reportedDate = NULL,
169
+    $reportedMilestone = NULL
170 170
 ) {
171 171
     // Get current projectid if not specified.
172 172
     if ($projectid === NULL) {
Please login to merge, or discard this patch.
Indentation   +124 added lines, -124 removed lines patch added patch discarded remove patch
@@ -27,116 +27,116 @@  discard block
 block discarded – undo
27 27
  * @api-permission public
28 28
  */
29 29
 public static function addIssue(
30
-    $title,
31
-    $description,
32
-    $reporter=NULL,
33
-    $projectid=NULL,
34
-    array $tags=array(),
35
-    $status=NULL,
36
-    $assignedTo=NULL,
37
-    $reportedDate=NULL,
38
-    $reportedMilestone=NULL
30
+	$title,
31
+	$description,
32
+	$reporter=NULL,
33
+	$projectid=NULL,
34
+	array $tags=array(),
35
+	$status=NULL,
36
+	$assignedTo=NULL,
37
+	$reportedDate=NULL,
38
+	$reportedMilestone=NULL
39 39
 ) {
40
-    // Get current projectid if not specified.
41
-    if ($projectid === NULL) {
42
-        Channels::includeSystem('Project');
43
-        $projectid = Project::getCurrentProjectId();
44
-        Channels::modifyBasket('project', $projectid);
45
-    }
46
-
47
-    Channels::includeSystem('SquizRoadmap');
48
-    Channels::includeSystem('Permission');
49
-    if (Permission::hasPermission($projectid, 'ideas.contribute') === FALSE) {
50
-        throw new ChannelException(_('You do not have permission to contribute idea'));
51
-    }
52
-
53
-    if ($assignedTo !== NULL) {
54
-        if (Permission::hasPermission($projectid, 'ideas.edit.details') === FALSE) {
55
-            throw new ChannelException(_('You do not have permission to assign user to idea'));
56
-        }
57
-
58
-        if (SquizRoadmap::isVisibleProject($projectid, $assignedTo) === FALSE) {
59
-            throw new ChannelException(_('Assigned to user does not have access to issue project.'));
60
-        }
61
-    }
62
-
63
-    // Get current user id if not specified.
64
-    if ($reporter === NULL) {
65
-        Channels::includeSystem('User');
66
-        $reporter = User::getCurrentUserid();
67
-        Channels::modifyBasket('reporter', $reporter);
68
-    }
69
-
70
-    if (SquizRoadmap::isVisibleProject($projectid, $reporter) === FALSE) {
71
-        throw new ChannelException(_('Contributed by user does not have access to issue project.'));
72
-    }
73
-
74
-    // Make sure status is valid.
75
-    Channels::includeSystem('SquizRoadmap');
76
-    Channels::includeSystem('SquizRoadmapStatus');
77
-    if ($status === NULL) {
78
-        $statuses = SquizRoadmapStatus::getStatus($projectid);
79
-        if (empty($statuses) === TRUE) {
80
-            throw new ChannelException(_('No defined statuses in project'));
81
-        }
82
-
83
-        $status = $statuses[0]['status'];
84
-        Channels::modifyBasket('status', $status);
85
-    } else if (SquizRoadmapStatus::isValidStatus($projectid, $status) === FALSE) {
86
-        throw new ChannelException(sprintf(_('Invalid status: %s'), $status));
87
-    }
88
-
89
-    $issueid = DAL::seqNextVal('sq_rdm_issue_seq');
90
-    Channels::addToBasket('issueid', $issueid);
91
-
92
-    if ($reportedDate === NULL) {
93
-        include_once 'Libs/String/String.inc';
94
-        $reportedDate = String::tsIso8601(time());
95
-        Channels::modifyBasket('reportedDate', $reportedDate);
96
-    }
97
-
98
-    $title = trim($title);
99
-    Channels::modifyBasket('title', $title);
100
-    if (empty($title) === TRUE) {
101
-        throw new ChannelException(_('Title cannot be empty'));
102
-    }
103
-
104
-    $description = SquizRoadmap::stripTags(trim($description));
105
-    Channels::modifyBasket('description', $description);
106
-    if (empty($description) === TRUE) {
107
-        throw new ChannelException(_('Description cannot be empty'));
108
-    }
109
-
110
-    try {
111
-        DAL::beginTransaction();
112
-
113
-        $query = DAL::getDALQuery('SquizRoadmapIssue', 'addIssue');
114
-        DAL::executeQuery($query);
115
-
116
-        // Add tags for the new issue.
117
-        SquizRoadmapIssue::addIssueTags($issueid, $tags);
118
-
119
-        // Add reporter and assignee to watch list.
120
-        SquizRoadmapIssue::addIssueWatch($issueid, $reporter);
121
-
122
-        if ($assignedTo !== NULL) {
123
-            SquizRoadmapIssue::addIssueWatch($issueid, $assignedTo);
124
-        }
125
-
126
-        SquizRoadmapIssue::clearIssueCache($issueid);
127
-
128
-        DAL::commit();
129
-    } catch (Exception $e) {
130
-        DAL::rollBack();
131
-        throw new ChannelException($e->getMessage());
132
-    }//end try
133
-
134
-    if ($something === NULL) {
135
-        if ($bar !== NULL) {
136
-        }
137
-    }
138
-
139
-    return $issueid;
40
+	// Get current projectid if not specified.
41
+	if ($projectid === NULL) {
42
+		Channels::includeSystem('Project');
43
+		$projectid = Project::getCurrentProjectId();
44
+		Channels::modifyBasket('project', $projectid);
45
+	}
46
+
47
+	Channels::includeSystem('SquizRoadmap');
48
+	Channels::includeSystem('Permission');
49
+	if (Permission::hasPermission($projectid, 'ideas.contribute') === FALSE) {
50
+		throw new ChannelException(_('You do not have permission to contribute idea'));
51
+	}
52
+
53
+	if ($assignedTo !== NULL) {
54
+		if (Permission::hasPermission($projectid, 'ideas.edit.details') === FALSE) {
55
+			throw new ChannelException(_('You do not have permission to assign user to idea'));
56
+		}
57
+
58
+		if (SquizRoadmap::isVisibleProject($projectid, $assignedTo) === FALSE) {
59
+			throw new ChannelException(_('Assigned to user does not have access to issue project.'));
60
+		}
61
+	}
62
+
63
+	// Get current user id if not specified.
64
+	if ($reporter === NULL) {
65
+		Channels::includeSystem('User');
66
+		$reporter = User::getCurrentUserid();
67
+		Channels::modifyBasket('reporter', $reporter);
68
+	}
69
+
70
+	if (SquizRoadmap::isVisibleProject($projectid, $reporter) === FALSE) {
71
+		throw new ChannelException(_('Contributed by user does not have access to issue project.'));
72
+	}
73
+
74
+	// Make sure status is valid.
75
+	Channels::includeSystem('SquizRoadmap');
76
+	Channels::includeSystem('SquizRoadmapStatus');
77
+	if ($status === NULL) {
78
+		$statuses = SquizRoadmapStatus::getStatus($projectid);
79
+		if (empty($statuses) === TRUE) {
80
+			throw new ChannelException(_('No defined statuses in project'));
81
+		}
82
+
83
+		$status = $statuses[0]['status'];
84
+		Channels::modifyBasket('status', $status);
85
+	} else if (SquizRoadmapStatus::isValidStatus($projectid, $status) === FALSE) {
86
+		throw new ChannelException(sprintf(_('Invalid status: %s'), $status));
87
+	}
88
+
89
+	$issueid = DAL::seqNextVal('sq_rdm_issue_seq');
90
+	Channels::addToBasket('issueid', $issueid);
91
+
92
+	if ($reportedDate === NULL) {
93
+		include_once 'Libs/String/String.inc';
94
+		$reportedDate = String::tsIso8601(time());
95
+		Channels::modifyBasket('reportedDate', $reportedDate);
96
+	}
97
+
98
+	$title = trim($title);
99
+	Channels::modifyBasket('title', $title);
100
+	if (empty($title) === TRUE) {
101
+		throw new ChannelException(_('Title cannot be empty'));
102
+	}
103
+
104
+	$description = SquizRoadmap::stripTags(trim($description));
105
+	Channels::modifyBasket('description', $description);
106
+	if (empty($description) === TRUE) {
107
+		throw new ChannelException(_('Description cannot be empty'));
108
+	}
109
+
110
+	try {
111
+		DAL::beginTransaction();
112
+
113
+		$query = DAL::getDALQuery('SquizRoadmapIssue', 'addIssue');
114
+		DAL::executeQuery($query);
115
+
116
+		// Add tags for the new issue.
117
+		SquizRoadmapIssue::addIssueTags($issueid, $tags);
118
+
119
+		// Add reporter and assignee to watch list.
120
+		SquizRoadmapIssue::addIssueWatch($issueid, $reporter);
121
+
122
+		if ($assignedTo !== NULL) {
123
+			SquizRoadmapIssue::addIssueWatch($issueid, $assignedTo);
124
+		}
125
+
126
+		SquizRoadmapIssue::clearIssueCache($issueid);
127
+
128
+		DAL::commit();
129
+	} catch (Exception $e) {
130
+		DAL::rollBack();
131
+		throw new ChannelException($e->getMessage());
132
+	}//end try
133
+
134
+	if ($something === NULL) {
135
+		if ($bar !== NULL) {
136
+		}
137
+	}
138
+
139
+	return $issueid;
140 140
 
141 141
 }//end addIssue()
142 142
 
@@ -162,21 +162,21 @@  discard block
 block discarded – undo
162 162
  *
163 163
  */
164 164
 public static function addIssue(
165
-    $title,
166
-    $description,
167
-    $reporter=NULL,
168
-    $projectid=NULL,
169
-    array $tags=array(),
170
-    $status=NULL,
171
-    $assignedTo=NULL,
172
-    $reportedDate=NULL,
173
-    $reportedMilestone=NULL
165
+	$title,
166
+	$description,
167
+	$reporter=NULL,
168
+	$projectid=NULL,
169
+	array $tags=array(),
170
+	$status=NULL,
171
+	$assignedTo=NULL,
172
+	$reportedDate=NULL,
173
+	$reportedMilestone=NULL
174 174
 ) {
175
-    // Get current projectid if not specified.
176
-    if ($projectid === NULL) {
177
-        Channels::includeSystem('Project');
178
-        $projectid = Project::getCurrentProjectId();
179
-        Channels::modifyBasket('project', $projectid);
180
-    }
175
+	// Get current projectid if not specified.
176
+	if ($projectid === NULL) {
177
+		Channels::includeSystem('Project');
178
+		$projectid = Project::getCurrentProjectId();
179
+		Channels::modifyBasket('project', $projectid);
180
+	}
181 181
 
182 182
 }//end addIssue()
Please login to merge, or discard this patch.
src/Standards/MySource/Tests/PHP/EvalObjectFactoryUnitTest.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -15,38 +15,38 @@
 block discarded – undo
15 15
 {
16 16
 
17 17
 
18
-    /**
19
-     * Returns the lines where errors should occur.
20
-     *
21
-     * The key of the array should represent the line number and the value
22
-     * should represent the number of errors that should occur on that line.
23
-     *
24
-     * @return array<int, int>
25
-     */
26
-    public function getErrorList()
27
-    {
28
-        return [];
29
-
30
-    }//end getErrorList()
31
-
32
-
33
-    /**
34
-     * Returns the lines where warnings should occur.
35
-     *
36
-     * The key of the array should represent the line number and the value
37
-     * should represent the number of warnings that should occur on that line.
38
-     *
39
-     * @return array<int, int>
40
-     */
41
-    public function getWarningList()
42
-    {
43
-        return [
44
-            4  => 1,
45
-            12 => 1,
46
-            21 => 1,
47
-        ];
48
-
49
-    }//end getWarningList()
18
+	/**
19
+	 * Returns the lines where errors should occur.
20
+	 *
21
+	 * The key of the array should represent the line number and the value
22
+	 * should represent the number of errors that should occur on that line.
23
+	 *
24
+	 * @return array<int, int>
25
+	 */
26
+	public function getErrorList()
27
+	{
28
+		return [];
29
+
30
+	}//end getErrorList()
31
+
32
+
33
+	/**
34
+	 * Returns the lines where warnings should occur.
35
+	 *
36
+	 * The key of the array should represent the line number and the value
37
+	 * should represent the number of warnings that should occur on that line.
38
+	 *
39
+	 * @return array<int, int>
40
+	 */
41
+	public function getWarningList()
42
+	{
43
+		return [
44
+			4  => 1,
45
+			12 => 1,
46
+			21 => 1,
47
+		];
48
+
49
+	}//end getWarningList()
50 50
 
51 51
 
52 52
 }//end class
Please login to merge, or discard this patch.