Completed
Pull Request — develop (#1492)
by Zack
28:58 queued 09:00
created
Sniffs/FunctionDeclarations/ForbiddenVariableNamesInClosureUseSniff.php 4 patches
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -31,88 +31,88 @@
 block discarded – undo
31 31
 class ForbiddenVariableNamesInClosureUseSniff extends Sniff
32 32
 {
33 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 array(\T_USE);
42
-    }
43
-
44
-    /**
45
-     * Processes this test, when one of its tokens is encountered.
46
-     *
47
-     * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
48
-     * @param int                   $stackPtr  The position of the current token
49
-     *                                         in the stack passed in $tokens.
50
-     *
51
-     * @return void
52
-     */
53
-    public function process(File $phpcsFile, $stackPtr)
54
-    {
55
-        if ($this->supportsAbove('7.1') === false) {
56
-            return;
57
-        }
58
-
59
-        $tokens = $phpcsFile->getTokens();
60
-
61
-        // Verify this use statement is used with a closure - if so, it has to have parenthesis before it.
62
-        $previousNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true, null, true);
63
-        if ($previousNonEmpty === false || $tokens[$previousNonEmpty]['code'] !== \T_CLOSE_PARENTHESIS
64
-            || isset($tokens[$previousNonEmpty]['parenthesis_opener']) === false
65
-        ) {
66
-            return;
67
-        }
68
-
69
-        // ... and (a variable within) parenthesis after it.
70
-        $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true, null, true);
71
-        if ($nextNonEmpty === false || $tokens[$nextNonEmpty]['code'] !== \T_OPEN_PARENTHESIS) {
72
-            return;
73
-        }
74
-
75
-        if (isset($tokens[$nextNonEmpty]['parenthesis_closer']) === false) {
76
-            // Live coding.
77
-            return;
78
-        }
79
-
80
-        $closurePtr = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($tokens[$previousNonEmpty]['parenthesis_opener'] - 1), null, true);
81
-        if ($closurePtr === false || $tokens[$closurePtr]['code'] !== \T_CLOSURE) {
82
-            return;
83
-        }
84
-
85
-        // Get the parameters declared by the closure.
86
-        $closureParams = PHPCSHelper::getMethodParameters($phpcsFile, $closurePtr);
87
-
88
-        $errorMsg = 'Variables bound to a closure via the use construct cannot use the same name as superglobals, $this, or a declared parameter since PHP 7.1. Found: %s';
89
-
90
-        for ($i = ($nextNonEmpty + 1); $i < $tokens[$nextNonEmpty]['parenthesis_closer']; $i++) {
91
-            if ($tokens[$i]['code'] !== \T_VARIABLE) {
92
-                continue;
93
-            }
94
-
95
-            $variableName = $tokens[$i]['content'];
96
-
97
-            if ($variableName === '$this') {
98
-                $phpcsFile->addError($errorMsg, $i, 'FoundThis', array($variableName));
99
-                continue;
100
-            }
101
-
102
-            if (isset($this->superglobals[$variableName]) === true) {
103
-                $phpcsFile->addError($errorMsg, $i, 'FoundSuperglobal', array($variableName));
104
-                continue;
105
-            }
106
-
107
-            // Check whether it is one of the parameters declared by the closure.
108
-            if (empty($closureParams) === false) {
109
-                foreach ($closureParams as $param) {
110
-                    if ($param['name'] === $variableName) {
111
-                        $phpcsFile->addError($errorMsg, $i, 'FoundShadowParam', array($variableName));
112
-                        continue 2;
113
-                    }
114
-                }
115
-            }
116
-        }
117
-    }
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 array(\T_USE);
42
+	}
43
+
44
+	/**
45
+	 * Processes this test, when one of its tokens is encountered.
46
+	 *
47
+	 * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
48
+	 * @param int                   $stackPtr  The position of the current token
49
+	 *                                         in the stack passed in $tokens.
50
+	 *
51
+	 * @return void
52
+	 */
53
+	public function process(File $phpcsFile, $stackPtr)
54
+	{
55
+		if ($this->supportsAbove('7.1') === false) {
56
+			return;
57
+		}
58
+
59
+		$tokens = $phpcsFile->getTokens();
60
+
61
+		// Verify this use statement is used with a closure - if so, it has to have parenthesis before it.
62
+		$previousNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true, null, true);
63
+		if ($previousNonEmpty === false || $tokens[$previousNonEmpty]['code'] !== \T_CLOSE_PARENTHESIS
64
+			|| isset($tokens[$previousNonEmpty]['parenthesis_opener']) === false
65
+		) {
66
+			return;
67
+		}
68
+
69
+		// ... and (a variable within) parenthesis after it.
70
+		$nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true, null, true);
71
+		if ($nextNonEmpty === false || $tokens[$nextNonEmpty]['code'] !== \T_OPEN_PARENTHESIS) {
72
+			return;
73
+		}
74
+
75
+		if (isset($tokens[$nextNonEmpty]['parenthesis_closer']) === false) {
76
+			// Live coding.
77
+			return;
78
+		}
79
+
80
+		$closurePtr = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($tokens[$previousNonEmpty]['parenthesis_opener'] - 1), null, true);
81
+		if ($closurePtr === false || $tokens[$closurePtr]['code'] !== \T_CLOSURE) {
82
+			return;
83
+		}
84
+
85
+		// Get the parameters declared by the closure.
86
+		$closureParams = PHPCSHelper::getMethodParameters($phpcsFile, $closurePtr);
87
+
88
+		$errorMsg = 'Variables bound to a closure via the use construct cannot use the same name as superglobals, $this, or a declared parameter since PHP 7.1. Found: %s';
89
+
90
+		for ($i = ($nextNonEmpty + 1); $i < $tokens[$nextNonEmpty]['parenthesis_closer']; $i++) {
91
+			if ($tokens[$i]['code'] !== \T_VARIABLE) {
92
+				continue;
93
+			}
94
+
95
+			$variableName = $tokens[$i]['content'];
96
+
97
+			if ($variableName === '$this') {
98
+				$phpcsFile->addError($errorMsg, $i, 'FoundThis', array($variableName));
99
+				continue;
100
+			}
101
+
102
+			if (isset($this->superglobals[$variableName]) === true) {
103
+				$phpcsFile->addError($errorMsg, $i, 'FoundSuperglobal', array($variableName));
104
+				continue;
105
+			}
106
+
107
+			// Check whether it is one of the parameters declared by the closure.
108
+			if (empty($closureParams) === false) {
109
+				foreach ($closureParams as $param) {
110
+					if ($param['name'] === $variableName) {
111
+						$phpcsFile->addError($errorMsg, $i, 'FoundShadowParam', array($variableName));
112
+						continue 2;
113
+					}
114
+				}
115
+			}
116
+		}
117
+	}
118 118
 }
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
      */
39 39
     public function register()
40 40
     {
41
-        return array(\T_USE);
41
+        return array( \T_USE );
42 42
     }
43 43
 
44 44
     /**
@@ -50,65 +50,65 @@  discard block
 block discarded – undo
50 50
      *
51 51
      * @return void
52 52
      */
53
-    public function process(File $phpcsFile, $stackPtr)
53
+    public function process( File $phpcsFile, $stackPtr )
54 54
     {
55
-        if ($this->supportsAbove('7.1') === false) {
55
+        if ( $this->supportsAbove( '7.1' ) === false ) {
56 56
             return;
57 57
         }
58 58
 
59 59
         $tokens = $phpcsFile->getTokens();
60 60
 
61 61
         // Verify this use statement is used with a closure - if so, it has to have parenthesis before it.
62
-        $previousNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true, null, true);
63
-        if ($previousNonEmpty === false || $tokens[$previousNonEmpty]['code'] !== \T_CLOSE_PARENTHESIS
64
-            || isset($tokens[$previousNonEmpty]['parenthesis_opener']) === false
62
+        $previousNonEmpty = $phpcsFile->findPrevious( Tokens::$emptyTokens, ( $stackPtr - 1 ), null, true, null, true );
63
+        if ( $previousNonEmpty === false || $tokens[ $previousNonEmpty ][ 'code' ] !== \T_CLOSE_PARENTHESIS
64
+            || isset( $tokens[ $previousNonEmpty ][ 'parenthesis_opener' ] ) === false
65 65
         ) {
66 66
             return;
67 67
         }
68 68
 
69 69
         // ... and (a variable within) parenthesis after it.
70
-        $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true, null, true);
71
-        if ($nextNonEmpty === false || $tokens[$nextNonEmpty]['code'] !== \T_OPEN_PARENTHESIS) {
70
+        $nextNonEmpty = $phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true, null, true );
71
+        if ( $nextNonEmpty === false || $tokens[ $nextNonEmpty ][ 'code' ] !== \T_OPEN_PARENTHESIS ) {
72 72
             return;
73 73
         }
74 74
 
75
-        if (isset($tokens[$nextNonEmpty]['parenthesis_closer']) === false) {
75
+        if ( isset( $tokens[ $nextNonEmpty ][ 'parenthesis_closer' ] ) === false ) {
76 76
             // Live coding.
77 77
             return;
78 78
         }
79 79
 
80
-        $closurePtr = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($tokens[$previousNonEmpty]['parenthesis_opener'] - 1), null, true);
81
-        if ($closurePtr === false || $tokens[$closurePtr]['code'] !== \T_CLOSURE) {
80
+        $closurePtr = $phpcsFile->findPrevious( Tokens::$emptyTokens, ( $tokens[ $previousNonEmpty ][ 'parenthesis_opener' ] - 1 ), null, true );
81
+        if ( $closurePtr === false || $tokens[ $closurePtr ][ 'code' ] !== \T_CLOSURE ) {
82 82
             return;
83 83
         }
84 84
 
85 85
         // Get the parameters declared by the closure.
86
-        $closureParams = PHPCSHelper::getMethodParameters($phpcsFile, $closurePtr);
86
+        $closureParams = PHPCSHelper::getMethodParameters( $phpcsFile, $closurePtr );
87 87
 
88 88
         $errorMsg = 'Variables bound to a closure via the use construct cannot use the same name as superglobals, $this, or a declared parameter since PHP 7.1. Found: %s';
89 89
 
90
-        for ($i = ($nextNonEmpty + 1); $i < $tokens[$nextNonEmpty]['parenthesis_closer']; $i++) {
91
-            if ($tokens[$i]['code'] !== \T_VARIABLE) {
90
+        for ( $i = ( $nextNonEmpty + 1 ); $i < $tokens[ $nextNonEmpty ][ 'parenthesis_closer' ]; $i++ ) {
91
+            if ( $tokens[ $i ][ 'code' ] !== \T_VARIABLE ) {
92 92
                 continue;
93 93
             }
94 94
 
95
-            $variableName = $tokens[$i]['content'];
95
+            $variableName = $tokens[ $i ][ 'content' ];
96 96
 
97
-            if ($variableName === '$this') {
98
-                $phpcsFile->addError($errorMsg, $i, 'FoundThis', array($variableName));
97
+            if ( $variableName === '$this' ) {
98
+                $phpcsFile->addError( $errorMsg, $i, 'FoundThis', array( $variableName ) );
99 99
                 continue;
100 100
             }
101 101
 
102
-            if (isset($this->superglobals[$variableName]) === true) {
103
-                $phpcsFile->addError($errorMsg, $i, 'FoundSuperglobal', array($variableName));
102
+            if ( isset( $this->superglobals[ $variableName ] ) === true ) {
103
+                $phpcsFile->addError( $errorMsg, $i, 'FoundSuperglobal', array( $variableName ) );
104 104
                 continue;
105 105
             }
106 106
 
107 107
             // Check whether it is one of the parameters declared by the closure.
108
-            if (empty($closureParams) === false) {
109
-                foreach ($closureParams as $param) {
110
-                    if ($param['name'] === $variableName) {
111
-                        $phpcsFile->addError($errorMsg, $i, 'FoundShadowParam', array($variableName));
108
+            if ( empty( $closureParams ) === false ) {
109
+                foreach ( $closureParams as $param ) {
110
+                    if ( $param[ 'name' ] === $variableName ) {
111
+                        $phpcsFile->addError( $errorMsg, $i, 'FoundShadowParam', array( $variableName ) );
112 112
                         continue 2;
113 113
                     }
114 114
                 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -28,16 +28,14 @@  discard block
 block discarded – undo
28 28
  * @package  PHPCompatibility
29 29
  * @author   Juliette Reinders Folmer <[email protected]>
30 30
  */
31
-class ForbiddenVariableNamesInClosureUseSniff extends Sniff
32
-{
31
+class ForbiddenVariableNamesInClosureUseSniff extends Sniff {
33 32
 
34 33
     /**
35 34
      * Returns an array of tokens this test wants to listen for.
36 35
      *
37 36
      * @return array
38 37
      */
39
-    public function register()
40
-    {
38
+    public function register() {
41 39
         return array(\T_USE);
42 40
     }
43 41
 
@@ -50,8 +48,7 @@  discard block
 block discarded – undo
50 48
      *
51 49
      * @return void
52 50
      */
53
-    public function process(File $phpcsFile, $stackPtr)
54
-    {
51
+    public function process(File $phpcsFile, $stackPtr) {
55 52
         if ($this->supportsAbove('7.1') === false) {
56 53
             return;
57 54
         }
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@
 block discarded – undo
65 65
     /**
66 66
      * Returns an array of tokens this test wants to listen for.
67 67
      *
68
-     * @return array
68
+     * @return integer[]
69 69
      */
70 70
     public function register()
71 71
     {
Please login to merge, or discard this patch.
Sniffs/FunctionDeclarations/ForbiddenParameterShadowSuperGlobalsSniff.php 3 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -33,47 +33,47 @@
 block discarded – undo
33 33
 class ForbiddenParameterShadowSuperGlobalsSniff extends Sniff
34 34
 {
35 35
 
36
-    /**
37
-     * Register the tokens to listen for.
38
-     *
39
-     * @return array
40
-     */
41
-    public function register()
42
-    {
43
-        return array(
44
-            \T_FUNCTION,
45
-            \T_CLOSURE,
46
-        );
47
-    }
36
+	/**
37
+	 * Register the tokens to listen for.
38
+	 *
39
+	 * @return array
40
+	 */
41
+	public function register()
42
+	{
43
+		return array(
44
+			\T_FUNCTION,
45
+			\T_CLOSURE,
46
+		);
47
+	}
48 48
 
49
-    /**
50
-     * Processes the test.
51
-     *
52
-     * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
53
-     * @param int                   $stackPtr  The position of the current token.
54
-     *
55
-     * @return void
56
-     */
57
-    public function process(File $phpcsFile, $stackPtr)
58
-    {
59
-        if ($this->supportsAbove('5.4') === false) {
60
-            return;
61
-        }
49
+	/**
50
+	 * Processes the test.
51
+	 *
52
+	 * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
53
+	 * @param int                   $stackPtr  The position of the current token.
54
+	 *
55
+	 * @return void
56
+	 */
57
+	public function process(File $phpcsFile, $stackPtr)
58
+	{
59
+		if ($this->supportsAbove('5.4') === false) {
60
+			return;
61
+		}
62 62
 
63
-        // Get all parameters from function signature.
64
-        $parameters = PHPCSHelper::getMethodParameters($phpcsFile, $stackPtr);
65
-        if (empty($parameters) || \is_array($parameters) === false) {
66
-            return;
67
-        }
63
+		// Get all parameters from function signature.
64
+		$parameters = PHPCSHelper::getMethodParameters($phpcsFile, $stackPtr);
65
+		if (empty($parameters) || \is_array($parameters) === false) {
66
+			return;
67
+		}
68 68
 
69
-        foreach ($parameters as $param) {
70
-            if (isset($this->superglobals[$param['name']]) === true) {
71
-                $error     = 'Parameter shadowing super global (%s) causes fatal error since PHP 5.4';
72
-                $errorCode = $this->stringToErrorCode(substr($param['name'], 1)) . 'Found';
73
-                $data      = array($param['name']);
69
+		foreach ($parameters as $param) {
70
+			if (isset($this->superglobals[$param['name']]) === true) {
71
+				$error     = 'Parameter shadowing super global (%s) causes fatal error since PHP 5.4';
72
+				$errorCode = $this->stringToErrorCode(substr($param['name'], 1)) . 'Found';
73
+				$data      = array($param['name']);
74 74
 
75
-                $phpcsFile->addError($error, $param['token'], $errorCode, $data);
76
-            }
77
-        }
78
-    }
75
+				$phpcsFile->addError($error, $param['token'], $errorCode, $data);
76
+			}
77
+		}
78
+	}
79 79
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -54,25 +54,25 @@
 block discarded – undo
54 54
      *
55 55
      * @return void
56 56
      */
57
-    public function process(File $phpcsFile, $stackPtr)
57
+    public function process( File $phpcsFile, $stackPtr )
58 58
     {
59
-        if ($this->supportsAbove('5.4') === false) {
59
+        if ( $this->supportsAbove( '5.4' ) === false ) {
60 60
             return;
61 61
         }
62 62
 
63 63
         // Get all parameters from function signature.
64
-        $parameters = PHPCSHelper::getMethodParameters($phpcsFile, $stackPtr);
65
-        if (empty($parameters) || \is_array($parameters) === false) {
64
+        $parameters = PHPCSHelper::getMethodParameters( $phpcsFile, $stackPtr );
65
+        if ( empty( $parameters ) || \is_array( $parameters ) === false ) {
66 66
             return;
67 67
         }
68 68
 
69
-        foreach ($parameters as $param) {
70
-            if (isset($this->superglobals[$param['name']]) === true) {
69
+        foreach ( $parameters as $param ) {
70
+            if ( isset( $this->superglobals[ $param[ 'name' ] ] ) === true ) {
71 71
                 $error     = 'Parameter shadowing super global (%s) causes fatal error since PHP 5.4';
72
-                $errorCode = $this->stringToErrorCode(substr($param['name'], 1)) . 'Found';
73
-                $data      = array($param['name']);
72
+                $errorCode = $this->stringToErrorCode( substr( $param[ 'name' ], 1 ) ) . 'Found';
73
+                $data      = array( $param[ 'name' ] );
74 74
 
75
-                $phpcsFile->addError($error, $param['token'], $errorCode, $data);
75
+                $phpcsFile->addError( $error, $param[ 'token' ], $errorCode, $data );
76 76
             }
77 77
         }
78 78
     }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -30,16 +30,14 @@  discard block
 block discarded – undo
30 30
  * @author    Declan Kelly <[email protected]>
31 31
  * @copyright 2015 Declan Kelly
32 32
  */
33
-class ForbiddenParameterShadowSuperGlobalsSniff extends Sniff
34
-{
33
+class ForbiddenParameterShadowSuperGlobalsSniff extends Sniff {
35 34
 
36 35
     /**
37 36
      * Register the tokens to listen for.
38 37
      *
39 38
      * @return array
40 39
      */
41
-    public function register()
42
-    {
40
+    public function register() {
43 41
         return array(
44 42
             \T_FUNCTION,
45 43
             \T_CLOSURE,
@@ -54,8 +52,7 @@  discard block
 block discarded – undo
54 52
      *
55 53
      * @return void
56 54
      */
57
-    public function process(File $phpcsFile, $stackPtr)
58
-    {
55
+    public function process(File $phpcsFile, $stackPtr) {
59 56
         if ($this->supportsAbove('5.4') === false) {
60 57
             return;
61 58
         }
Please login to merge, or discard this patch.
Sniffs/FunctionDeclarations/ForbiddenParametersWithSameNameSniff.php 3 patches
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -29,58 +29,58 @@
 block discarded – undo
29 29
 class ForbiddenParametersWithSameNameSniff extends Sniff
30 30
 {
31 31
 
32
-    /**
33
-     * Returns an array of tokens this test wants to listen for.
34
-     *
35
-     * @return array
36
-     */
37
-    public function register()
38
-    {
39
-        return array(
40
-            \T_FUNCTION,
41
-            \T_CLOSURE,
42
-        );
43
-    }
32
+	/**
33
+	 * Returns an array of tokens this test wants to listen for.
34
+	 *
35
+	 * @return array
36
+	 */
37
+	public function register()
38
+	{
39
+		return array(
40
+			\T_FUNCTION,
41
+			\T_CLOSURE,
42
+		);
43
+	}
44 44
 
45
-    /**
46
-     * Processes this test, when one of its tokens is encountered.
47
-     *
48
-     * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
49
-     * @param int                   $stackPtr  The position of the current token
50
-     *                                         in the stack passed in $tokens.
51
-     *
52
-     * @return void
53
-     */
54
-    public function process(File $phpcsFile, $stackPtr)
55
-    {
56
-        if ($this->supportsAbove('7.0') === false) {
57
-            return;
58
-        }
45
+	/**
46
+	 * Processes this test, when one of its tokens is encountered.
47
+	 *
48
+	 * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
49
+	 * @param int                   $stackPtr  The position of the current token
50
+	 *                                         in the stack passed in $tokens.
51
+	 *
52
+	 * @return void
53
+	 */
54
+	public function process(File $phpcsFile, $stackPtr)
55
+	{
56
+		if ($this->supportsAbove('7.0') === false) {
57
+			return;
58
+		}
59 59
 
60
-        $tokens = $phpcsFile->getTokens();
61
-        $token  = $tokens[$stackPtr];
62
-        // Skip function without body.
63
-        if (isset($token['scope_opener']) === false) {
64
-            return;
65
-        }
60
+		$tokens = $phpcsFile->getTokens();
61
+		$token  = $tokens[$stackPtr];
62
+		// Skip function without body.
63
+		if (isset($token['scope_opener']) === false) {
64
+			return;
65
+		}
66 66
 
67
-        // Get all parameters from method signature.
68
-        $parameters = PHPCSHelper::getMethodParameters($phpcsFile, $stackPtr);
69
-        if (empty($parameters) || \is_array($parameters) === false) {
70
-            return;
71
-        }
67
+		// Get all parameters from method signature.
68
+		$parameters = PHPCSHelper::getMethodParameters($phpcsFile, $stackPtr);
69
+		if (empty($parameters) || \is_array($parameters) === false) {
70
+			return;
71
+		}
72 72
 
73
-        $paramNames = array();
74
-        foreach ($parameters as $param) {
75
-            $paramNames[] = strtolower($param['name']);
76
-        }
73
+		$paramNames = array();
74
+		foreach ($parameters as $param) {
75
+			$paramNames[] = strtolower($param['name']);
76
+		}
77 77
 
78
-        if (\count($paramNames) !== \count(array_unique($paramNames))) {
79
-            $phpcsFile->addError(
80
-                'Functions can not have multiple parameters with the same name since PHP 7.0',
81
-                $stackPtr,
82
-                'Found'
83
-            );
84
-        }
85
-    }
78
+		if (\count($paramNames) !== \count(array_unique($paramNames))) {
79
+			$phpcsFile->addError(
80
+				'Functions can not have multiple parameters with the same name since PHP 7.0',
81
+				$stackPtr,
82
+				'Found'
83
+			);
84
+		}
85
+	}
86 86
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -51,31 +51,31 @@
 block discarded – undo
51 51
      *
52 52
      * @return void
53 53
      */
54
-    public function process(File $phpcsFile, $stackPtr)
54
+    public function process( File $phpcsFile, $stackPtr )
55 55
     {
56
-        if ($this->supportsAbove('7.0') === false) {
56
+        if ( $this->supportsAbove( '7.0' ) === false ) {
57 57
             return;
58 58
         }
59 59
 
60 60
         $tokens = $phpcsFile->getTokens();
61
-        $token  = $tokens[$stackPtr];
61
+        $token  = $tokens[ $stackPtr ];
62 62
         // Skip function without body.
63
-        if (isset($token['scope_opener']) === false) {
63
+        if ( isset( $token[ 'scope_opener' ] ) === false ) {
64 64
             return;
65 65
         }
66 66
 
67 67
         // Get all parameters from method signature.
68
-        $parameters = PHPCSHelper::getMethodParameters($phpcsFile, $stackPtr);
69
-        if (empty($parameters) || \is_array($parameters) === false) {
68
+        $parameters = PHPCSHelper::getMethodParameters( $phpcsFile, $stackPtr );
69
+        if ( empty( $parameters ) || \is_array( $parameters ) === false ) {
70 70
             return;
71 71
         }
72 72
 
73 73
         $paramNames = array();
74
-        foreach ($parameters as $param) {
75
-            $paramNames[] = strtolower($param['name']);
74
+        foreach ( $parameters as $param ) {
75
+            $paramNames[ ] = strtolower( $param[ 'name' ] );
76 76
         }
77 77
 
78
-        if (\count($paramNames) !== \count(array_unique($paramNames))) {
78
+        if ( \count( $paramNames ) !== \count( array_unique( $paramNames ) ) ) {
79 79
             $phpcsFile->addError(
80 80
                 'Functions can not have multiple parameters with the same name since PHP 7.0',
81 81
                 $stackPtr,
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -26,16 +26,14 @@  discard block
 block discarded – undo
26 26
  * @package  PHPCompatibility
27 27
  * @author   Wim Godden <[email protected]>
28 28
  */
29
-class ForbiddenParametersWithSameNameSniff extends Sniff
30
-{
29
+class ForbiddenParametersWithSameNameSniff extends Sniff {
31 30
 
32 31
     /**
33 32
      * Returns an array of tokens this test wants to listen for.
34 33
      *
35 34
      * @return array
36 35
      */
37
-    public function register()
38
-    {
36
+    public function register() {
39 37
         return array(
40 38
             \T_FUNCTION,
41 39
             \T_CLOSURE,
@@ -51,8 +49,7 @@  discard block
 block discarded – undo
51 49
      *
52 50
      * @return void
53 51
      */
54
-    public function process(File $phpcsFile, $stackPtr)
55
-    {
52
+    public function process(File $phpcsFile, $stackPtr) {
56 53
         if ($this->supportsAbove('7.0') === false) {
57 54
             return;
58 55
         }
Please login to merge, or discard this patch.
Sniffs/FunctionDeclarations/NewExceptionsFromToStringSniff.php 4 patches
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -25,76 +25,76 @@
 block discarded – undo
25 25
 class NewExceptionsFromToStringSniff extends Sniff
26 26
 {
27 27
 
28
-    /**
29
-     * Valid scopes for the __toString() method to live in.
30
-     *
31
-     * @since 9.2.0
32
-     *
33
-     * @var array
34
-     */
35
-    public $ooScopeTokens = array(
36
-        'T_CLASS'      => true,
37
-        'T_TRAIT'      => true,
38
-        'T_ANON_CLASS' => true,
39
-    );
28
+	/**
29
+	 * Valid scopes for the __toString() method to live in.
30
+	 *
31
+	 * @since 9.2.0
32
+	 *
33
+	 * @var array
34
+	 */
35
+	public $ooScopeTokens = array(
36
+		'T_CLASS'      => true,
37
+		'T_TRAIT'      => true,
38
+		'T_ANON_CLASS' => true,
39
+	);
40 40
 
41
-    /**
42
-     * Returns an array of tokens this test wants to listen for.
43
-     *
44
-     * @since 9.2.0
45
-     *
46
-     * @return array
47
-     */
48
-    public function register()
49
-    {
50
-        return array(\T_FUNCTION);
51
-    }
41
+	/**
42
+	 * Returns an array of tokens this test wants to listen for.
43
+	 *
44
+	 * @since 9.2.0
45
+	 *
46
+	 * @return array
47
+	 */
48
+	public function register()
49
+	{
50
+		return array(\T_FUNCTION);
51
+	}
52 52
 
53
-    /**
54
-     * Processes this test, when one of its tokens is encountered.
55
-     *
56
-     * @since 9.2.0
57
-     *
58
-     * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
59
-     * @param int                   $stackPtr  The position of the current token
60
-     *                                         in the stack passed in $tokens.
61
-     *
62
-     * @return void
63
-     */
64
-    public function process(File $phpcsFile, $stackPtr)
65
-    {
66
-        if ($this->supportsBelow('7.3') === false) {
67
-            return;
68
-        }
53
+	/**
54
+	 * Processes this test, when one of its tokens is encountered.
55
+	 *
56
+	 * @since 9.2.0
57
+	 *
58
+	 * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
59
+	 * @param int                   $stackPtr  The position of the current token
60
+	 *                                         in the stack passed in $tokens.
61
+	 *
62
+	 * @return void
63
+	 */
64
+	public function process(File $phpcsFile, $stackPtr)
65
+	{
66
+		if ($this->supportsBelow('7.3') === false) {
67
+			return;
68
+		}
69 69
 
70
-        $tokens = $phpcsFile->getTokens();
71
-        if (isset($tokens[$stackPtr]['scope_opener'], $tokens[$stackPtr]['scope_closer']) === false) {
72
-            // Abstract function, interface function, live coding or parse error.
73
-            return;
74
-        }
70
+		$tokens = $phpcsFile->getTokens();
71
+		if (isset($tokens[$stackPtr]['scope_opener'], $tokens[$stackPtr]['scope_closer']) === false) {
72
+			// Abstract function, interface function, live coding or parse error.
73
+			return;
74
+		}
75 75
 
76
-        $functionName = $phpcsFile->getDeclarationName($stackPtr);
77
-        if (strtolower($functionName) !== '__tostring') {
78
-            // Not the right function.
79
-            return;
80
-        }
76
+		$functionName = $phpcsFile->getDeclarationName($stackPtr);
77
+		if (strtolower($functionName) !== '__tostring') {
78
+			// Not the right function.
79
+			return;
80
+		}
81 81
 
82
-        if ($this->validDirectScope($phpcsFile, $stackPtr, $this->ooScopeTokens) === false) {
83
-            // Function, not method.
84
-            return;
85
-        }
82
+		if ($this->validDirectScope($phpcsFile, $stackPtr, $this->ooScopeTokens) === false) {
83
+			// Function, not method.
84
+			return;
85
+		}
86 86
 
87
-        $hasThrow = $phpcsFile->findNext(\T_THROW, ($tokens[$stackPtr]['scope_opener'] + 1), $tokens[$stackPtr]['scope_closer']);
87
+		$hasThrow = $phpcsFile->findNext(\T_THROW, ($tokens[$stackPtr]['scope_opener'] + 1), $tokens[$stackPtr]['scope_closer']);
88 88
 
89
-        if ($hasThrow === false) {
90
-            // No exception is being thrown.
91
-            return;
92
-        }
89
+		if ($hasThrow === false) {
90
+			// No exception is being thrown.
91
+			return;
92
+		}
93 93
 
94
-        $phpcsFile->addError(
95
-            'Throwing exceptions from __toString() was not allowed prior to PHP 7.4',
96
-            $hasThrow,
97
-            'Found'
98
-        );
99
-    }
94
+		$phpcsFile->addError(
95
+			'Throwing exceptions from __toString() was not allowed prior to PHP 7.4',
96
+			$hasThrow,
97
+			'Found'
98
+		);
99
+	}
100 100
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
      */
48 48
     public function register()
49 49
     {
50
-        return array(\T_FUNCTION);
50
+        return array( \T_FUNCTION );
51 51
     }
52 52
 
53 53
     /**
@@ -61,32 +61,32 @@  discard block
 block discarded – undo
61 61
      *
62 62
      * @return void
63 63
      */
64
-    public function process(File $phpcsFile, $stackPtr)
64
+    public function process( File $phpcsFile, $stackPtr )
65 65
     {
66
-        if ($this->supportsBelow('7.3') === false) {
66
+        if ( $this->supportsBelow( '7.3' ) === false ) {
67 67
             return;
68 68
         }
69 69
 
70 70
         $tokens = $phpcsFile->getTokens();
71
-        if (isset($tokens[$stackPtr]['scope_opener'], $tokens[$stackPtr]['scope_closer']) === false) {
71
+        if ( isset( $tokens[ $stackPtr ][ 'scope_opener' ], $tokens[ $stackPtr ][ 'scope_closer' ] ) === false ) {
72 72
             // Abstract function, interface function, live coding or parse error.
73 73
             return;
74 74
         }
75 75
 
76
-        $functionName = $phpcsFile->getDeclarationName($stackPtr);
77
-        if (strtolower($functionName) !== '__tostring') {
76
+        $functionName = $phpcsFile->getDeclarationName( $stackPtr );
77
+        if ( strtolower( $functionName ) !== '__tostring' ) {
78 78
             // Not the right function.
79 79
             return;
80 80
         }
81 81
 
82
-        if ($this->validDirectScope($phpcsFile, $stackPtr, $this->ooScopeTokens) === false) {
82
+        if ( $this->validDirectScope( $phpcsFile, $stackPtr, $this->ooScopeTokens ) === false ) {
83 83
             // Function, not method.
84 84
             return;
85 85
         }
86 86
 
87
-        $hasThrow = $phpcsFile->findNext(\T_THROW, ($tokens[$stackPtr]['scope_opener'] + 1), $tokens[$stackPtr]['scope_closer']);
87
+        $hasThrow = $phpcsFile->findNext( \T_THROW, ( $tokens[ $stackPtr ][ 'scope_opener' ] + 1 ), $tokens[ $stackPtr ][ 'scope_closer' ] );
88 88
 
89
-        if ($hasThrow === false) {
89
+        if ( $hasThrow === false ) {
90 90
             // No exception is being thrown.
91 91
             return;
92 92
         }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -22,8 +22,7 @@  discard block
 block discarded – undo
22 22
  *
23 23
  * @since 9.2.0
24 24
  */
25
-class NewExceptionsFromToStringSniff extends Sniff
26
-{
25
+class NewExceptionsFromToStringSniff extends Sniff {
27 26
 
28 27
     /**
29 28
      * Valid scopes for the __toString() method to live in.
@@ -45,8 +44,7 @@  discard block
 block discarded – undo
45 44
      *
46 45
      * @return array
47 46
      */
48
-    public function register()
49
-    {
47
+    public function register() {
50 48
         return array(\T_FUNCTION);
51 49
     }
52 50
 
@@ -61,8 +59,7 @@  discard block
 block discarded – undo
61 59
      *
62 60
      * @return void
63 61
      */
64
-    public function process(File $phpcsFile, $stackPtr)
65
-    {
62
+    public function process(File $phpcsFile, $stackPtr) {
66 63
         if ($this->supportsBelow('7.3') === false) {
67 64
             return;
68 65
         }
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@
 block discarded – undo
47 47
      *
48 48
      * @since 9.2.0
49 49
      *
50
-     * @return array
50
+     * @return integer[]
51 51
      */
52 52
     public function register()
53 53
     {
Please login to merge, or discard this patch.
PHPCompatibility/Sniffs/FunctionDeclarations/NewNullableTypesSniff.php 3 patches
Indentation   +130 added lines, -130 removed lines patch added patch discarded remove patch
@@ -29,134 +29,134 @@
 block discarded – undo
29 29
  */
30 30
 class NewNullableTypesSniff extends Sniff
31 31
 {
32
-    /**
33
-     * Returns an array of tokens this test wants to listen for.
34
-     *
35
-     * {@internal Not sniffing for T_NULLABLE which was introduced in PHPCS 2.7.2
36
-     * as in that case we can't distinguish between parameter type hints and
37
-     * return type hints for the error message.}}
38
-     *
39
-     * @return array
40
-     */
41
-    public function register()
42
-    {
43
-        $tokens = array(
44
-            \T_FUNCTION,
45
-            \T_CLOSURE,
46
-        );
47
-
48
-        if (\defined('T_RETURN_TYPE')) {
49
-            $tokens[] = \T_RETURN_TYPE;
50
-        }
51
-
52
-        return $tokens;
53
-    }
54
-
55
-
56
-    /**
57
-     * Processes this test, when one of its tokens is encountered.
58
-     *
59
-     * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
60
-     * @param int                   $stackPtr  The position of the current token
61
-     *                                         in the stack passed in $tokens.
62
-     *
63
-     * @return void
64
-     */
65
-    public function process(File $phpcsFile, $stackPtr)
66
-    {
67
-        if ($this->supportsBelow('7.0') === false) {
68
-            return;
69
-        }
70
-
71
-        $tokens    = $phpcsFile->getTokens();
72
-        $tokenCode = $tokens[$stackPtr]['code'];
73
-
74
-        if ($tokenCode === \T_FUNCTION || $tokenCode === \T_CLOSURE) {
75
-            $this->processFunctionDeclaration($phpcsFile, $stackPtr);
76
-
77
-            // Deal with older PHPCS version which don't recognize return type hints
78
-            // as well as newer PHPCS versions (3.3.0+) where the tokenization has changed.
79
-            $returnTypeHint = $this->getReturnTypeHintToken($phpcsFile, $stackPtr);
80
-            if ($returnTypeHint !== false) {
81
-                $this->processReturnType($phpcsFile, $returnTypeHint);
82
-            }
83
-        } else {
84
-            $this->processReturnType($phpcsFile, $stackPtr);
85
-        }
86
-    }
87
-
88
-
89
-    /**
90
-     * Process this test for function tokens.
91
-     *
92
-     * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
93
-     * @param int                   $stackPtr  The position of the current token
94
-     *                                         in the stack passed in $tokens.
95
-     *
96
-     * @return void
97
-     */
98
-    protected function processFunctionDeclaration(File $phpcsFile, $stackPtr)
99
-    {
100
-        $params = PHPCSHelper::getMethodParameters($phpcsFile, $stackPtr);
101
-
102
-        if (empty($params) === false && \is_array($params)) {
103
-            foreach ($params as $param) {
104
-                if ($param['nullable_type'] === true) {
105
-                    $phpcsFile->addError(
106
-                        'Nullable type declarations are not supported in PHP 7.0 or earlier. Found: %s',
107
-                        $param['token'],
108
-                        'typeDeclarationFound',
109
-                        array($param['type_hint'])
110
-                    );
111
-                }
112
-            }
113
-        }
114
-    }
115
-
116
-
117
-    /**
118
-     * Process this test for return type tokens.
119
-     *
120
-     * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
121
-     * @param int                   $stackPtr  The position of the current token
122
-     *                                         in the stack passed in $tokens.
123
-     *
124
-     * @return void
125
-     */
126
-    protected function processReturnType(File $phpcsFile, $stackPtr)
127
-    {
128
-        $tokens = $phpcsFile->getTokens();
129
-
130
-        if (isset($tokens[($stackPtr - 1)]['code']) === false) {
131
-            return;
132
-        }
133
-
134
-        $previous = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
135
-
136
-        // Deal with namespaced class names.
137
-        if ($tokens[$previous]['code'] === \T_NS_SEPARATOR) {
138
-            $validTokens                  = Tokens::$emptyTokens;
139
-            $validTokens[\T_STRING]       = true;
140
-            $validTokens[\T_NS_SEPARATOR] = true;
141
-
142
-            $stackPtr--;
143
-
144
-            while (isset($validTokens[$tokens[($stackPtr - 1)]['code']]) === true) {
145
-                $stackPtr--;
146
-            }
147
-
148
-            $previous = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
149
-        }
150
-
151
-        // T_NULLABLE token was introduced in PHPCS 2.7.2. Before that it identified as T_INLINE_THEN.
152
-        if ((\defined('T_NULLABLE') === true && $tokens[$previous]['type'] === 'T_NULLABLE')
153
-            || (\defined('T_NULLABLE') === false && $tokens[$previous]['code'] === \T_INLINE_THEN)
154
-        ) {
155
-            $phpcsFile->addError(
156
-                'Nullable return types are not supported in PHP 7.0 or earlier.',
157
-                $stackPtr,
158
-                'returnTypeFound'
159
-            );
160
-        }
161
-    }
32
+	/**
33
+	 * Returns an array of tokens this test wants to listen for.
34
+	 *
35
+	 * {@internal Not sniffing for T_NULLABLE which was introduced in PHPCS 2.7.2
36
+	 * as in that case we can't distinguish between parameter type hints and
37
+	 * return type hints for the error message.}}
38
+	 *
39
+	 * @return array
40
+	 */
41
+	public function register()
42
+	{
43
+		$tokens = array(
44
+			\T_FUNCTION,
45
+			\T_CLOSURE,
46
+		);
47
+
48
+		if (\defined('T_RETURN_TYPE')) {
49
+			$tokens[] = \T_RETURN_TYPE;
50
+		}
51
+
52
+		return $tokens;
53
+	}
54
+
55
+
56
+	/**
57
+	 * Processes this test, when one of its tokens is encountered.
58
+	 *
59
+	 * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
60
+	 * @param int                   $stackPtr  The position of the current token
61
+	 *                                         in the stack passed in $tokens.
62
+	 *
63
+	 * @return void
64
+	 */
65
+	public function process(File $phpcsFile, $stackPtr)
66
+	{
67
+		if ($this->supportsBelow('7.0') === false) {
68
+			return;
69
+		}
70
+
71
+		$tokens    = $phpcsFile->getTokens();
72
+		$tokenCode = $tokens[$stackPtr]['code'];
73
+
74
+		if ($tokenCode === \T_FUNCTION || $tokenCode === \T_CLOSURE) {
75
+			$this->processFunctionDeclaration($phpcsFile, $stackPtr);
76
+
77
+			// Deal with older PHPCS version which don't recognize return type hints
78
+			// as well as newer PHPCS versions (3.3.0+) where the tokenization has changed.
79
+			$returnTypeHint = $this->getReturnTypeHintToken($phpcsFile, $stackPtr);
80
+			if ($returnTypeHint !== false) {
81
+				$this->processReturnType($phpcsFile, $returnTypeHint);
82
+			}
83
+		} else {
84
+			$this->processReturnType($phpcsFile, $stackPtr);
85
+		}
86
+	}
87
+
88
+
89
+	/**
90
+	 * Process this test for function tokens.
91
+	 *
92
+	 * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
93
+	 * @param int                   $stackPtr  The position of the current token
94
+	 *                                         in the stack passed in $tokens.
95
+	 *
96
+	 * @return void
97
+	 */
98
+	protected function processFunctionDeclaration(File $phpcsFile, $stackPtr)
99
+	{
100
+		$params = PHPCSHelper::getMethodParameters($phpcsFile, $stackPtr);
101
+
102
+		if (empty($params) === false && \is_array($params)) {
103
+			foreach ($params as $param) {
104
+				if ($param['nullable_type'] === true) {
105
+					$phpcsFile->addError(
106
+						'Nullable type declarations are not supported in PHP 7.0 or earlier. Found: %s',
107
+						$param['token'],
108
+						'typeDeclarationFound',
109
+						array($param['type_hint'])
110
+					);
111
+				}
112
+			}
113
+		}
114
+	}
115
+
116
+
117
+	/**
118
+	 * Process this test for return type tokens.
119
+	 *
120
+	 * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
121
+	 * @param int                   $stackPtr  The position of the current token
122
+	 *                                         in the stack passed in $tokens.
123
+	 *
124
+	 * @return void
125
+	 */
126
+	protected function processReturnType(File $phpcsFile, $stackPtr)
127
+	{
128
+		$tokens = $phpcsFile->getTokens();
129
+
130
+		if (isset($tokens[($stackPtr - 1)]['code']) === false) {
131
+			return;
132
+		}
133
+
134
+		$previous = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
135
+
136
+		// Deal with namespaced class names.
137
+		if ($tokens[$previous]['code'] === \T_NS_SEPARATOR) {
138
+			$validTokens                  = Tokens::$emptyTokens;
139
+			$validTokens[\T_STRING]       = true;
140
+			$validTokens[\T_NS_SEPARATOR] = true;
141
+
142
+			$stackPtr--;
143
+
144
+			while (isset($validTokens[$tokens[($stackPtr - 1)]['code']]) === true) {
145
+				$stackPtr--;
146
+			}
147
+
148
+			$previous = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
149
+		}
150
+
151
+		// T_NULLABLE token was introduced in PHPCS 2.7.2. Before that it identified as T_INLINE_THEN.
152
+		if ((\defined('T_NULLABLE') === true && $tokens[$previous]['type'] === 'T_NULLABLE')
153
+			|| (\defined('T_NULLABLE') === false && $tokens[$previous]['code'] === \T_INLINE_THEN)
154
+		) {
155
+			$phpcsFile->addError(
156
+				'Nullable return types are not supported in PHP 7.0 or earlier.',
157
+				$stackPtr,
158
+				'returnTypeFound'
159
+			);
160
+		}
161
+	}
162 162
 }
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -45,8 +45,8 @@  discard block
 block discarded – undo
45 45
             \T_CLOSURE,
46 46
         );
47 47
 
48
-        if (\defined('T_RETURN_TYPE')) {
49
-            $tokens[] = \T_RETURN_TYPE;
48
+        if ( \defined( 'T_RETURN_TYPE' ) ) {
49
+            $tokens[ ] = \T_RETURN_TYPE;
50 50
         }
51 51
 
52 52
         return $tokens;
@@ -62,26 +62,26 @@  discard block
 block discarded – undo
62 62
      *
63 63
      * @return void
64 64
      */
65
-    public function process(File $phpcsFile, $stackPtr)
65
+    public function process( File $phpcsFile, $stackPtr )
66 66
     {
67
-        if ($this->supportsBelow('7.0') === false) {
67
+        if ( $this->supportsBelow( '7.0' ) === false ) {
68 68
             return;
69 69
         }
70 70
 
71 71
         $tokens    = $phpcsFile->getTokens();
72
-        $tokenCode = $tokens[$stackPtr]['code'];
72
+        $tokenCode = $tokens[ $stackPtr ][ 'code' ];
73 73
 
74
-        if ($tokenCode === \T_FUNCTION || $tokenCode === \T_CLOSURE) {
75
-            $this->processFunctionDeclaration($phpcsFile, $stackPtr);
74
+        if ( $tokenCode === \T_FUNCTION || $tokenCode === \T_CLOSURE ) {
75
+            $this->processFunctionDeclaration( $phpcsFile, $stackPtr );
76 76
 
77 77
             // Deal with older PHPCS version which don't recognize return type hints
78 78
             // as well as newer PHPCS versions (3.3.0+) where the tokenization has changed.
79
-            $returnTypeHint = $this->getReturnTypeHintToken($phpcsFile, $stackPtr);
80
-            if ($returnTypeHint !== false) {
81
-                $this->processReturnType($phpcsFile, $returnTypeHint);
79
+            $returnTypeHint = $this->getReturnTypeHintToken( $phpcsFile, $stackPtr );
80
+            if ( $returnTypeHint !== false ) {
81
+                $this->processReturnType( $phpcsFile, $returnTypeHint );
82 82
             }
83 83
         } else {
84
-            $this->processReturnType($phpcsFile, $stackPtr);
84
+            $this->processReturnType( $phpcsFile, $stackPtr );
85 85
         }
86 86
     }
87 87
 
@@ -95,18 +95,18 @@  discard block
 block discarded – undo
95 95
      *
96 96
      * @return void
97 97
      */
98
-    protected function processFunctionDeclaration(File $phpcsFile, $stackPtr)
98
+    protected function processFunctionDeclaration( File $phpcsFile, $stackPtr )
99 99
     {
100
-        $params = PHPCSHelper::getMethodParameters($phpcsFile, $stackPtr);
100
+        $params = PHPCSHelper::getMethodParameters( $phpcsFile, $stackPtr );
101 101
 
102
-        if (empty($params) === false && \is_array($params)) {
103
-            foreach ($params as $param) {
104
-                if ($param['nullable_type'] === true) {
102
+        if ( empty( $params ) === false && \is_array( $params ) ) {
103
+            foreach ( $params as $param ) {
104
+                if ( $param[ 'nullable_type' ] === true ) {
105 105
                     $phpcsFile->addError(
106 106
                         'Nullable type declarations are not supported in PHP 7.0 or earlier. Found: %s',
107
-                        $param['token'],
107
+                        $param[ 'token' ],
108 108
                         'typeDeclarationFound',
109
-                        array($param['type_hint'])
109
+                        array( $param[ 'type_hint' ] )
110 110
                     );
111 111
                 }
112 112
             }
@@ -123,34 +123,34 @@  discard block
 block discarded – undo
123 123
      *
124 124
      * @return void
125 125
      */
126
-    protected function processReturnType(File $phpcsFile, $stackPtr)
126
+    protected function processReturnType( File $phpcsFile, $stackPtr )
127 127
     {
128 128
         $tokens = $phpcsFile->getTokens();
129 129
 
130
-        if (isset($tokens[($stackPtr - 1)]['code']) === false) {
130
+        if ( isset( $tokens[ ( $stackPtr - 1 ) ][ 'code' ] ) === false ) {
131 131
             return;
132 132
         }
133 133
 
134
-        $previous = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
134
+        $previous = $phpcsFile->findPrevious( Tokens::$emptyTokens, ( $stackPtr - 1 ), null, true );
135 135
 
136 136
         // Deal with namespaced class names.
137
-        if ($tokens[$previous]['code'] === \T_NS_SEPARATOR) {
137
+        if ( $tokens[ $previous ][ 'code' ] === \T_NS_SEPARATOR ) {
138 138
             $validTokens                  = Tokens::$emptyTokens;
139
-            $validTokens[\T_STRING]       = true;
140
-            $validTokens[\T_NS_SEPARATOR] = true;
139
+            $validTokens[ \T_STRING ]       = true;
140
+            $validTokens[ \T_NS_SEPARATOR ] = true;
141 141
 
142 142
             $stackPtr--;
143 143
 
144
-            while (isset($validTokens[$tokens[($stackPtr - 1)]['code']]) === true) {
144
+            while ( isset( $validTokens[ $tokens[ ( $stackPtr - 1 ) ][ 'code' ] ] ) === true ) {
145 145
                 $stackPtr--;
146 146
             }
147 147
 
148
-            $previous = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
148
+            $previous = $phpcsFile->findPrevious( Tokens::$emptyTokens, ( $stackPtr - 1 ), null, true );
149 149
         }
150 150
 
151 151
         // T_NULLABLE token was introduced in PHPCS 2.7.2. Before that it identified as T_INLINE_THEN.
152
-        if ((\defined('T_NULLABLE') === true && $tokens[$previous]['type'] === 'T_NULLABLE')
153
-            || (\defined('T_NULLABLE') === false && $tokens[$previous]['code'] === \T_INLINE_THEN)
152
+        if ( ( \defined( 'T_NULLABLE' ) === true && $tokens[ $previous ][ 'type' ] === 'T_NULLABLE' )
153
+            || ( \defined( 'T_NULLABLE' ) === false && $tokens[ $previous ][ 'code' ] === \T_INLINE_THEN )
154 154
         ) {
155 155
             $phpcsFile->addError(
156 156
                 'Nullable return types are not supported in PHP 7.0 or earlier.',
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -27,8 +27,7 @@  discard block
 block discarded – undo
27 27
  * @package  PHPCompatibility
28 28
  * @author   Juliette Reinders Folmer <[email protected]>
29 29
  */
30
-class NewNullableTypesSniff extends Sniff
31
-{
30
+class NewNullableTypesSniff extends Sniff {
32 31
     /**
33 32
      * Returns an array of tokens this test wants to listen for.
34 33
      *
@@ -38,8 +37,7 @@  discard block
 block discarded – undo
38 37
      *
39 38
      * @return array
40 39
      */
41
-    public function register()
42
-    {
40
+    public function register() {
43 41
         $tokens = array(
44 42
             \T_FUNCTION,
45 43
             \T_CLOSURE,
@@ -62,8 +60,7 @@  discard block
 block discarded – undo
62 60
      *
63 61
      * @return void
64 62
      */
65
-    public function process(File $phpcsFile, $stackPtr)
66
-    {
63
+    public function process(File $phpcsFile, $stackPtr) {
67 64
         if ($this->supportsBelow('7.0') === false) {
68 65
             return;
69 66
         }
@@ -95,8 +92,7 @@  discard block
 block discarded – undo
95 92
      *
96 93
      * @return void
97 94
      */
98
-    protected function processFunctionDeclaration(File $phpcsFile, $stackPtr)
99
-    {
95
+    protected function processFunctionDeclaration(File $phpcsFile, $stackPtr) {
100 96
         $params = PHPCSHelper::getMethodParameters($phpcsFile, $stackPtr);
101 97
 
102 98
         if (empty($params) === false && \is_array($params)) {
@@ -123,8 +119,7 @@  discard block
 block discarded – undo
123 119
      *
124 120
      * @return void
125 121
      */
126
-    protected function processReturnType(File $phpcsFile, $stackPtr)
127
-    {
122
+    protected function processReturnType(File $phpcsFile, $stackPtr) {
128 123
         $tokens = $phpcsFile->getTokens();
129 124
 
130 125
         if (isset($tokens[($stackPtr - 1)]['code']) === false) {
Please login to merge, or discard this patch.
PHPCompatibility/Sniffs/FunctionDeclarations/NonStaticMagicMethodsSniff.php 3 patches
Indentation   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -28,151 +28,151 @@
 block discarded – undo
28 28
 class NonStaticMagicMethodsSniff extends Sniff
29 29
 {
30 30
 
31
-    /**
32
-     * A list of PHP magic methods and their visibility and static requirements.
33
-     *
34
-     * Method names in the array should be all *lowercase*.
35
-     * Visibility can be either 'public', 'protected' or 'private'.
36
-     * Static can be either 'true' - *must* be static, or 'false' - *must* be non-static.
37
-     * When a method does not have a specific requirement for either visibility or static,
38
-     * do *not* add the key.
39
-     *
40
-     * @var array(string)
41
-     */
42
-    protected $magicMethods = array(
43
-        '__get' => array(
44
-            'visibility' => 'public',
45
-            'static'     => false,
46
-        ),
47
-        '__set' => array(
48
-            'visibility' => 'public',
49
-            'static'     => false,
50
-        ),
51
-        '__isset' => array(
52
-            'visibility' => 'public',
53
-            'static'     => false,
54
-        ),
55
-        '__unset' => array(
56
-            'visibility' => 'public',
57
-            'static'     => false,
58
-        ),
59
-        '__call' => array(
60
-            'visibility' => 'public',
61
-            'static'     => false,
62
-        ),
63
-        '__callstatic' => array(
64
-            'visibility' => 'public',
65
-            'static'     => true,
66
-        ),
67
-        '__sleep' => array(
68
-            'visibility' => 'public',
69
-        ),
70
-        '__tostring' => array(
71
-            'visibility' => 'public',
72
-        ),
73
-        '__set_state' => array(
74
-            'static'     => true,
75
-        ),
76
-    );
77
-
78
-
79
-    /**
80
-     * Returns an array of tokens this test wants to listen for.
81
-     *
82
-     * @return array
83
-     */
84
-    public function register()
85
-    {
86
-        $targets = array(
87
-            \T_CLASS,
88
-            \T_INTERFACE,
89
-            \T_TRAIT,
90
-        );
91
-
92
-        if (\defined('T_ANON_CLASS')) {
93
-            $targets[] = \T_ANON_CLASS;
94
-        }
95
-
96
-        return $targets;
97
-    }
98
-
99
-
100
-    /**
101
-     * Processes this test, when one of its tokens is encountered.
102
-     *
103
-     * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
104
-     * @param int                   $stackPtr  The position of the current token in the
105
-     *                                         stack passed in $tokens.
106
-     *
107
-     * @return void
108
-     */
109
-    public function process(File $phpcsFile, $stackPtr)
110
-    {
111
-        // Should be removed, the requirement was previously also there, 5.3 just started throwing a warning about it.
112
-        if ($this->supportsAbove('5.3') === false) {
113
-            return;
114
-        }
115
-
116
-        $tokens = $phpcsFile->getTokens();
117
-
118
-        if (isset($tokens[$stackPtr]['scope_closer']) === false) {
119
-            return;
120
-        }
121
-
122
-        $classScopeCloser = $tokens[$stackPtr]['scope_closer'];
123
-        $functionPtr      = $stackPtr;
124
-
125
-        // Find all the functions in this class or interface.
126
-        while (($functionToken = $phpcsFile->findNext(\T_FUNCTION, $functionPtr, $classScopeCloser)) !== false) {
127
-            /*
31
+	/**
32
+	 * A list of PHP magic methods and their visibility and static requirements.
33
+	 *
34
+	 * Method names in the array should be all *lowercase*.
35
+	 * Visibility can be either 'public', 'protected' or 'private'.
36
+	 * Static can be either 'true' - *must* be static, or 'false' - *must* be non-static.
37
+	 * When a method does not have a specific requirement for either visibility or static,
38
+	 * do *not* add the key.
39
+	 *
40
+	 * @var array(string)
41
+	 */
42
+	protected $magicMethods = array(
43
+		'__get' => array(
44
+			'visibility' => 'public',
45
+			'static'     => false,
46
+		),
47
+		'__set' => array(
48
+			'visibility' => 'public',
49
+			'static'     => false,
50
+		),
51
+		'__isset' => array(
52
+			'visibility' => 'public',
53
+			'static'     => false,
54
+		),
55
+		'__unset' => array(
56
+			'visibility' => 'public',
57
+			'static'     => false,
58
+		),
59
+		'__call' => array(
60
+			'visibility' => 'public',
61
+			'static'     => false,
62
+		),
63
+		'__callstatic' => array(
64
+			'visibility' => 'public',
65
+			'static'     => true,
66
+		),
67
+		'__sleep' => array(
68
+			'visibility' => 'public',
69
+		),
70
+		'__tostring' => array(
71
+			'visibility' => 'public',
72
+		),
73
+		'__set_state' => array(
74
+			'static'     => true,
75
+		),
76
+	);
77
+
78
+
79
+	/**
80
+	 * Returns an array of tokens this test wants to listen for.
81
+	 *
82
+	 * @return array
83
+	 */
84
+	public function register()
85
+	{
86
+		$targets = array(
87
+			\T_CLASS,
88
+			\T_INTERFACE,
89
+			\T_TRAIT,
90
+		);
91
+
92
+		if (\defined('T_ANON_CLASS')) {
93
+			$targets[] = \T_ANON_CLASS;
94
+		}
95
+
96
+		return $targets;
97
+	}
98
+
99
+
100
+	/**
101
+	 * Processes this test, when one of its tokens is encountered.
102
+	 *
103
+	 * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
104
+	 * @param int                   $stackPtr  The position of the current token in the
105
+	 *                                         stack passed in $tokens.
106
+	 *
107
+	 * @return void
108
+	 */
109
+	public function process(File $phpcsFile, $stackPtr)
110
+	{
111
+		// Should be removed, the requirement was previously also there, 5.3 just started throwing a warning about it.
112
+		if ($this->supportsAbove('5.3') === false) {
113
+			return;
114
+		}
115
+
116
+		$tokens = $phpcsFile->getTokens();
117
+
118
+		if (isset($tokens[$stackPtr]['scope_closer']) === false) {
119
+			return;
120
+		}
121
+
122
+		$classScopeCloser = $tokens[$stackPtr]['scope_closer'];
123
+		$functionPtr      = $stackPtr;
124
+
125
+		// Find all the functions in this class or interface.
126
+		while (($functionToken = $phpcsFile->findNext(\T_FUNCTION, $functionPtr, $classScopeCloser)) !== false) {
127
+			/*
128 128
              * Get the scope closer for this function in order to know how
129 129
              * to advance to the next function.
130 130
              * If no body of function (e.g. for interfaces), there is
131 131
              * no closing curly brace; advance the pointer differently.
132 132
              */
133
-            if (isset($tokens[$functionToken]['scope_closer'])) {
134
-                $scopeCloser = $tokens[$functionToken]['scope_closer'];
135
-            } else {
136
-                $scopeCloser = ($functionToken + 1);
137
-            }
138
-
139
-            $methodName   = $phpcsFile->getDeclarationName($functionToken);
140
-            $methodNameLc = strtolower($methodName);
141
-            if (isset($this->magicMethods[$methodNameLc]) === false) {
142
-                $functionPtr = $scopeCloser;
143
-                continue;
144
-            }
145
-
146
-            $methodProperties = $phpcsFile->getMethodProperties($functionToken);
147
-            $errorCodeBase    = $this->stringToErrorCode($methodNameLc);
148
-
149
-            if (isset($this->magicMethods[$methodNameLc]['visibility']) && $this->magicMethods[$methodNameLc]['visibility'] !== $methodProperties['scope']) {
150
-                $error     = 'Visibility for magic method %s must be %s. Found: %s';
151
-                $errorCode = $errorCodeBase . 'MethodVisibility';
152
-                $data      = array(
153
-                    $methodName,
154
-                    $this->magicMethods[$methodNameLc]['visibility'],
155
-                    $methodProperties['scope'],
156
-                );
157
-
158
-                $phpcsFile->addError($error, $functionToken, $errorCode, $data);
159
-            }
160
-
161
-            if (isset($this->magicMethods[$methodNameLc]['static']) && $this->magicMethods[$methodNameLc]['static'] !== $methodProperties['is_static']) {
162
-                $error     = 'Magic method %s cannot be defined as static.';
163
-                $errorCode = $errorCodeBase . 'MethodStatic';
164
-                $data      = array($methodName);
165
-
166
-                if ($this->magicMethods[$methodNameLc]['static'] === true) {
167
-                    $error     = 'Magic method %s must be defined as static.';
168
-                    $errorCode = $errorCodeBase . 'MethodNonStatic';
169
-                }
170
-
171
-                $phpcsFile->addError($error, $functionToken, $errorCode, $data);
172
-            }
173
-
174
-            // Advance to next function.
175
-            $functionPtr = $scopeCloser;
176
-        }
177
-    }
133
+			if (isset($tokens[$functionToken]['scope_closer'])) {
134
+				$scopeCloser = $tokens[$functionToken]['scope_closer'];
135
+			} else {
136
+				$scopeCloser = ($functionToken + 1);
137
+			}
138
+
139
+			$methodName   = $phpcsFile->getDeclarationName($functionToken);
140
+			$methodNameLc = strtolower($methodName);
141
+			if (isset($this->magicMethods[$methodNameLc]) === false) {
142
+				$functionPtr = $scopeCloser;
143
+				continue;
144
+			}
145
+
146
+			$methodProperties = $phpcsFile->getMethodProperties($functionToken);
147
+			$errorCodeBase    = $this->stringToErrorCode($methodNameLc);
148
+
149
+			if (isset($this->magicMethods[$methodNameLc]['visibility']) && $this->magicMethods[$methodNameLc]['visibility'] !== $methodProperties['scope']) {
150
+				$error     = 'Visibility for magic method %s must be %s. Found: %s';
151
+				$errorCode = $errorCodeBase . 'MethodVisibility';
152
+				$data      = array(
153
+					$methodName,
154
+					$this->magicMethods[$methodNameLc]['visibility'],
155
+					$methodProperties['scope'],
156
+				);
157
+
158
+				$phpcsFile->addError($error, $functionToken, $errorCode, $data);
159
+			}
160
+
161
+			if (isset($this->magicMethods[$methodNameLc]['static']) && $this->magicMethods[$methodNameLc]['static'] !== $methodProperties['is_static']) {
162
+				$error     = 'Magic method %s cannot be defined as static.';
163
+				$errorCode = $errorCodeBase . 'MethodStatic';
164
+				$data      = array($methodName);
165
+
166
+				if ($this->magicMethods[$methodNameLc]['static'] === true) {
167
+					$error     = 'Magic method %s must be defined as static.';
168
+					$errorCode = $errorCodeBase . 'MethodNonStatic';
169
+				}
170
+
171
+				$phpcsFile->addError($error, $functionToken, $errorCode, $data);
172
+			}
173
+
174
+			// Advance to next function.
175
+			$functionPtr = $scopeCloser;
176
+		}
177
+	}
178 178
 }
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
             \T_TRAIT,
90 90
         );
91 91
 
92
-        if (\defined('T_ANON_CLASS')) {
93
-            $targets[] = \T_ANON_CLASS;
92
+        if ( \defined( 'T_ANON_CLASS' ) ) {
93
+            $targets[ ] = \T_ANON_CLASS;
94 94
         }
95 95
 
96 96
         return $targets;
@@ -106,69 +106,69 @@  discard block
 block discarded – undo
106 106
      *
107 107
      * @return void
108 108
      */
109
-    public function process(File $phpcsFile, $stackPtr)
109
+    public function process( File $phpcsFile, $stackPtr )
110 110
     {
111 111
         // Should be removed, the requirement was previously also there, 5.3 just started throwing a warning about it.
112
-        if ($this->supportsAbove('5.3') === false) {
112
+        if ( $this->supportsAbove( '5.3' ) === false ) {
113 113
             return;
114 114
         }
115 115
 
116 116
         $tokens = $phpcsFile->getTokens();
117 117
 
118
-        if (isset($tokens[$stackPtr]['scope_closer']) === false) {
118
+        if ( isset( $tokens[ $stackPtr ][ 'scope_closer' ] ) === false ) {
119 119
             return;
120 120
         }
121 121
 
122
-        $classScopeCloser = $tokens[$stackPtr]['scope_closer'];
122
+        $classScopeCloser = $tokens[ $stackPtr ][ 'scope_closer' ];
123 123
         $functionPtr      = $stackPtr;
124 124
 
125 125
         // Find all the functions in this class or interface.
126
-        while (($functionToken = $phpcsFile->findNext(\T_FUNCTION, $functionPtr, $classScopeCloser)) !== false) {
126
+        while ( ( $functionToken = $phpcsFile->findNext( \T_FUNCTION, $functionPtr, $classScopeCloser ) ) !== false ) {
127 127
             /*
128 128
              * Get the scope closer for this function in order to know how
129 129
              * to advance to the next function.
130 130
              * If no body of function (e.g. for interfaces), there is
131 131
              * no closing curly brace; advance the pointer differently.
132 132
              */
133
-            if (isset($tokens[$functionToken]['scope_closer'])) {
134
-                $scopeCloser = $tokens[$functionToken]['scope_closer'];
133
+            if ( isset( $tokens[ $functionToken ][ 'scope_closer' ] ) ) {
134
+                $scopeCloser = $tokens[ $functionToken ][ 'scope_closer' ];
135 135
             } else {
136
-                $scopeCloser = ($functionToken + 1);
136
+                $scopeCloser = ( $functionToken + 1 );
137 137
             }
138 138
 
139
-            $methodName   = $phpcsFile->getDeclarationName($functionToken);
140
-            $methodNameLc = strtolower($methodName);
141
-            if (isset($this->magicMethods[$methodNameLc]) === false) {
139
+            $methodName   = $phpcsFile->getDeclarationName( $functionToken );
140
+            $methodNameLc = strtolower( $methodName );
141
+            if ( isset( $this->magicMethods[ $methodNameLc ] ) === false ) {
142 142
                 $functionPtr = $scopeCloser;
143 143
                 continue;
144 144
             }
145 145
 
146
-            $methodProperties = $phpcsFile->getMethodProperties($functionToken);
147
-            $errorCodeBase    = $this->stringToErrorCode($methodNameLc);
146
+            $methodProperties = $phpcsFile->getMethodProperties( $functionToken );
147
+            $errorCodeBase    = $this->stringToErrorCode( $methodNameLc );
148 148
 
149
-            if (isset($this->magicMethods[$methodNameLc]['visibility']) && $this->magicMethods[$methodNameLc]['visibility'] !== $methodProperties['scope']) {
149
+            if ( isset( $this->magicMethods[ $methodNameLc ][ 'visibility' ] ) && $this->magicMethods[ $methodNameLc ][ 'visibility' ] !== $methodProperties[ 'scope' ] ) {
150 150
                 $error     = 'Visibility for magic method %s must be %s. Found: %s';
151 151
                 $errorCode = $errorCodeBase . 'MethodVisibility';
152 152
                 $data      = array(
153 153
                     $methodName,
154
-                    $this->magicMethods[$methodNameLc]['visibility'],
155
-                    $methodProperties['scope'],
154
+                    $this->magicMethods[ $methodNameLc ][ 'visibility' ],
155
+                    $methodProperties[ 'scope' ],
156 156
                 );
157 157
 
158
-                $phpcsFile->addError($error, $functionToken, $errorCode, $data);
158
+                $phpcsFile->addError( $error, $functionToken, $errorCode, $data );
159 159
             }
160 160
 
161
-            if (isset($this->magicMethods[$methodNameLc]['static']) && $this->magicMethods[$methodNameLc]['static'] !== $methodProperties['is_static']) {
161
+            if ( isset( $this->magicMethods[ $methodNameLc ][ 'static' ] ) && $this->magicMethods[ $methodNameLc ][ 'static' ] !== $methodProperties[ 'is_static' ] ) {
162 162
                 $error     = 'Magic method %s cannot be defined as static.';
163 163
                 $errorCode = $errorCodeBase . 'MethodStatic';
164
-                $data      = array($methodName);
164
+                $data      = array( $methodName );
165 165
 
166
-                if ($this->magicMethods[$methodNameLc]['static'] === true) {
166
+                if ( $this->magicMethods[ $methodNameLc ][ 'static' ] === true ) {
167 167
                     $error     = 'Magic method %s must be defined as static.';
168 168
                     $errorCode = $errorCodeBase . 'MethodNonStatic';
169 169
                 }
170 170
 
171
-                $phpcsFile->addError($error, $functionToken, $errorCode, $data);
171
+                $phpcsFile->addError( $error, $functionToken, $errorCode, $data );
172 172
             }
173 173
 
174 174
             // Advance to next function.
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -25,8 +25,7 @@  discard block
 block discarded – undo
25 25
  * @author    Wim Godden <[email protected]>
26 26
  * @copyright 2012 Cu.be Solutions bvba
27 27
  */
28
-class NonStaticMagicMethodsSniff extends Sniff
29
-{
28
+class NonStaticMagicMethodsSniff extends Sniff {
30 29
 
31 30
     /**
32 31
      * A list of PHP magic methods and their visibility and static requirements.
@@ -81,8 +80,7 @@  discard block
 block discarded – undo
81 80
      *
82 81
      * @return array
83 82
      */
84
-    public function register()
85
-    {
83
+    public function register() {
86 84
         $targets = array(
87 85
             \T_CLASS,
88 86
             \T_INTERFACE,
@@ -106,8 +104,7 @@  discard block
 block discarded – undo
106 104
      *
107 105
      * @return void
108 106
      */
109
-    public function process(File $phpcsFile, $stackPtr)
110
-    {
107
+    public function process(File $phpcsFile, $stackPtr) {
111 108
         // Should be removed, the requirement was previously also there, 5.3 just started throwing a warning about it.
112 109
         if ($this->supportsAbove('5.3') === false) {
113 110
             return;
Please login to merge, or discard this patch.
PHPCompatibility/Sniffs/Extensions/RemovedExtensionsSniff.php 4 patches
Indentation   +266 added lines, -266 removed lines patch added patch discarded remove patch
@@ -26,292 +26,292 @@
 block discarded – undo
26 26
  */
27 27
 class RemovedExtensionsSniff extends AbstractRemovedFeatureSniff
28 28
 {
29
-    /**
30
-     * A list of functions to whitelist, if any.
31
-     *
32
-     * This is intended for projects using functions which start with the same
33
-     * prefix as one of the removed extensions.
34
-     *
35
-     * This property can be set from the ruleset, like so:
36
-     * <rule ref="PHPCompatibility.Extensions.RemovedExtensions">
37
-     *   <properties>
38
-     *     <property name="functionWhitelist" type="array" value="mysql_to_rfc3339,mysql_another_function" />
39
-     *   </properties>
40
-     * </rule>
41
-     *
42
-     * @var array
43
-     */
44
-    public $functionWhitelist;
29
+	/**
30
+	 * A list of functions to whitelist, if any.
31
+	 *
32
+	 * This is intended for projects using functions which start with the same
33
+	 * prefix as one of the removed extensions.
34
+	 *
35
+	 * This property can be set from the ruleset, like so:
36
+	 * <rule ref="PHPCompatibility.Extensions.RemovedExtensions">
37
+	 *   <properties>
38
+	 *     <property name="functionWhitelist" type="array" value="mysql_to_rfc3339,mysql_another_function" />
39
+	 *   </properties>
40
+	 * </rule>
41
+	 *
42
+	 * @var array
43
+	 */
44
+	public $functionWhitelist;
45 45
 
46
-    /**
47
-     * A list of removed extensions with their alternative, if any
48
-     *
49
-     * The array lists : version number with false (deprecated) and true (removed).
50
-     * If's sufficient to list the first version where the extension was deprecated/removed.
51
-     *
52
-     * @var array(string|null)
53
-     */
54
-    protected $removedExtensions = array(
55
-        'activescript' => array(
56
-            '5.1' => true,
57
-            'alternative' => 'pecl/activescript',
58
-        ),
59
-        'cpdf' => array(
60
-            '5.1' => true,
61
-            'alternative' => 'pecl/pdflib',
62
-        ),
63
-        'dbase' => array(
64
-            '5.3' => true,
65
-            'alternative' => null,
66
-        ),
67
-        'dbx' => array(
68
-            '5.1' => true,
69
-            'alternative' => 'pecl/dbx',
70
-        ),
71
-        'dio' => array(
72
-            '5.1' => true,
73
-            'alternative' => 'pecl/dio',
74
-        ),
75
-        'ereg' => array(
76
-            '5.3' => false,
77
-            '7.0' => true,
78
-            'alternative' => 'pcre',
79
-        ),
80
-        'fam' => array(
81
-            '5.1' => true,
82
-            'alternative' => null,
83
-        ),
84
-        'fbsql' => array(
85
-            '5.3' => true,
86
-            'alternative' => null,
87
-        ),
88
-        'fdf' => array(
89
-            '5.3' => true,
90
-            'alternative' => 'pecl/fdf',
91
-        ),
92
-        'filepro' => array(
93
-            '5.2' => true,
94
-            'alternative' => null,
95
-        ),
96
-        'hw_api' => array(
97
-            '5.2' => true,
98
-            'alternative' => null,
99
-        ),
100
-        'ibase' => array(
101
-            '7.4' => true,
102
-            'alternative' => 'pecl/ibase',
103
-        ),
104
-        'ingres' => array(
105
-            '5.1' => true,
106
-            'alternative' => 'pecl/ingres',
107
-        ),
108
-        'ircg' => array(
109
-            '5.1' => true,
110
-            'alternative' => null,
111
-        ),
112
-        'mcrypt' => array(
113
-            '7.1' => false,
114
-            '7.2' => true,
115
-            'alternative' => 'openssl (preferred) or pecl/mcrypt once available',
116
-        ),
117
-        'mcve' => array(
118
-            '5.1' => true,
119
-            'alternative' => 'pecl/mcve',
120
-        ),
121
-        'ming' => array(
122
-            '5.3' => true,
123
-            'alternative' => 'pecl/ming',
124
-        ),
125
-        'mnogosearch' => array(
126
-            '5.1' => true,
127
-            'alternative' => null,
128
-        ),
129
-        'msql' => array(
130
-            '5.3' => true,
131
-            'alternative' => null,
132
-        ),
133
-        'mssql' => array(
134
-            '7.0' => true,
135
-            'alternative' => null,
136
-        ),
137
-        'mysql_' => array(
138
-            '5.5' => false,
139
-            '7.0' => true,
140
-            'alternative' => 'mysqli',
141
-        ),
142
-        'ncurses' => array(
143
-            '5.3' => true,
144
-            'alternative' => 'pecl/ncurses',
145
-        ),
146
-        'oracle' => array(
147
-            '5.1' => true,
148
-            'alternative' => 'oci8 or pdo_oci',
149
-        ),
150
-        'ovrimos' => array(
151
-            '5.1' => true,
152
-            'alternative' => null,
153
-        ),
154
-        'pfpro_' => array(
155
-            '5.1' => true,
156
-            'alternative' => null,
157
-        ),
158
-        'sqlite' => array(
159
-            '5.4' => true,
160
-            'alternative' => null,
161
-        ),
162
-        // Has to be before `sybase` as otherwise it will never match.
163
-        'sybase_ct' => array(
164
-            '7.0' => true,
165
-            'alternative' => null,
166
-        ),
167
-        'sybase' => array(
168
-            '5.3' => true,
169
-            'alternative' => 'sybase_ct',
170
-        ),
171
-        'w32api' => array(
172
-            '5.1' => true,
173
-            'alternative' => 'pecl/ffi',
174
-        ),
175
-        'wddx' => array(
176
-            '7.4' => true,
177
-            'alternative' => 'pecl/wddx',
178
-        ),
179
-        'yp' => array(
180
-            '5.1' => true,
181
-            'alternative' => null,
182
-        ),
183
-    );
46
+	/**
47
+	 * A list of removed extensions with their alternative, if any
48
+	 *
49
+	 * The array lists : version number with false (deprecated) and true (removed).
50
+	 * If's sufficient to list the first version where the extension was deprecated/removed.
51
+	 *
52
+	 * @var array(string|null)
53
+	 */
54
+	protected $removedExtensions = array(
55
+		'activescript' => array(
56
+			'5.1' => true,
57
+			'alternative' => 'pecl/activescript',
58
+		),
59
+		'cpdf' => array(
60
+			'5.1' => true,
61
+			'alternative' => 'pecl/pdflib',
62
+		),
63
+		'dbase' => array(
64
+			'5.3' => true,
65
+			'alternative' => null,
66
+		),
67
+		'dbx' => array(
68
+			'5.1' => true,
69
+			'alternative' => 'pecl/dbx',
70
+		),
71
+		'dio' => array(
72
+			'5.1' => true,
73
+			'alternative' => 'pecl/dio',
74
+		),
75
+		'ereg' => array(
76
+			'5.3' => false,
77
+			'7.0' => true,
78
+			'alternative' => 'pcre',
79
+		),
80
+		'fam' => array(
81
+			'5.1' => true,
82
+			'alternative' => null,
83
+		),
84
+		'fbsql' => array(
85
+			'5.3' => true,
86
+			'alternative' => null,
87
+		),
88
+		'fdf' => array(
89
+			'5.3' => true,
90
+			'alternative' => 'pecl/fdf',
91
+		),
92
+		'filepro' => array(
93
+			'5.2' => true,
94
+			'alternative' => null,
95
+		),
96
+		'hw_api' => array(
97
+			'5.2' => true,
98
+			'alternative' => null,
99
+		),
100
+		'ibase' => array(
101
+			'7.4' => true,
102
+			'alternative' => 'pecl/ibase',
103
+		),
104
+		'ingres' => array(
105
+			'5.1' => true,
106
+			'alternative' => 'pecl/ingres',
107
+		),
108
+		'ircg' => array(
109
+			'5.1' => true,
110
+			'alternative' => null,
111
+		),
112
+		'mcrypt' => array(
113
+			'7.1' => false,
114
+			'7.2' => true,
115
+			'alternative' => 'openssl (preferred) or pecl/mcrypt once available',
116
+		),
117
+		'mcve' => array(
118
+			'5.1' => true,
119
+			'alternative' => 'pecl/mcve',
120
+		),
121
+		'ming' => array(
122
+			'5.3' => true,
123
+			'alternative' => 'pecl/ming',
124
+		),
125
+		'mnogosearch' => array(
126
+			'5.1' => true,
127
+			'alternative' => null,
128
+		),
129
+		'msql' => array(
130
+			'5.3' => true,
131
+			'alternative' => null,
132
+		),
133
+		'mssql' => array(
134
+			'7.0' => true,
135
+			'alternative' => null,
136
+		),
137
+		'mysql_' => array(
138
+			'5.5' => false,
139
+			'7.0' => true,
140
+			'alternative' => 'mysqli',
141
+		),
142
+		'ncurses' => array(
143
+			'5.3' => true,
144
+			'alternative' => 'pecl/ncurses',
145
+		),
146
+		'oracle' => array(
147
+			'5.1' => true,
148
+			'alternative' => 'oci8 or pdo_oci',
149
+		),
150
+		'ovrimos' => array(
151
+			'5.1' => true,
152
+			'alternative' => null,
153
+		),
154
+		'pfpro_' => array(
155
+			'5.1' => true,
156
+			'alternative' => null,
157
+		),
158
+		'sqlite' => array(
159
+			'5.4' => true,
160
+			'alternative' => null,
161
+		),
162
+		// Has to be before `sybase` as otherwise it will never match.
163
+		'sybase_ct' => array(
164
+			'7.0' => true,
165
+			'alternative' => null,
166
+		),
167
+		'sybase' => array(
168
+			'5.3' => true,
169
+			'alternative' => 'sybase_ct',
170
+		),
171
+		'w32api' => array(
172
+			'5.1' => true,
173
+			'alternative' => 'pecl/ffi',
174
+		),
175
+		'wddx' => array(
176
+			'7.4' => true,
177
+			'alternative' => 'pecl/wddx',
178
+		),
179
+		'yp' => array(
180
+			'5.1' => true,
181
+			'alternative' => null,
182
+		),
183
+	);
184 184
 
185
-    /**
186
-     * Returns an array of tokens this test wants to listen for.
187
-     *
188
-     * @return array
189
-     */
190
-    public function register()
191
-    {
192
-        // Handle case-insensitivity of function names.
193
-        $this->removedExtensions = $this->arrayKeysToLowercase($this->removedExtensions);
185
+	/**
186
+	 * Returns an array of tokens this test wants to listen for.
187
+	 *
188
+	 * @return array
189
+	 */
190
+	public function register()
191
+	{
192
+		// Handle case-insensitivity of function names.
193
+		$this->removedExtensions = $this->arrayKeysToLowercase($this->removedExtensions);
194 194
 
195
-        return array(\T_STRING);
196
-    }
195
+		return array(\T_STRING);
196
+	}
197 197
 
198
-    /**
199
-     * Processes this test, when one of its tokens is encountered.
200
-     *
201
-     * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
202
-     * @param int                   $stackPtr  The position of the current token in the
203
-     *                                         stack passed in $tokens.
204
-     *
205
-     * @return void
206
-     */
207
-    public function process(File $phpcsFile, $stackPtr)
208
-    {
209
-        $tokens = $phpcsFile->getTokens();
198
+	/**
199
+	 * Processes this test, when one of its tokens is encountered.
200
+	 *
201
+	 * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
202
+	 * @param int                   $stackPtr  The position of the current token in the
203
+	 *                                         stack passed in $tokens.
204
+	 *
205
+	 * @return void
206
+	 */
207
+	public function process(File $phpcsFile, $stackPtr)
208
+	{
209
+		$tokens = $phpcsFile->getTokens();
210 210
 
211
-        // Find the next non-empty token.
212
-        $openBracket = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
211
+		// Find the next non-empty token.
212
+		$openBracket = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
213 213
 
214
-        if ($tokens[$openBracket]['code'] !== \T_OPEN_PARENTHESIS) {
215
-            // Not a function call.
216
-            return;
217
-        }
214
+		if ($tokens[$openBracket]['code'] !== \T_OPEN_PARENTHESIS) {
215
+			// Not a function call.
216
+			return;
217
+		}
218 218
 
219
-        if (isset($tokens[$openBracket]['parenthesis_closer']) === false) {
220
-            // Not a function call.
221
-            return;
222
-        }
219
+		if (isset($tokens[$openBracket]['parenthesis_closer']) === false) {
220
+			// Not a function call.
221
+			return;
222
+		}
223 223
 
224
-        // Find the previous non-empty token.
225
-        $search   = Tokens::$emptyTokens;
226
-        $search[] = \T_BITWISE_AND;
227
-        $previous = $phpcsFile->findPrevious($search, ($stackPtr - 1), null, true);
228
-        if ($tokens[$previous]['code'] === \T_FUNCTION) {
229
-            // It's a function definition, not a function call.
230
-            return;
231
-        }
224
+		// Find the previous non-empty token.
225
+		$search   = Tokens::$emptyTokens;
226
+		$search[] = \T_BITWISE_AND;
227
+		$previous = $phpcsFile->findPrevious($search, ($stackPtr - 1), null, true);
228
+		if ($tokens[$previous]['code'] === \T_FUNCTION) {
229
+			// It's a function definition, not a function call.
230
+			return;
231
+		}
232 232
 
233
-        if ($tokens[$previous]['code'] === \T_NEW) {
234
-            // We are creating an object, not calling a function.
235
-            return;
236
-        }
233
+		if ($tokens[$previous]['code'] === \T_NEW) {
234
+			// We are creating an object, not calling a function.
235
+			return;
236
+		}
237 237
 
238
-        if ($tokens[$previous]['code'] === \T_OBJECT_OPERATOR) {
239
-            // We are calling a method of an object.
240
-            return;
241
-        }
238
+		if ($tokens[$previous]['code'] === \T_OBJECT_OPERATOR) {
239
+			// We are calling a method of an object.
240
+			return;
241
+		}
242 242
 
243
-        $function   = $tokens[$stackPtr]['content'];
244
-        $functionLc = strtolower($function);
243
+		$function   = $tokens[$stackPtr]['content'];
244
+		$functionLc = strtolower($function);
245 245
 
246
-        if ($this->isWhiteListed($functionLc) === true) {
247
-            // Function is whitelisted.
248
-            return;
249
-        }
246
+		if ($this->isWhiteListed($functionLc) === true) {
247
+			// Function is whitelisted.
248
+			return;
249
+		}
250 250
 
251
-        foreach ($this->removedExtensions as $extension => $versionList) {
252
-            if (strpos($functionLc, $extension) === 0) {
253
-                $itemInfo = array(
254
-                    'name'   => $extension,
255
-                );
256
-                $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
257
-                break;
258
-            }
259
-        }
260
-    }
251
+		foreach ($this->removedExtensions as $extension => $versionList) {
252
+			if (strpos($functionLc, $extension) === 0) {
253
+				$itemInfo = array(
254
+					'name'   => $extension,
255
+				);
256
+				$this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
257
+				break;
258
+			}
259
+		}
260
+	}
261 261
 
262 262
 
263
-    /**
264
-     * Is the current function being checked whitelisted ?
265
-     *
266
-     * Parsing the list late as it may be provided as a property, but also inline.
267
-     *
268
-     * @param string $content Content of the current token.
269
-     *
270
-     * @return bool
271
-     */
272
-    protected function isWhiteListed($content)
273
-    {
274
-        if (isset($this->functionWhitelist) === false) {
275
-            return false;
276
-        }
263
+	/**
264
+	 * Is the current function being checked whitelisted ?
265
+	 *
266
+	 * Parsing the list late as it may be provided as a property, but also inline.
267
+	 *
268
+	 * @param string $content Content of the current token.
269
+	 *
270
+	 * @return bool
271
+	 */
272
+	protected function isWhiteListed($content)
273
+	{
274
+		if (isset($this->functionWhitelist) === false) {
275
+			return false;
276
+		}
277 277
 
278
-        if (\is_string($this->functionWhitelist) === true) {
279
-            if (strpos($this->functionWhitelist, ',') !== false) {
280
-                $this->functionWhitelist = explode(',', $this->functionWhitelist);
281
-            } else {
282
-                $this->functionWhitelist = (array) $this->functionWhitelist;
283
-            }
284
-        }
278
+		if (\is_string($this->functionWhitelist) === true) {
279
+			if (strpos($this->functionWhitelist, ',') !== false) {
280
+				$this->functionWhitelist = explode(',', $this->functionWhitelist);
281
+			} else {
282
+				$this->functionWhitelist = (array) $this->functionWhitelist;
283
+			}
284
+		}
285 285
 
286
-        if (\is_array($this->functionWhitelist) === true) {
287
-            $this->functionWhitelist = array_map('strtolower', $this->functionWhitelist);
288
-            return \in_array($content, $this->functionWhitelist, true);
289
-        }
286
+		if (\is_array($this->functionWhitelist) === true) {
287
+			$this->functionWhitelist = array_map('strtolower', $this->functionWhitelist);
288
+			return \in_array($content, $this->functionWhitelist, true);
289
+		}
290 290
 
291
-        return false;
292
-    }
291
+		return false;
292
+	}
293 293
 
294 294
 
295
-    /**
296
-     * Get the relevant sub-array for a specific item from a multi-dimensional array.
297
-     *
298
-     * @param array $itemInfo Base information about the item.
299
-     *
300
-     * @return array Version and other information about the item.
301
-     */
302
-    public function getItemArray(array $itemInfo)
303
-    {
304
-        return $this->removedExtensions[$itemInfo['name']];
305
-    }
295
+	/**
296
+	 * Get the relevant sub-array for a specific item from a multi-dimensional array.
297
+	 *
298
+	 * @param array $itemInfo Base information about the item.
299
+	 *
300
+	 * @return array Version and other information about the item.
301
+	 */
302
+	public function getItemArray(array $itemInfo)
303
+	{
304
+		return $this->removedExtensions[$itemInfo['name']];
305
+	}
306 306
 
307 307
 
308
-    /**
309
-     * Get the error message template for this sniff.
310
-     *
311
-     * @return string
312
-     */
313
-    protected function getErrorMsgTemplate()
314
-    {
315
-        return "Extension '%s' is ";
316
-    }
308
+	/**
309
+	 * Get the error message template for this sniff.
310
+	 *
311
+	 * @return string
312
+	 */
313
+	protected function getErrorMsgTemplate()
314
+	{
315
+		return "Extension '%s' is ";
316
+	}
317 317
 }
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -190,9 +190,9 @@  discard block
 block discarded – undo
190 190
     public function register()
191 191
     {
192 192
         // Handle case-insensitivity of function names.
193
-        $this->removedExtensions = $this->arrayKeysToLowercase($this->removedExtensions);
193
+        $this->removedExtensions = $this->arrayKeysToLowercase( $this->removedExtensions );
194 194
 
195
-        return array(\T_STRING);
195
+        return array( \T_STRING );
196 196
     }
197 197
 
198 198
     /**
@@ -204,56 +204,56 @@  discard block
 block discarded – undo
204 204
      *
205 205
      * @return void
206 206
      */
207
-    public function process(File $phpcsFile, $stackPtr)
207
+    public function process( File $phpcsFile, $stackPtr )
208 208
     {
209 209
         $tokens = $phpcsFile->getTokens();
210 210
 
211 211
         // Find the next non-empty token.
212
-        $openBracket = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
212
+        $openBracket = $phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true );
213 213
 
214
-        if ($tokens[$openBracket]['code'] !== \T_OPEN_PARENTHESIS) {
214
+        if ( $tokens[ $openBracket ][ 'code' ] !== \T_OPEN_PARENTHESIS ) {
215 215
             // Not a function call.
216 216
             return;
217 217
         }
218 218
 
219
-        if (isset($tokens[$openBracket]['parenthesis_closer']) === false) {
219
+        if ( isset( $tokens[ $openBracket ][ 'parenthesis_closer' ] ) === false ) {
220 220
             // Not a function call.
221 221
             return;
222 222
         }
223 223
 
224 224
         // Find the previous non-empty token.
225 225
         $search   = Tokens::$emptyTokens;
226
-        $search[] = \T_BITWISE_AND;
227
-        $previous = $phpcsFile->findPrevious($search, ($stackPtr - 1), null, true);
228
-        if ($tokens[$previous]['code'] === \T_FUNCTION) {
226
+        $search[ ] = \T_BITWISE_AND;
227
+        $previous = $phpcsFile->findPrevious( $search, ( $stackPtr - 1 ), null, true );
228
+        if ( $tokens[ $previous ][ 'code' ] === \T_FUNCTION ) {
229 229
             // It's a function definition, not a function call.
230 230
             return;
231 231
         }
232 232
 
233
-        if ($tokens[$previous]['code'] === \T_NEW) {
233
+        if ( $tokens[ $previous ][ 'code' ] === \T_NEW ) {
234 234
             // We are creating an object, not calling a function.
235 235
             return;
236 236
         }
237 237
 
238
-        if ($tokens[$previous]['code'] === \T_OBJECT_OPERATOR) {
238
+        if ( $tokens[ $previous ][ 'code' ] === \T_OBJECT_OPERATOR ) {
239 239
             // We are calling a method of an object.
240 240
             return;
241 241
         }
242 242
 
243
-        $function   = $tokens[$stackPtr]['content'];
244
-        $functionLc = strtolower($function);
243
+        $function   = $tokens[ $stackPtr ][ 'content' ];
244
+        $functionLc = strtolower( $function );
245 245
 
246
-        if ($this->isWhiteListed($functionLc) === true) {
246
+        if ( $this->isWhiteListed( $functionLc ) === true ) {
247 247
             // Function is whitelisted.
248 248
             return;
249 249
         }
250 250
 
251
-        foreach ($this->removedExtensions as $extension => $versionList) {
252
-            if (strpos($functionLc, $extension) === 0) {
251
+        foreach ( $this->removedExtensions as $extension => $versionList ) {
252
+            if ( strpos( $functionLc, $extension ) === 0 ) {
253 253
                 $itemInfo = array(
254 254
                     'name'   => $extension,
255 255
                 );
256
-                $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
256
+                $this->handleFeature( $phpcsFile, $stackPtr, $itemInfo );
257 257
                 break;
258 258
             }
259 259
         }
@@ -269,23 +269,23 @@  discard block
 block discarded – undo
269 269
      *
270 270
      * @return bool
271 271
      */
272
-    protected function isWhiteListed($content)
272
+    protected function isWhiteListed( $content )
273 273
     {
274
-        if (isset($this->functionWhitelist) === false) {
274
+        if ( isset( $this->functionWhitelist ) === false ) {
275 275
             return false;
276 276
         }
277 277
 
278
-        if (\is_string($this->functionWhitelist) === true) {
279
-            if (strpos($this->functionWhitelist, ',') !== false) {
280
-                $this->functionWhitelist = explode(',', $this->functionWhitelist);
278
+        if ( \is_string( $this->functionWhitelist ) === true ) {
279
+            if ( strpos( $this->functionWhitelist, ',' ) !== false ) {
280
+                $this->functionWhitelist = explode( ',', $this->functionWhitelist );
281 281
             } else {
282
-                $this->functionWhitelist = (array) $this->functionWhitelist;
282
+                $this->functionWhitelist = (array)$this->functionWhitelist;
283 283
             }
284 284
         }
285 285
 
286
-        if (\is_array($this->functionWhitelist) === true) {
287
-            $this->functionWhitelist = array_map('strtolower', $this->functionWhitelist);
288
-            return \in_array($content, $this->functionWhitelist, true);
286
+        if ( \is_array( $this->functionWhitelist ) === true ) {
287
+            $this->functionWhitelist = array_map( 'strtolower', $this->functionWhitelist );
288
+            return \in_array( $content, $this->functionWhitelist, true );
289 289
         }
290 290
 
291 291
         return false;
@@ -299,9 +299,9 @@  discard block
 block discarded – undo
299 299
      *
300 300
      * @return array Version and other information about the item.
301 301
      */
302
-    public function getItemArray(array $itemInfo)
302
+    public function getItemArray( array $itemInfo )
303 303
     {
304
-        return $this->removedExtensions[$itemInfo['name']];
304
+        return $this->removedExtensions[ $itemInfo[ 'name' ] ];
305 305
     }
306 306
 
307 307
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -24,8 +24,7 @@  discard block
 block discarded – undo
24 24
  * @author    Wim Godden <[email protected]>
25 25
  * @copyright 2012 Cu.be Solutions bvba
26 26
  */
27
-class RemovedExtensionsSniff extends AbstractRemovedFeatureSniff
28
-{
27
+class RemovedExtensionsSniff extends AbstractRemovedFeatureSniff {
29 28
     /**
30 29
      * A list of functions to whitelist, if any.
31 30
      *
@@ -187,8 +186,7 @@  discard block
 block discarded – undo
187 186
      *
188 187
      * @return array
189 188
      */
190
-    public function register()
191
-    {
189
+    public function register() {
192 190
         // Handle case-insensitivity of function names.
193 191
         $this->removedExtensions = $this->arrayKeysToLowercase($this->removedExtensions);
194 192
 
@@ -204,8 +202,7 @@  discard block
 block discarded – undo
204 202
      *
205 203
      * @return void
206 204
      */
207
-    public function process(File $phpcsFile, $stackPtr)
208
-    {
205
+    public function process(File $phpcsFile, $stackPtr) {
209 206
         $tokens = $phpcsFile->getTokens();
210 207
 
211 208
         // Find the next non-empty token.
@@ -269,8 +266,7 @@  discard block
 block discarded – undo
269 266
      *
270 267
      * @return bool
271 268
      */
272
-    protected function isWhiteListed($content)
273
-    {
269
+    protected function isWhiteListed($content) {
274 270
         if (isset($this->functionWhitelist) === false) {
275 271
             return false;
276 272
         }
@@ -299,8 +295,7 @@  discard block
 block discarded – undo
299 295
      *
300 296
      * @return array Version and other information about the item.
301 297
      */
302
-    public function getItemArray(array $itemInfo)
303
-    {
298
+    public function getItemArray(array $itemInfo) {
304 299
         return $this->removedExtensions[$itemInfo['name']];
305 300
     }
306 301
 
@@ -310,8 +305,7 @@  discard block
 block discarded – undo
310 305
      *
311 306
      * @return string
312 307
      */
313
-    protected function getErrorMsgTemplate()
314
-    {
308
+    protected function getErrorMsgTemplate() {
315 309
         return "Extension '%s' is ";
316 310
     }
317 311
 }
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@
 block discarded – undo
65 65
     /**
66 66
      * Returns an array of tokens this test wants to listen for.
67 67
      *
68
-     * @return array
68
+     * @return integer[]
69 69
      */
70 70
     public function register()
71 71
     {
Please login to merge, or discard this patch.
PHPCompatibility/Sniffs/UseDeclarations/NewGroupUseDeclarationsSniff.php 3 patches
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -26,80 +26,80 @@
 block discarded – undo
26 26
  */
27 27
 class NewGroupUseDeclarationsSniff extends Sniff
28 28
 {
29
-    /**
30
-     * Returns an array of tokens this test wants to listen for.
31
-     *
32
-     * @return array
33
-     */
34
-    public function register()
35
-    {
36
-        if (\defined('T_OPEN_USE_GROUP')) {
37
-            return array(\T_OPEN_USE_GROUP);
38
-        } else {
39
-            return array(\T_USE);
40
-        }
41
-    }
29
+	/**
30
+	 * Returns an array of tokens this test wants to listen for.
31
+	 *
32
+	 * @return array
33
+	 */
34
+	public function register()
35
+	{
36
+		if (\defined('T_OPEN_USE_GROUP')) {
37
+			return array(\T_OPEN_USE_GROUP);
38
+		} else {
39
+			return array(\T_USE);
40
+		}
41
+	}
42 42
 
43 43
 
44
-    /**
45
-     * Processes this test, when one of its tokens is encountered.
46
-     *
47
-     * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
48
-     * @param int                   $stackPtr  The position of the current token in
49
-     *                                         the stack passed in $tokens.
50
-     *
51
-     * @return void
52
-     */
53
-    public function process(File $phpcsFile, $stackPtr)
54
-    {
55
-        if ($this->supportsBelow('7.1') === false) {
56
-            return;
57
-        }
44
+	/**
45
+	 * Processes this test, when one of its tokens is encountered.
46
+	 *
47
+	 * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
48
+	 * @param int                   $stackPtr  The position of the current token in
49
+	 *                                         the stack passed in $tokens.
50
+	 *
51
+	 * @return void
52
+	 */
53
+	public function process(File $phpcsFile, $stackPtr)
54
+	{
55
+		if ($this->supportsBelow('7.1') === false) {
56
+			return;
57
+		}
58 58
 
59
-        $tokens = $phpcsFile->getTokens();
60
-        $token  = $tokens[$stackPtr];
59
+		$tokens = $phpcsFile->getTokens();
60
+		$token  = $tokens[$stackPtr];
61 61
 
62
-        // Deal with PHPCS pre-2.6.0.
63
-        if ($token['code'] === \T_USE) {
64
-            $hasCurlyBrace = $phpcsFile->findNext(\T_OPEN_CURLY_BRACKET, ($stackPtr + 1), null, false, null, true);
65
-            if ($hasCurlyBrace === false) {
66
-                return;
67
-            }
62
+		// Deal with PHPCS pre-2.6.0.
63
+		if ($token['code'] === \T_USE) {
64
+			$hasCurlyBrace = $phpcsFile->findNext(\T_OPEN_CURLY_BRACKET, ($stackPtr + 1), null, false, null, true);
65
+			if ($hasCurlyBrace === false) {
66
+				return;
67
+			}
68 68
 
69
-            $prevToken = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($hasCurlyBrace - 1), null, true);
70
-            if ($prevToken === false || $tokens[$prevToken]['code'] !== \T_NS_SEPARATOR) {
71
-                return;
72
-            }
69
+			$prevToken = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($hasCurlyBrace - 1), null, true);
70
+			if ($prevToken === false || $tokens[$prevToken]['code'] !== \T_NS_SEPARATOR) {
71
+				return;
72
+			}
73 73
 
74
-            $stackPtr = $hasCurlyBrace;
75
-        }
74
+			$stackPtr = $hasCurlyBrace;
75
+		}
76 76
 
77
-        // Still here ? In that case, it is a group use statement.
78
-        if ($this->supportsBelow('5.6') === true) {
79
-            $phpcsFile->addError(
80
-                'Group use declarations are not allowed in PHP 5.6 or earlier',
81
-                $stackPtr,
82
-                'Found'
83
-            );
84
-        }
77
+		// Still here ? In that case, it is a group use statement.
78
+		if ($this->supportsBelow('5.6') === true) {
79
+			$phpcsFile->addError(
80
+				'Group use declarations are not allowed in PHP 5.6 or earlier',
81
+				$stackPtr,
82
+				'Found'
83
+			);
84
+		}
85 85
 
86
-        $closers = array(\T_CLOSE_CURLY_BRACKET);
87
-        if (\defined('T_CLOSE_USE_GROUP')) {
88
-            $closers[] = \T_CLOSE_USE_GROUP;
89
-        }
86
+		$closers = array(\T_CLOSE_CURLY_BRACKET);
87
+		if (\defined('T_CLOSE_USE_GROUP')) {
88
+			$closers[] = \T_CLOSE_USE_GROUP;
89
+		}
90 90
 
91
-        $closeCurly = $phpcsFile->findNext($closers, ($stackPtr + 1), null, false, null, true);
92
-        if ($closeCurly === false) {
93
-            return;
94
-        }
91
+		$closeCurly = $phpcsFile->findNext($closers, ($stackPtr + 1), null, false, null, true);
92
+		if ($closeCurly === false) {
93
+			return;
94
+		}
95 95
 
96
-        $prevToken = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($closeCurly - 1), null, true);
97
-        if ($tokens[$prevToken]['code'] === \T_COMMA) {
98
-            $phpcsFile->addError(
99
-                'Trailing comma\'s are not allowed in group use statements in PHP 7.1 or earlier',
100
-                $prevToken,
101
-                'TrailingCommaFound'
102
-            );
103
-        }
104
-    }
96
+		$prevToken = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($closeCurly - 1), null, true);
97
+		if ($tokens[$prevToken]['code'] === \T_COMMA) {
98
+			$phpcsFile->addError(
99
+				'Trailing comma\'s are not allowed in group use statements in PHP 7.1 or earlier',
100
+				$prevToken,
101
+				'TrailingCommaFound'
102
+			);
103
+		}
104
+	}
105 105
 }
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -33,10 +33,10 @@  discard block
 block discarded – undo
33 33
      */
34 34
     public function register()
35 35
     {
36
-        if (\defined('T_OPEN_USE_GROUP')) {
37
-            return array(\T_OPEN_USE_GROUP);
36
+        if ( \defined( 'T_OPEN_USE_GROUP' ) ) {
37
+            return array( \T_OPEN_USE_GROUP );
38 38
         } else {
39
-            return array(\T_USE);
39
+            return array( \T_USE );
40 40
         }
41 41
     }
42 42
 
@@ -50,24 +50,24 @@  discard block
 block discarded – undo
50 50
      *
51 51
      * @return void
52 52
      */
53
-    public function process(File $phpcsFile, $stackPtr)
53
+    public function process( File $phpcsFile, $stackPtr )
54 54
     {
55
-        if ($this->supportsBelow('7.1') === false) {
55
+        if ( $this->supportsBelow( '7.1' ) === false ) {
56 56
             return;
57 57
         }
58 58
 
59 59
         $tokens = $phpcsFile->getTokens();
60
-        $token  = $tokens[$stackPtr];
60
+        $token  = $tokens[ $stackPtr ];
61 61
 
62 62
         // Deal with PHPCS pre-2.6.0.
63
-        if ($token['code'] === \T_USE) {
64
-            $hasCurlyBrace = $phpcsFile->findNext(\T_OPEN_CURLY_BRACKET, ($stackPtr + 1), null, false, null, true);
65
-            if ($hasCurlyBrace === false) {
63
+        if ( $token[ 'code' ] === \T_USE ) {
64
+            $hasCurlyBrace = $phpcsFile->findNext( \T_OPEN_CURLY_BRACKET, ( $stackPtr + 1 ), null, false, null, true );
65
+            if ( $hasCurlyBrace === false ) {
66 66
                 return;
67 67
             }
68 68
 
69
-            $prevToken = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($hasCurlyBrace - 1), null, true);
70
-            if ($prevToken === false || $tokens[$prevToken]['code'] !== \T_NS_SEPARATOR) {
69
+            $prevToken = $phpcsFile->findPrevious( Tokens::$emptyTokens, ( $hasCurlyBrace - 1 ), null, true );
70
+            if ( $prevToken === false || $tokens[ $prevToken ][ 'code' ] !== \T_NS_SEPARATOR ) {
71 71
                 return;
72 72
             }
73 73
 
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
         }
76 76
 
77 77
         // Still here ? In that case, it is a group use statement.
78
-        if ($this->supportsBelow('5.6') === true) {
78
+        if ( $this->supportsBelow( '5.6' ) === true ) {
79 79
             $phpcsFile->addError(
80 80
                 'Group use declarations are not allowed in PHP 5.6 or earlier',
81 81
                 $stackPtr,
@@ -83,18 +83,18 @@  discard block
 block discarded – undo
83 83
             );
84 84
         }
85 85
 
86
-        $closers = array(\T_CLOSE_CURLY_BRACKET);
87
-        if (\defined('T_CLOSE_USE_GROUP')) {
88
-            $closers[] = \T_CLOSE_USE_GROUP;
86
+        $closers = array( \T_CLOSE_CURLY_BRACKET );
87
+        if ( \defined( 'T_CLOSE_USE_GROUP' ) ) {
88
+            $closers[ ] = \T_CLOSE_USE_GROUP;
89 89
         }
90 90
 
91
-        $closeCurly = $phpcsFile->findNext($closers, ($stackPtr + 1), null, false, null, true);
92
-        if ($closeCurly === false) {
91
+        $closeCurly = $phpcsFile->findNext( $closers, ( $stackPtr + 1 ), null, false, null, true );
92
+        if ( $closeCurly === false ) {
93 93
             return;
94 94
         }
95 95
 
96
-        $prevToken = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($closeCurly - 1), null, true);
97
-        if ($tokens[$prevToken]['code'] === \T_COMMA) {
96
+        $prevToken = $phpcsFile->findPrevious( Tokens::$emptyTokens, ( $closeCurly - 1 ), null, true );
97
+        if ( $tokens[ $prevToken ][ 'code' ] === \T_COMMA ) {
98 98
             $phpcsFile->addError(
99 99
                 'Trailing comma\'s are not allowed in group use statements in PHP 7.1 or earlier',
100 100
                 $prevToken,
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -24,15 +24,13 @@  discard block
 block discarded – undo
24 24
  * @package  PHPCompatibility
25 25
  * @author   Wim Godden <[email protected]>
26 26
  */
27
-class NewGroupUseDeclarationsSniff extends Sniff
28
-{
27
+class NewGroupUseDeclarationsSniff extends Sniff {
29 28
     /**
30 29
      * Returns an array of tokens this test wants to listen for.
31 30
      *
32 31
      * @return array
33 32
      */
34
-    public function register()
35
-    {
33
+    public function register() {
36 34
         if (\defined('T_OPEN_USE_GROUP')) {
37 35
             return array(\T_OPEN_USE_GROUP);
38 36
         } else {
@@ -50,8 +48,7 @@  discard block
 block discarded – undo
50 48
      *
51 49
      * @return void
52 50
      */
53
-    public function process(File $phpcsFile, $stackPtr)
54
-    {
51
+    public function process(File $phpcsFile, $stackPtr) {
55 52
         if ($this->supportsBelow('7.1') === false) {
56 53
             return;
57 54
         }
Please login to merge, or discard this patch.
PHPCompatibility/Sniffs/UseDeclarations/NewUseConstFunctionSniff.php 4 patches
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -31,72 +31,72 @@
 block discarded – undo
31 31
 class NewUseConstFunctionSniff extends Sniff
32 32
 {
33 33
 
34
-    /**
35
-     * A list of keywords that can follow use statements.
36
-     *
37
-     * @var array(string => string)
38
-     */
39
-    protected $validUseNames = array(
40
-        'const'    => true,
41
-        'function' => true,
42
-    );
34
+	/**
35
+	 * A list of keywords that can follow use statements.
36
+	 *
37
+	 * @var array(string => string)
38
+	 */
39
+	protected $validUseNames = array(
40
+		'const'    => true,
41
+		'function' => true,
42
+	);
43 43
 
44
-    /**
45
-     * Returns an array of tokens this test wants to listen for.
46
-     *
47
-     * @return array
48
-     */
49
-    public function register()
50
-    {
51
-        return array(\T_USE);
52
-    }
44
+	/**
45
+	 * Returns an array of tokens this test wants to listen for.
46
+	 *
47
+	 * @return array
48
+	 */
49
+	public function register()
50
+	{
51
+		return array(\T_USE);
52
+	}
53 53
 
54 54
 
55
-    /**
56
-     * Processes this test, when one of its tokens is encountered.
57
-     *
58
-     * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
59
-     * @param int                   $stackPtr  The position of the current token in the
60
-     *                                         stack passed in $tokens.
61
-     *
62
-     * @return void
63
-     */
64
-    public function process(File $phpcsFile, $stackPtr)
65
-    {
66
-        if ($this->supportsBelow('5.5') !== true) {
67
-            return;
68
-        }
55
+	/**
56
+	 * Processes this test, when one of its tokens is encountered.
57
+	 *
58
+	 * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
59
+	 * @param int                   $stackPtr  The position of the current token in the
60
+	 *                                         stack passed in $tokens.
61
+	 *
62
+	 * @return void
63
+	 */
64
+	public function process(File $phpcsFile, $stackPtr)
65
+	{
66
+		if ($this->supportsBelow('5.5') !== true) {
67
+			return;
68
+		}
69 69
 
70
-        $tokens = $phpcsFile->getTokens();
70
+		$tokens = $phpcsFile->getTokens();
71 71
 
72
-        $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
73
-        if ($nextNonEmpty === false) {
74
-            // Live coding.
75
-            return;
76
-        }
72
+		$nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
73
+		if ($nextNonEmpty === false) {
74
+			// Live coding.
75
+			return;
76
+		}
77 77
 
78
-        if (isset($this->validUseNames[strtolower($tokens[$nextNonEmpty]['content'])]) === false) {
79
-            // Not a `use const` or `use function` statement.
80
-            return;
81
-        }
78
+		if (isset($this->validUseNames[strtolower($tokens[$nextNonEmpty]['content'])]) === false) {
79
+			// Not a `use const` or `use function` statement.
80
+			return;
81
+		}
82 82
 
83
-        // `use const` and `use function` have to be followed by the function/constant name.
84
-        $functionOrConstName = $phpcsFile->findNext(Tokens::$emptyTokens, ($nextNonEmpty + 1), null, true);
85
-        if ($functionOrConstName === false
86
-            // Identifies as T_AS or T_STRING, this covers both.
87
-            || ($tokens[$functionOrConstName]['content'] === 'as'
88
-            || $tokens[$functionOrConstName]['code'] === \T_COMMA)
89
-        ) {
90
-            // Live coding or incorrect use of reserved keyword, but that is
91
-            // covered by the ForbiddenNames sniff.
92
-            return;
93
-        }
83
+		// `use const` and `use function` have to be followed by the function/constant name.
84
+		$functionOrConstName = $phpcsFile->findNext(Tokens::$emptyTokens, ($nextNonEmpty + 1), null, true);
85
+		if ($functionOrConstName === false
86
+			// Identifies as T_AS or T_STRING, this covers both.
87
+			|| ($tokens[$functionOrConstName]['content'] === 'as'
88
+			|| $tokens[$functionOrConstName]['code'] === \T_COMMA)
89
+		) {
90
+			// Live coding or incorrect use of reserved keyword, but that is
91
+			// covered by the ForbiddenNames sniff.
92
+			return;
93
+		}
94 94
 
95
-        // Still here ? In that case we have encountered a `use const` or `use function` statement.
96
-        $phpcsFile->addError(
97
-            'Importing functions and constants through a "use" statement is not supported in PHP 5.5 or lower.',
98
-            $nextNonEmpty,
99
-            'Found'
100
-        );
101
-    }
95
+		// Still here ? In that case we have encountered a `use const` or `use function` statement.
96
+		$phpcsFile->addError(
97
+			'Importing functions and constants through a "use" statement is not supported in PHP 5.5 or lower.',
98
+			$nextNonEmpty,
99
+			'Found'
100
+		);
101
+	}
102 102
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      */
49 49
     public function register()
50 50
     {
51
-        return array(\T_USE);
51
+        return array( \T_USE );
52 52
     }
53 53
 
54 54
 
@@ -61,31 +61,31 @@  discard block
 block discarded – undo
61 61
      *
62 62
      * @return void
63 63
      */
64
-    public function process(File $phpcsFile, $stackPtr)
64
+    public function process( File $phpcsFile, $stackPtr )
65 65
     {
66
-        if ($this->supportsBelow('5.5') !== true) {
66
+        if ( $this->supportsBelow( '5.5' ) !== true ) {
67 67
             return;
68 68
         }
69 69
 
70 70
         $tokens = $phpcsFile->getTokens();
71 71
 
72
-        $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
73
-        if ($nextNonEmpty === false) {
72
+        $nextNonEmpty = $phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true );
73
+        if ( $nextNonEmpty === false ) {
74 74
             // Live coding.
75 75
             return;
76 76
         }
77 77
 
78
-        if (isset($this->validUseNames[strtolower($tokens[$nextNonEmpty]['content'])]) === false) {
78
+        if ( isset( $this->validUseNames[ strtolower( $tokens[ $nextNonEmpty ][ 'content' ] ) ] ) === false ) {
79 79
             // Not a `use const` or `use function` statement.
80 80
             return;
81 81
         }
82 82
 
83 83
         // `use const` and `use function` have to be followed by the function/constant name.
84
-        $functionOrConstName = $phpcsFile->findNext(Tokens::$emptyTokens, ($nextNonEmpty + 1), null, true);
85
-        if ($functionOrConstName === false
84
+        $functionOrConstName = $phpcsFile->findNext( Tokens::$emptyTokens, ( $nextNonEmpty + 1 ), null, true );
85
+        if ( $functionOrConstName === false
86 86
             // Identifies as T_AS or T_STRING, this covers both.
87
-            || ($tokens[$functionOrConstName]['content'] === 'as'
88
-            || $tokens[$functionOrConstName]['code'] === \T_COMMA)
87
+            || ( $tokens[ $functionOrConstName ][ 'content' ] === 'as'
88
+            || $tokens[ $functionOrConstName ][ 'code' ] === \T_COMMA )
89 89
         ) {
90 90
             // Live coding or incorrect use of reserved keyword, but that is
91 91
             // covered by the ForbiddenNames sniff.
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -28,8 +28,7 @@  discard block
 block discarded – undo
28 28
  * @package  PHPCompatibility
29 29
  * @author   Juliette Reinders Folmer <[email protected]>
30 30
  */
31
-class NewUseConstFunctionSniff extends Sniff
32
-{
31
+class NewUseConstFunctionSniff extends Sniff {
33 32
 
34 33
     /**
35 34
      * A list of keywords that can follow use statements.
@@ -46,8 +45,7 @@  discard block
 block discarded – undo
46 45
      *
47 46
      * @return array
48 47
      */
49
-    public function register()
50
-    {
48
+    public function register() {
51 49
         return array(\T_USE);
52 50
     }
53 51
 
@@ -61,8 +59,7 @@  discard block
 block discarded – undo
61 59
      *
62 60
      * @return void
63 61
      */
64
-    public function process(File $phpcsFile, $stackPtr)
65
-    {
62
+    public function process(File $phpcsFile, $stackPtr) {
66 63
         if ($this->supportsBelow('5.5') !== true) {
67 64
             return;
68 65
         }
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@
 block discarded – undo
65 65
     /**
66 66
      * Returns an array of tokens this test wants to listen for.
67 67
      *
68
-     * @return array
68
+     * @return integer[]
69 69
      */
70 70
     public function register()
71 71
     {
Please login to merge, or discard this patch.