Completed
Pull Request — develop (#1492)
by Zack
28:58 queued 09:00
created
PHPCompatibility/Sniffs/Generators/NewGeneratorReturnSniff.php 3 patches
Indentation   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -28,29 +28,29 @@  discard block
 block discarded – undo
28 28
  */
29 29
 class NewGeneratorReturnSniff extends Sniff
30 30
 {
31
-    /**
32
-     * Scope conditions within which a yield can exist.
33
-     *
34
-     * @var array
35
-     */
36
-    private $validConditions = array(
37
-        \T_FUNCTION => \T_FUNCTION,
38
-        \T_CLOSURE  => \T_CLOSURE,
39
-    );
40
-
41
-
42
-    /**
43
-     * Returns an array of tokens this test wants to listen for.
44
-     *
45
-     * @return array
46
-     */
47
-    public function register()
48
-    {
49
-        $targets = array(
50
-            \T_YIELD,
51
-        );
52
-
53
-        /*
31
+	/**
32
+	 * Scope conditions within which a yield can exist.
33
+	 *
34
+	 * @var array
35
+	 */
36
+	private $validConditions = array(
37
+		\T_FUNCTION => \T_FUNCTION,
38
+		\T_CLOSURE  => \T_CLOSURE,
39
+	);
40
+
41
+
42
+	/**
43
+	 * Returns an array of tokens this test wants to listen for.
44
+	 *
45
+	 * @return array
46
+	 */
47
+	public function register()
48
+	{
49
+		$targets = array(
50
+			\T_YIELD,
51
+		);
52
+
53
+		/*
54 54
          * The `yield` keyword was introduced in PHP 5.5 with the token T_YIELD.
55 55
          * The `yield from` keyword was introduced in PHP 7.0 and tokenizes as
56 56
          * "T_YIELD T_WHITESPACE T_STRING".
@@ -63,91 +63,91 @@  discard block
 block discarded – undo
63 63
          * For PHP 5.5+ we need to look for T_YIELD.
64 64
          * For PHPCS 3.1.0+, we also need to look for T_YIELD_FROM.
65 65
          */
66
-        if (version_compare(\PHP_VERSION_ID, '50500', '<') === true
67
-            && version_compare(PHPCSHelper::getVersion(), '3.1.0', '<') === true
68
-        ) {
69
-            $targets[] = \T_STRING;
70
-        }
71
-
72
-        if (\defined('T_YIELD_FROM')) {
73
-            $targets[] = \T_YIELD_FROM;
74
-        }
75
-
76
-        return $targets;
77
-    }
78
-
79
-    /**
80
-     * Processes this test, when one of its tokens is encountered.
81
-     *
82
-     * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
83
-     * @param int                   $stackPtr  The position of the current token in the
84
-     *                                         stack passed in $tokens.
85
-     *
86
-     * @return void|int Void or a stack pointer to skip forward.
87
-     */
88
-    public function process(File $phpcsFile, $stackPtr)
89
-    {
90
-        if ($this->supportsBelow('5.6') !== true) {
91
-            return;
92
-        }
93
-
94
-        $tokens = $phpcsFile->getTokens();
95
-
96
-        if ($tokens[$stackPtr]['code'] === \T_STRING
97
-            && $tokens[$stackPtr]['content'] !== 'yield'
98
-        ) {
99
-            return;
100
-        }
101
-
102
-        if (empty($tokens[$stackPtr]['conditions']) === true) {
103
-            return;
104
-        }
105
-
106
-        // Walk the condition from inner to outer to see if we can find a valid function/closure scope.
107
-        $conditions = array_reverse($tokens[$stackPtr]['conditions'], true);
108
-        foreach ($conditions as $ptr => $type) {
109
-            if (isset($this->validConditions[$type]) === true) {
110
-                $function = $ptr;
111
-                break;
112
-            }
113
-        }
114
-
115
-        if (isset($function) === false) {
116
-            // Yield outside function scope, fatal error, but not our concern.
117
-            return;
118
-        }
119
-
120
-        if (isset($tokens[$function]['scope_opener'], $tokens[$function]['scope_closer']) === false) {
121
-            // Can't reliably determine start/end of function scope.
122
-            return;
123
-        }
124
-
125
-        $targets = array(\T_RETURN, \T_CLOSURE, \T_FUNCTION, \T_CLASS);
126
-        if (\defined('T_ANON_CLASS')) {
127
-            $targets[] = \T_ANON_CLASS;
128
-        }
129
-
130
-        $current = $tokens[$function]['scope_opener'];
131
-
132
-        while (($current = $phpcsFile->findNext($targets, ($current + 1), $tokens[$function]['scope_closer'])) !== false) {
133
-            if ($tokens[$current]['code'] === \T_RETURN) {
134
-                $phpcsFile->addError(
135
-                    'Returning a final expression from a generator was not supported in PHP 5.6 or earlier',
136
-                    $current,
137
-                    'ReturnFound'
138
-                );
139
-
140
-                return $tokens[$function]['scope_closer'];
141
-            }
142
-
143
-            // Found a nested scope in which return can exist without problems.
144
-            if (isset($tokens[$current]['scope_closer'])) {
145
-                // Skip past the nested scope.
146
-                $current = $tokens[$current]['scope_closer'];
147
-            }
148
-        }
149
-
150
-        // Don't examine this function again.
151
-        return $tokens[$function]['scope_closer'];
152
-    }
66
+		if (version_compare(\PHP_VERSION_ID, '50500', '<') === true
67
+			&& version_compare(PHPCSHelper::getVersion(), '3.1.0', '<') === true
68
+		) {
69
+			$targets[] = \T_STRING;
70
+		}
71
+
72
+		if (\defined('T_YIELD_FROM')) {
73
+			$targets[] = \T_YIELD_FROM;
74
+		}
75
+
76
+		return $targets;
77
+	}
78
+
79
+	/**
80
+	 * Processes this test, when one of its tokens is encountered.
81
+	 *
82
+	 * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
83
+	 * @param int                   $stackPtr  The position of the current token in the
84
+	 *                                         stack passed in $tokens.
85
+	 *
86
+	 * @return void|int Void or a stack pointer to skip forward.
87
+	 */
88
+	public function process(File $phpcsFile, $stackPtr)
89
+	{
90
+		if ($this->supportsBelow('5.6') !== true) {
91
+			return;
92
+		}
93
+
94
+		$tokens = $phpcsFile->getTokens();
95
+
96
+		if ($tokens[$stackPtr]['code'] === \T_STRING
97
+			&& $tokens[$stackPtr]['content'] !== 'yield'
98
+		) {
99
+			return;
100
+		}
101
+
102
+		if (empty($tokens[$stackPtr]['conditions']) === true) {
103
+			return;
104
+		}
105
+
106
+		// Walk the condition from inner to outer to see if we can find a valid function/closure scope.
107
+		$conditions = array_reverse($tokens[$stackPtr]['conditions'], true);
108
+		foreach ($conditions as $ptr => $type) {
109
+			if (isset($this->validConditions[$type]) === true) {
110
+				$function = $ptr;
111
+				break;
112
+			}
113
+		}
114
+
115
+		if (isset($function) === false) {
116
+			// Yield outside function scope, fatal error, but not our concern.
117
+			return;
118
+		}
119
+
120
+		if (isset($tokens[$function]['scope_opener'], $tokens[$function]['scope_closer']) === false) {
121
+			// Can't reliably determine start/end of function scope.
122
+			return;
123
+		}
124
+
125
+		$targets = array(\T_RETURN, \T_CLOSURE, \T_FUNCTION, \T_CLASS);
126
+		if (\defined('T_ANON_CLASS')) {
127
+			$targets[] = \T_ANON_CLASS;
128
+		}
129
+
130
+		$current = $tokens[$function]['scope_opener'];
131
+
132
+		while (($current = $phpcsFile->findNext($targets, ($current + 1), $tokens[$function]['scope_closer'])) !== false) {
133
+			if ($tokens[$current]['code'] === \T_RETURN) {
134
+				$phpcsFile->addError(
135
+					'Returning a final expression from a generator was not supported in PHP 5.6 or earlier',
136
+					$current,
137
+					'ReturnFound'
138
+				);
139
+
140
+				return $tokens[$function]['scope_closer'];
141
+			}
142
+
143
+			// Found a nested scope in which return can exist without problems.
144
+			if (isset($tokens[$current]['scope_closer'])) {
145
+				// Skip past the nested scope.
146
+				$current = $tokens[$current]['scope_closer'];
147
+			}
148
+		}
149
+
150
+		// Don't examine this function again.
151
+		return $tokens[$function]['scope_closer'];
152
+	}
153 153
 }
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -63,14 +63,14 @@  discard block
 block discarded – undo
63 63
          * For PHP 5.5+ we need to look for T_YIELD.
64 64
          * For PHPCS 3.1.0+, we also need to look for T_YIELD_FROM.
65 65
          */
66
-        if (version_compare(\PHP_VERSION_ID, '50500', '<') === true
67
-            && version_compare(PHPCSHelper::getVersion(), '3.1.0', '<') === true
66
+        if ( version_compare( \PHP_VERSION_ID, '50500', '<' ) === true
67
+            && version_compare( PHPCSHelper::getVersion(), '3.1.0', '<' ) === true
68 68
         ) {
69
-            $targets[] = \T_STRING;
69
+            $targets[ ] = \T_STRING;
70 70
         }
71 71
 
72
-        if (\defined('T_YIELD_FROM')) {
73
-            $targets[] = \T_YIELD_FROM;
72
+        if ( \defined( 'T_YIELD_FROM' ) ) {
73
+            $targets[ ] = \T_YIELD_FROM;
74 74
         }
75 75
 
76 76
         return $targets;
@@ -85,69 +85,69 @@  discard block
 block discarded – undo
85 85
      *
86 86
      * @return void|int Void or a stack pointer to skip forward.
87 87
      */
88
-    public function process(File $phpcsFile, $stackPtr)
88
+    public function process( File $phpcsFile, $stackPtr )
89 89
     {
90
-        if ($this->supportsBelow('5.6') !== true) {
90
+        if ( $this->supportsBelow( '5.6' ) !== true ) {
91 91
             return;
92 92
         }
93 93
 
94 94
         $tokens = $phpcsFile->getTokens();
95 95
 
96
-        if ($tokens[$stackPtr]['code'] === \T_STRING
97
-            && $tokens[$stackPtr]['content'] !== 'yield'
96
+        if ( $tokens[ $stackPtr ][ 'code' ] === \T_STRING
97
+            && $tokens[ $stackPtr ][ 'content' ] !== 'yield'
98 98
         ) {
99 99
             return;
100 100
         }
101 101
 
102
-        if (empty($tokens[$stackPtr]['conditions']) === true) {
102
+        if ( empty( $tokens[ $stackPtr ][ 'conditions' ] ) === true ) {
103 103
             return;
104 104
         }
105 105
 
106 106
         // Walk the condition from inner to outer to see if we can find a valid function/closure scope.
107
-        $conditions = array_reverse($tokens[$stackPtr]['conditions'], true);
108
-        foreach ($conditions as $ptr => $type) {
109
-            if (isset($this->validConditions[$type]) === true) {
107
+        $conditions = array_reverse( $tokens[ $stackPtr ][ 'conditions' ], true );
108
+        foreach ( $conditions as $ptr => $type ) {
109
+            if ( isset( $this->validConditions[ $type ] ) === true ) {
110 110
                 $function = $ptr;
111 111
                 break;
112 112
             }
113 113
         }
114 114
 
115
-        if (isset($function) === false) {
115
+        if ( isset( $function ) === false ) {
116 116
             // Yield outside function scope, fatal error, but not our concern.
117 117
             return;
118 118
         }
119 119
 
120
-        if (isset($tokens[$function]['scope_opener'], $tokens[$function]['scope_closer']) === false) {
120
+        if ( isset( $tokens[ $function ][ 'scope_opener' ], $tokens[ $function ][ 'scope_closer' ] ) === false ) {
121 121
             // Can't reliably determine start/end of function scope.
122 122
             return;
123 123
         }
124 124
 
125
-        $targets = array(\T_RETURN, \T_CLOSURE, \T_FUNCTION, \T_CLASS);
126
-        if (\defined('T_ANON_CLASS')) {
127
-            $targets[] = \T_ANON_CLASS;
125
+        $targets = array( \T_RETURN, \T_CLOSURE, \T_FUNCTION, \T_CLASS );
126
+        if ( \defined( 'T_ANON_CLASS' ) ) {
127
+            $targets[ ] = \T_ANON_CLASS;
128 128
         }
129 129
 
130
-        $current = $tokens[$function]['scope_opener'];
130
+        $current = $tokens[ $function ][ 'scope_opener' ];
131 131
 
132
-        while (($current = $phpcsFile->findNext($targets, ($current + 1), $tokens[$function]['scope_closer'])) !== false) {
133
-            if ($tokens[$current]['code'] === \T_RETURN) {
132
+        while ( ( $current = $phpcsFile->findNext( $targets, ( $current + 1 ), $tokens[ $function ][ 'scope_closer' ] ) ) !== false ) {
133
+            if ( $tokens[ $current ][ 'code' ] === \T_RETURN ) {
134 134
                 $phpcsFile->addError(
135 135
                     'Returning a final expression from a generator was not supported in PHP 5.6 or earlier',
136 136
                     $current,
137 137
                     'ReturnFound'
138 138
                 );
139 139
 
140
-                return $tokens[$function]['scope_closer'];
140
+                return $tokens[ $function ][ 'scope_closer' ];
141 141
             }
142 142
 
143 143
             // Found a nested scope in which return can exist without problems.
144
-            if (isset($tokens[$current]['scope_closer'])) {
144
+            if ( isset( $tokens[ $current ][ 'scope_closer' ] ) ) {
145 145
                 // Skip past the nested scope.
146
-                $current = $tokens[$current]['scope_closer'];
146
+                $current = $tokens[ $current ][ 'scope_closer' ];
147 147
             }
148 148
         }
149 149
 
150 150
         // Don't examine this function again.
151
-        return $tokens[$function]['scope_closer'];
151
+        return $tokens[ $function ][ 'scope_closer' ];
152 152
     }
153 153
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -26,8 +26,7 @@  discard block
 block discarded – undo
26 26
  * @package  PHPCompatibility
27 27
  * @author   Juliette Reinders Folmer <[email protected]>
28 28
  */
29
-class NewGeneratorReturnSniff extends Sniff
30
-{
29
+class NewGeneratorReturnSniff extends Sniff {
31 30
     /**
32 31
      * Scope conditions within which a yield can exist.
33 32
      *
@@ -44,8 +43,7 @@  discard block
 block discarded – undo
44 43
      *
45 44
      * @return array
46 45
      */
47
-    public function register()
48
-    {
46
+    public function register() {
49 47
         $targets = array(
50 48
             \T_YIELD,
51 49
         );
@@ -85,8 +83,7 @@  discard block
 block discarded – undo
85 83
      *
86 84
      * @return void|int Void or a stack pointer to skip forward.
87 85
      */
88
-    public function process(File $phpcsFile, $stackPtr)
89
-    {
86
+    public function process(File $phpcsFile, $stackPtr) {
90 87
         if ($this->supportsBelow('5.6') !== true) {
91 88
             return;
92 89
         }
Please login to merge, or discard this patch.
PHPCompatibility/Sniffs/MethodUse/ForbiddenToStringParametersSniff.php 4 patches
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -28,43 +28,43 @@  discard block
 block discarded – undo
28 28
 class ForbiddenToStringParametersSniff extends Sniff
29 29
 {
30 30
 
31
-    /**
32
-     * Returns an array of tokens this test wants to listen for.
33
-     *
34
-     * @since 9.2.0
35
-     *
36
-     * @return array
37
-     */
38
-    public function register()
39
-    {
40
-        return array(
41
-            \T_DOUBLE_COLON,
42
-            \T_OBJECT_OPERATOR,
43
-        );
44
-    }
31
+	/**
32
+	 * Returns an array of tokens this test wants to listen for.
33
+	 *
34
+	 * @since 9.2.0
35
+	 *
36
+	 * @return array
37
+	 */
38
+	public function register()
39
+	{
40
+		return array(
41
+			\T_DOUBLE_COLON,
42
+			\T_OBJECT_OPERATOR,
43
+		);
44
+	}
45 45
 
46
-    /**
47
-     * Processes this test, when one of its tokens is encountered.
48
-     *
49
-     * @since 9.2.0
50
-     *
51
-     * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
52
-     * @param int                   $stackPtr  The position of the current token
53
-     *                                         in the stack passed in $tokens.
54
-     *
55
-     * @return void
56
-     */
57
-    public function process(File $phpcsFile, $stackPtr)
58
-    {
59
-        if ($this->supportsAbove('5.3') === false) {
60
-            return;
61
-        }
46
+	/**
47
+	 * Processes this test, when one of its tokens is encountered.
48
+	 *
49
+	 * @since 9.2.0
50
+	 *
51
+	 * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
52
+	 * @param int                   $stackPtr  The position of the current token
53
+	 *                                         in the stack passed in $tokens.
54
+	 *
55
+	 * @return void
56
+	 */
57
+	public function process(File $phpcsFile, $stackPtr)
58
+	{
59
+		if ($this->supportsAbove('5.3') === false) {
60
+			return;
61
+		}
62 62
 
63
-        $tokens = $phpcsFile->getTokens();
63
+		$tokens = $phpcsFile->getTokens();
64 64
 
65
-        $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
66
-        if ($nextNonEmpty === false || $tokens[$nextNonEmpty]['code'] !== \T_STRING) {
67
-            /*
65
+		$nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
66
+		if ($nextNonEmpty === false || $tokens[$nextNonEmpty]['code'] !== \T_STRING) {
67
+			/*
68 68
              * Not a method call.
69 69
              *
70 70
              * Note: This disregards method calls with the method name in a variable, like:
@@ -72,31 +72,31 @@  discard block
 block discarded – undo
72 72
              *   $obj->$method();
73 73
              * However, that would be very hard to examine reliably anyway.
74 74
              */
75
-            return;
76
-        }
75
+			return;
76
+		}
77 77
 
78
-        if (strtolower($tokens[$nextNonEmpty]['content']) !== '__tostring') {
79
-            // Not a call to the __clone() method.
80
-            return;
81
-        }
78
+		if (strtolower($tokens[$nextNonEmpty]['content']) !== '__tostring') {
79
+			// Not a call to the __clone() method.
80
+			return;
81
+		}
82 82
 
83
-        $openParens = $phpcsFile->findNext(Tokens::$emptyTokens, ($nextNonEmpty + 1), null, true);
84
-        if ($openParens === false || $tokens[$openParens]['code'] !== \T_OPEN_PARENTHESIS) {
85
-            // Not a method call.
86
-            return;
87
-        }
83
+		$openParens = $phpcsFile->findNext(Tokens::$emptyTokens, ($nextNonEmpty + 1), null, true);
84
+		if ($openParens === false || $tokens[$openParens]['code'] !== \T_OPEN_PARENTHESIS) {
85
+			// Not a method call.
86
+			return;
87
+		}
88 88
 
89
-        $closeParens = $phpcsFile->findNext(Tokens::$emptyTokens, ($openParens + 1), null, true);
90
-        if ($closeParens === false || $tokens[$closeParens]['code'] === \T_CLOSE_PARENTHESIS) {
91
-            // Not a method call.
92
-            return;
93
-        }
89
+		$closeParens = $phpcsFile->findNext(Tokens::$emptyTokens, ($openParens + 1), null, true);
90
+		if ($closeParens === false || $tokens[$closeParens]['code'] === \T_CLOSE_PARENTHESIS) {
91
+			// Not a method call.
92
+			return;
93
+		}
94 94
 
95
-        // If we're still here, then this is a call to the __toString() magic method passing parameters.
96
-        $phpcsFile->addError(
97
-            'The __toString() magic method will no longer accept passed arguments since PHP 5.3',
98
-            $stackPtr,
99
-            'Passed'
100
-        );
101
-    }
95
+		// If we're still here, then this is a call to the __toString() magic method passing parameters.
96
+		$phpcsFile->addError(
97
+			'The __toString() magic method will no longer accept passed arguments since PHP 5.3',
98
+			$stackPtr,
99
+			'Passed'
100
+		);
101
+	}
102 102
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -54,16 +54,16 @@  discard block
 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.3') === false) {
59
+        if ( $this->supportsAbove( '5.3' ) === false ) {
60 60
             return;
61 61
         }
62 62
 
63 63
         $tokens = $phpcsFile->getTokens();
64 64
 
65
-        $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
66
-        if ($nextNonEmpty === false || $tokens[$nextNonEmpty]['code'] !== \T_STRING) {
65
+        $nextNonEmpty = $phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true );
66
+        if ( $nextNonEmpty === false || $tokens[ $nextNonEmpty ][ 'code' ] !== \T_STRING ) {
67 67
             /*
68 68
              * Not a method call.
69 69
              *
@@ -75,19 +75,19 @@  discard block
 block discarded – undo
75 75
             return;
76 76
         }
77 77
 
78
-        if (strtolower($tokens[$nextNonEmpty]['content']) !== '__tostring') {
78
+        if ( strtolower( $tokens[ $nextNonEmpty ][ 'content' ] ) !== '__tostring' ) {
79 79
             // Not a call to the __clone() method.
80 80
             return;
81 81
         }
82 82
 
83
-        $openParens = $phpcsFile->findNext(Tokens::$emptyTokens, ($nextNonEmpty + 1), null, true);
84
-        if ($openParens === false || $tokens[$openParens]['code'] !== \T_OPEN_PARENTHESIS) {
83
+        $openParens = $phpcsFile->findNext( Tokens::$emptyTokens, ( $nextNonEmpty + 1 ), null, true );
84
+        if ( $openParens === false || $tokens[ $openParens ][ 'code' ] !== \T_OPEN_PARENTHESIS ) {
85 85
             // Not a method call.
86 86
             return;
87 87
         }
88 88
 
89
-        $closeParens = $phpcsFile->findNext(Tokens::$emptyTokens, ($openParens + 1), null, true);
90
-        if ($closeParens === false || $tokens[$closeParens]['code'] === \T_CLOSE_PARENTHESIS) {
89
+        $closeParens = $phpcsFile->findNext( Tokens::$emptyTokens, ( $openParens + 1 ), null, true );
90
+        if ( $closeParens === false || $tokens[ $closeParens ][ 'code' ] === \T_CLOSE_PARENTHESIS ) {
91 91
             // Not a method call.
92 92
             return;
93 93
         }
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
  *
26 26
  * @since 9.2.0
27 27
  */
28
-class ForbiddenToStringParametersSniff extends Sniff
29
-{
28
+class ForbiddenToStringParametersSniff extends Sniff {
30 29
 
31 30
     /**
32 31
      * Returns an array of tokens this test wants to listen for.
@@ -35,8 +34,7 @@  discard block
 block discarded – undo
35 34
      *
36 35
      * @return array
37 36
      */
38
-    public function register()
39
-    {
37
+    public function register() {
40 38
         return array(
41 39
             \T_DOUBLE_COLON,
42 40
             \T_OBJECT_OPERATOR,
@@ -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.3') === false) {
60 57
             return;
61 58
         }
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.
Sniffs/FunctionNameRestrictions/RemovedMagicAutoloadSniff.php 4 patches
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -23,58 +23,58 @@
 block discarded – undo
23 23
  */
24 24
 class RemovedMagicAutoloadSniff extends Sniff
25 25
 {
26
-    /**
27
-     * Scopes to look for when testing using validDirectScope
28
-     *
29
-     * @var array
30
-     */
31
-    private $checkForScopes = array(
32
-        'T_CLASS'      => true,
33
-        'T_ANON_CLASS' => true,
34
-        'T_INTERFACE'  => true,
35
-        'T_TRAIT'      => true,
36
-        'T_NAMESPACE'  => true,
37
-    );
26
+	/**
27
+	 * Scopes to look for when testing using validDirectScope
28
+	 *
29
+	 * @var array
30
+	 */
31
+	private $checkForScopes = array(
32
+		'T_CLASS'      => true,
33
+		'T_ANON_CLASS' => true,
34
+		'T_INTERFACE'  => true,
35
+		'T_TRAIT'      => true,
36
+		'T_NAMESPACE'  => true,
37
+	);
38 38
 
39
-    /**
40
-     * Returns an array of tokens this test wants to listen for.
41
-     *
42
-     * @return array
43
-     */
44
-    public function register()
45
-    {
46
-        return array(\T_FUNCTION);
47
-    }
39
+	/**
40
+	 * Returns an array of tokens this test wants to listen for.
41
+	 *
42
+	 * @return array
43
+	 */
44
+	public function register()
45
+	{
46
+		return array(\T_FUNCTION);
47
+	}
48 48
 
49
-    /**
50
-     * Processes this test, when one of its tokens is encountered.
51
-     *
52
-     * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
53
-     * @param int                   $stackPtr  The position of the current token in the
54
-     *                                         stack passed in $tokens.
55
-     *
56
-     * @return void
57
-     */
58
-    public function process(File $phpcsFile, $stackPtr)
59
-    {
60
-        if ($this->supportsAbove('7.2') === false) {
61
-            return;
62
-        }
49
+	/**
50
+	 * Processes this test, when one of its tokens is encountered.
51
+	 *
52
+	 * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
53
+	 * @param int                   $stackPtr  The position of the current token in the
54
+	 *                                         stack passed in $tokens.
55
+	 *
56
+	 * @return void
57
+	 */
58
+	public function process(File $phpcsFile, $stackPtr)
59
+	{
60
+		if ($this->supportsAbove('7.2') === false) {
61
+			return;
62
+		}
63 63
 
64
-        $funcName = $phpcsFile->getDeclarationName($stackPtr);
64
+		$funcName = $phpcsFile->getDeclarationName($stackPtr);
65 65
 
66
-        if (strtolower($funcName) !== '__autoload') {
67
-            return;
68
-        }
66
+		if (strtolower($funcName) !== '__autoload') {
67
+			return;
68
+		}
69 69
 
70
-        if ($this->validDirectScope($phpcsFile, $stackPtr, $this->checkForScopes) !== false) {
71
-            return;
72
-        }
70
+		if ($this->validDirectScope($phpcsFile, $stackPtr, $this->checkForScopes) !== false) {
71
+			return;
72
+		}
73 73
 
74
-        if ($this->determineNamespace($phpcsFile, $stackPtr) !== '') {
75
-            return;
76
-        }
74
+		if ($this->determineNamespace($phpcsFile, $stackPtr) !== '') {
75
+			return;
76
+		}
77 77
 
78
-        $phpcsFile->addWarning('Use of __autoload() function is deprecated since PHP 7.2', $stackPtr, 'Found');
79
-    }
78
+		$phpcsFile->addWarning('Use of __autoload() function is deprecated since PHP 7.2', $stackPtr, 'Found');
79
+	}
80 80
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
      */
44 44
     public function register()
45 45
     {
46
-        return array(\T_FUNCTION);
46
+        return array( \T_FUNCTION );
47 47
     }
48 48
 
49 49
     /**
@@ -55,26 +55,26 @@  discard block
 block discarded – undo
55 55
      *
56 56
      * @return void
57 57
      */
58
-    public function process(File $phpcsFile, $stackPtr)
58
+    public function process( File $phpcsFile, $stackPtr )
59 59
     {
60
-        if ($this->supportsAbove('7.2') === false) {
60
+        if ( $this->supportsAbove( '7.2' ) === false ) {
61 61
             return;
62 62
         }
63 63
 
64
-        $funcName = $phpcsFile->getDeclarationName($stackPtr);
64
+        $funcName = $phpcsFile->getDeclarationName( $stackPtr );
65 65
 
66
-        if (strtolower($funcName) !== '__autoload') {
66
+        if ( strtolower( $funcName ) !== '__autoload' ) {
67 67
             return;
68 68
         }
69 69
 
70
-        if ($this->validDirectScope($phpcsFile, $stackPtr, $this->checkForScopes) !== false) {
70
+        if ( $this->validDirectScope( $phpcsFile, $stackPtr, $this->checkForScopes ) !== false ) {
71 71
             return;
72 72
         }
73 73
 
74
-        if ($this->determineNamespace($phpcsFile, $stackPtr) !== '') {
74
+        if ( $this->determineNamespace( $phpcsFile, $stackPtr ) !== '' ) {
75 75
             return;
76 76
         }
77 77
 
78
-        $phpcsFile->addWarning('Use of __autoload() function is deprecated since PHP 7.2', $stackPtr, 'Found');
78
+        $phpcsFile->addWarning( 'Use of __autoload() function is deprecated since PHP 7.2', $stackPtr, 'Found' );
79 79
     }
80 80
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -21,8 +21,7 @@  discard block
 block discarded – undo
21 21
  * @package  PHPCompatibility
22 22
  * @author   Wim Godden <[email protected]>
23 23
  */
24
-class RemovedMagicAutoloadSniff extends Sniff
25
-{
24
+class RemovedMagicAutoloadSniff extends Sniff {
26 25
     /**
27 26
      * Scopes to look for when testing using validDirectScope
28 27
      *
@@ -41,8 +40,7 @@  discard block
 block discarded – undo
41 40
      *
42 41
      * @return array
43 42
      */
44
-    public function register()
45
-    {
43
+    public function register() {
46 44
         return array(\T_FUNCTION);
47 45
     }
48 46
 
@@ -55,8 +53,7 @@  discard block
 block discarded – undo
55 53
      *
56 54
      * @return void
57 55
      */
58
-    public function process(File $phpcsFile, $stackPtr)
59
-    {
56
+    public function process(File $phpcsFile, $stackPtr) {
60 57
         if ($this->supportsAbove('7.2') === false) {
61 58
             return;
62 59
         }
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/FunctionNameRestrictions/RemovedNamespacedAssertSniff.php 4 patches
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -30,63 +30,63 @@
 block discarded – undo
30 30
  */
31 31
 class RemovedNamespacedAssertSniff extends Sniff
32 32
 {
33
-    /**
34
-     * Scopes in which an `assert` function can be declared without issue.
35
-     *
36
-     * @var array
37
-     */
38
-    private $scopes = array(
39
-        \T_CLASS,
40
-        \T_INTERFACE,
41
-        \T_TRAIT,
42
-        \T_CLOSURE,
43
-    );
33
+	/**
34
+	 * Scopes in which an `assert` function can be declared without issue.
35
+	 *
36
+	 * @var array
37
+	 */
38
+	private $scopes = array(
39
+		\T_CLASS,
40
+		\T_INTERFACE,
41
+		\T_TRAIT,
42
+		\T_CLOSURE,
43
+	);
44 44
 
45
-    /**
46
-     * Returns an array of tokens this test wants to listen for.
47
-     *
48
-     * @return array
49
-     */
50
-    public function register()
51
-    {
52
-        // Enrich the scopes list.
53
-        if (\defined('T_ANON_CLASS')) {
54
-            $this->scopes[] = \T_ANON_CLASS;
55
-        }
45
+	/**
46
+	 * Returns an array of tokens this test wants to listen for.
47
+	 *
48
+	 * @return array
49
+	 */
50
+	public function register()
51
+	{
52
+		// Enrich the scopes list.
53
+		if (\defined('T_ANON_CLASS')) {
54
+			$this->scopes[] = \T_ANON_CLASS;
55
+		}
56 56
 
57
-        return array(\T_FUNCTION);
58
-    }
57
+		return array(\T_FUNCTION);
58
+	}
59 59
 
60
-    /**
61
-     * Processes this test, when one of its tokens is encountered.
62
-     *
63
-     * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
64
-     * @param int                   $stackPtr  The position of the current token in the
65
-     *                                         stack passed in $tokens.
66
-     *
67
-     * @return void
68
-     */
69
-    public function process(File $phpcsFile, $stackPtr)
70
-    {
71
-        if ($this->supportsAbove('7.3') === false) {
72
-            return;
73
-        }
60
+	/**
61
+	 * Processes this test, when one of its tokens is encountered.
62
+	 *
63
+	 * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
64
+	 * @param int                   $stackPtr  The position of the current token in the
65
+	 *                                         stack passed in $tokens.
66
+	 *
67
+	 * @return void
68
+	 */
69
+	public function process(File $phpcsFile, $stackPtr)
70
+	{
71
+		if ($this->supportsAbove('7.3') === false) {
72
+			return;
73
+		}
74 74
 
75
-        $funcName = $phpcsFile->getDeclarationName($stackPtr);
75
+		$funcName = $phpcsFile->getDeclarationName($stackPtr);
76 76
 
77
-        if (strtolower($funcName) !== 'assert') {
78
-            return;
79
-        }
77
+		if (strtolower($funcName) !== 'assert') {
78
+			return;
79
+		}
80 80
 
81
-        if ($phpcsFile->hasCondition($stackPtr, $this->scopes) === true) {
82
-            return;
83
-        }
81
+		if ($phpcsFile->hasCondition($stackPtr, $this->scopes) === true) {
82
+			return;
83
+		}
84 84
 
85
-        if ($this->determineNamespace($phpcsFile, $stackPtr) === '') {
86
-            // Not a namespaced function declaration. Parse error, but not our concern.
87
-            return;
88
-        }
85
+		if ($this->determineNamespace($phpcsFile, $stackPtr) === '') {
86
+			// Not a namespaced function declaration. Parse error, but not our concern.
87
+			return;
88
+		}
89 89
 
90
-        $phpcsFile->addWarning('Declaring a free-standing function called assert() is deprecated since PHP 7.3.', $stackPtr, 'Found');
91
-    }
90
+		$phpcsFile->addWarning('Declaring a free-standing function called assert() is deprecated since PHP 7.3.', $stackPtr, 'Found');
91
+	}
92 92
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -50,11 +50,11 @@  discard block
 block discarded – undo
50 50
     public function register()
51 51
     {
52 52
         // Enrich the scopes list.
53
-        if (\defined('T_ANON_CLASS')) {
54
-            $this->scopes[] = \T_ANON_CLASS;
53
+        if ( \defined( 'T_ANON_CLASS' ) ) {
54
+            $this->scopes[ ] = \T_ANON_CLASS;
55 55
         }
56 56
 
57
-        return array(\T_FUNCTION);
57
+        return array( \T_FUNCTION );
58 58
     }
59 59
 
60 60
     /**
@@ -66,27 +66,27 @@  discard block
 block discarded – undo
66 66
      *
67 67
      * @return void
68 68
      */
69
-    public function process(File $phpcsFile, $stackPtr)
69
+    public function process( File $phpcsFile, $stackPtr )
70 70
     {
71
-        if ($this->supportsAbove('7.3') === false) {
71
+        if ( $this->supportsAbove( '7.3' ) === false ) {
72 72
             return;
73 73
         }
74 74
 
75
-        $funcName = $phpcsFile->getDeclarationName($stackPtr);
75
+        $funcName = $phpcsFile->getDeclarationName( $stackPtr );
76 76
 
77
-        if (strtolower($funcName) !== 'assert') {
77
+        if ( strtolower( $funcName ) !== 'assert' ) {
78 78
             return;
79 79
         }
80 80
 
81
-        if ($phpcsFile->hasCondition($stackPtr, $this->scopes) === true) {
81
+        if ( $phpcsFile->hasCondition( $stackPtr, $this->scopes ) === true ) {
82 82
             return;
83 83
         }
84 84
 
85
-        if ($this->determineNamespace($phpcsFile, $stackPtr) === '') {
85
+        if ( $this->determineNamespace( $phpcsFile, $stackPtr ) === '' ) {
86 86
             // Not a namespaced function declaration. Parse error, but not our concern.
87 87
             return;
88 88
         }
89 89
 
90
-        $phpcsFile->addWarning('Declaring a free-standing function called assert() is deprecated since PHP 7.3.', $stackPtr, 'Found');
90
+        $phpcsFile->addWarning( 'Declaring a free-standing function called assert() is deprecated since PHP 7.3.', $stackPtr, 'Found' );
91 91
     }
92 92
 }
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 RemovedNamespacedAssertSniff extends Sniff
32
-{
31
+class RemovedNamespacedAssertSniff extends Sniff {
33 32
     /**
34 33
      * Scopes in which an `assert` function can be declared without issue.
35 34
      *
@@ -47,8 +46,7 @@  discard block
 block discarded – undo
47 46
      *
48 47
      * @return array
49 48
      */
50
-    public function register()
51
-    {
49
+    public function register() {
52 50
         // Enrich the scopes list.
53 51
         if (\defined('T_ANON_CLASS')) {
54 52
             $this->scopes[] = \T_ANON_CLASS;
@@ -66,8 +64,7 @@  discard block
 block discarded – undo
66 64
      *
67 65
      * @return void
68 66
      */
69
-    public function process(File $phpcsFile, $stackPtr)
70
-    {
67
+    public function process(File $phpcsFile, $stackPtr) {
71 68
         if ($this->supportsAbove('7.3') === false) {
72 69
             return;
73 70
         }
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/FunctionNameRestrictions/NewMagicMethodsSniff.php 4 patches
Indentation   +167 added lines, -167 removed lines patch added patch discarded remove patch
@@ -24,171 +24,171 @@
 block discarded – undo
24 24
 class NewMagicMethodsSniff extends AbstractNewFeatureSniff
25 25
 {
26 26
 
27
-    /**
28
-     * A list of new magic methods, not considered magic in older versions.
29
-     *
30
-     * Method names in the array should be all *lowercase*.
31
-     * The array lists : version number with false (not magic) or true (magic).
32
-     * If's sufficient to list the first version where the method became magic.
33
-     *
34
-     * @var array(string => array(string => int|string|null))
35
-     */
36
-    protected $newMagicMethods = array(
37
-        '__get' => array(
38
-            '4.4' => false,
39
-            '5.0' => true,
40
-        ),
41
-
42
-        '__isset' => array(
43
-            '5.0' => false,
44
-            '5.1' => true,
45
-        ),
46
-        '__unset' => array(
47
-            '5.0' => false,
48
-            '5.1' => true,
49
-        ),
50
-        '__set_state' => array(
51
-            '5.0' => false,
52
-            '5.1' => true,
53
-        ),
54
-
55
-        '__callstatic' => array(
56
-            '5.2' => false,
57
-            '5.3' => true,
58
-        ),
59
-        '__invoke' => array(
60
-            '5.2' => false,
61
-            '5.3' => true,
62
-        ),
63
-
64
-        '__debuginfo' => array(
65
-            '5.5' => false,
66
-            '5.6' => true,
67
-        ),
68
-
69
-        // Special case - only became properly magical in 5.2.0,
70
-        // before that it was only called for echo and print.
71
-        '__tostring' => array(
72
-            '5.1'     => false,
73
-            '5.2'     => true,
74
-            'message' => 'The method %s() was not truly magical in PHP version %s and earlier. The associated magic functionality will only be called when directly combined with echo or print.',
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
-        return array(\T_FUNCTION);
87
-    }
88
-
89
-
90
-    /**
91
-     * Processes this test, when one of its tokens is encountered.
92
-     *
93
-     * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
94
-     * @param int                   $stackPtr  The position of the current token in the
95
-     *                                         stack passed in $tokens.
96
-     *
97
-     * @return void
98
-     */
99
-    public function process(File $phpcsFile, $stackPtr)
100
-    {
101
-        $functionName   = $phpcsFile->getDeclarationName($stackPtr);
102
-        $functionNameLc = strtolower($functionName);
103
-
104
-        if (isset($this->newMagicMethods[$functionNameLc]) === false) {
105
-            return;
106
-        }
107
-
108
-        if ($this->inClassScope($phpcsFile, $stackPtr, false) === false) {
109
-            return;
110
-        }
111
-
112
-        $itemInfo = array(
113
-            'name'   => $functionName,
114
-            'nameLc' => $functionNameLc,
115
-        );
116
-        $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
117
-    }
118
-
119
-
120
-    /**
121
-     * Get the relevant sub-array for a specific item from a multi-dimensional array.
122
-     *
123
-     * @param array $itemInfo Base information about the item.
124
-     *
125
-     * @return array Version and other information about the item.
126
-     */
127
-    public function getItemArray(array $itemInfo)
128
-    {
129
-        return $this->newMagicMethods[$itemInfo['nameLc']];
130
-    }
131
-
132
-
133
-    /**
134
-     * Get an array of the non-PHP-version array keys used in a sub-array.
135
-     *
136
-     * @return array
137
-     */
138
-    protected function getNonVersionArrayKeys()
139
-    {
140
-        return array('message');
141
-    }
142
-
143
-
144
-    /**
145
-     * Retrieve the relevant detail (version) information for use in an error message.
146
-     *
147
-     * @param array $itemArray Version and other information about the item.
148
-     * @param array $itemInfo  Base information about the item.
149
-     *
150
-     * @return array
151
-     */
152
-    public function getErrorInfo(array $itemArray, array $itemInfo)
153
-    {
154
-        $errorInfo            = parent::getErrorInfo($itemArray, $itemInfo);
155
-        $errorInfo['error']   = false; // Warning, not error.
156
-        $errorInfo['message'] = '';
157
-
158
-        if (empty($itemArray['message']) === false) {
159
-            $errorInfo['message'] = $itemArray['message'];
160
-        }
161
-
162
-        return $errorInfo;
163
-    }
164
-
165
-
166
-    /**
167
-     * Get the error message template for this sniff.
168
-     *
169
-     * @return string
170
-     */
171
-    protected function getErrorMsgTemplate()
172
-    {
173
-        return 'The method %s() was not magical in PHP version %s and earlier. The associated magic functionality will not be invoked.';
174
-    }
175
-
176
-
177
-    /**
178
-     * Allow for concrete child classes to filter the error message before it's passed to PHPCS.
179
-     *
180
-     * @param string $error     The error message which was created.
181
-     * @param array  $itemInfo  Base information about the item this error message applies to.
182
-     * @param array  $errorInfo Detail information about an item this error message applies to.
183
-     *
184
-     * @return string
185
-     */
186
-    protected function filterErrorMsg($error, array $itemInfo, array $errorInfo)
187
-    {
188
-        if ($errorInfo['message'] !== '') {
189
-            $error = $errorInfo['message'];
190
-        }
191
-
192
-        return $error;
193
-    }
27
+	/**
28
+	 * A list of new magic methods, not considered magic in older versions.
29
+	 *
30
+	 * Method names in the array should be all *lowercase*.
31
+	 * The array lists : version number with false (not magic) or true (magic).
32
+	 * If's sufficient to list the first version where the method became magic.
33
+	 *
34
+	 * @var array(string => array(string => int|string|null))
35
+	 */
36
+	protected $newMagicMethods = array(
37
+		'__get' => array(
38
+			'4.4' => false,
39
+			'5.0' => true,
40
+		),
41
+
42
+		'__isset' => array(
43
+			'5.0' => false,
44
+			'5.1' => true,
45
+		),
46
+		'__unset' => array(
47
+			'5.0' => false,
48
+			'5.1' => true,
49
+		),
50
+		'__set_state' => array(
51
+			'5.0' => false,
52
+			'5.1' => true,
53
+		),
54
+
55
+		'__callstatic' => array(
56
+			'5.2' => false,
57
+			'5.3' => true,
58
+		),
59
+		'__invoke' => array(
60
+			'5.2' => false,
61
+			'5.3' => true,
62
+		),
63
+
64
+		'__debuginfo' => array(
65
+			'5.5' => false,
66
+			'5.6' => true,
67
+		),
68
+
69
+		// Special case - only became properly magical in 5.2.0,
70
+		// before that it was only called for echo and print.
71
+		'__tostring' => array(
72
+			'5.1'     => false,
73
+			'5.2'     => true,
74
+			'message' => 'The method %s() was not truly magical in PHP version %s and earlier. The associated magic functionality will only be called when directly combined with echo or print.',
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
+		return array(\T_FUNCTION);
87
+	}
88
+
89
+
90
+	/**
91
+	 * Processes this test, when one of its tokens is encountered.
92
+	 *
93
+	 * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
94
+	 * @param int                   $stackPtr  The position of the current token in the
95
+	 *                                         stack passed in $tokens.
96
+	 *
97
+	 * @return void
98
+	 */
99
+	public function process(File $phpcsFile, $stackPtr)
100
+	{
101
+		$functionName   = $phpcsFile->getDeclarationName($stackPtr);
102
+		$functionNameLc = strtolower($functionName);
103
+
104
+		if (isset($this->newMagicMethods[$functionNameLc]) === false) {
105
+			return;
106
+		}
107
+
108
+		if ($this->inClassScope($phpcsFile, $stackPtr, false) === false) {
109
+			return;
110
+		}
111
+
112
+		$itemInfo = array(
113
+			'name'   => $functionName,
114
+			'nameLc' => $functionNameLc,
115
+		);
116
+		$this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
117
+	}
118
+
119
+
120
+	/**
121
+	 * Get the relevant sub-array for a specific item from a multi-dimensional array.
122
+	 *
123
+	 * @param array $itemInfo Base information about the item.
124
+	 *
125
+	 * @return array Version and other information about the item.
126
+	 */
127
+	public function getItemArray(array $itemInfo)
128
+	{
129
+		return $this->newMagicMethods[$itemInfo['nameLc']];
130
+	}
131
+
132
+
133
+	/**
134
+	 * Get an array of the non-PHP-version array keys used in a sub-array.
135
+	 *
136
+	 * @return array
137
+	 */
138
+	protected function getNonVersionArrayKeys()
139
+	{
140
+		return array('message');
141
+	}
142
+
143
+
144
+	/**
145
+	 * Retrieve the relevant detail (version) information for use in an error message.
146
+	 *
147
+	 * @param array $itemArray Version and other information about the item.
148
+	 * @param array $itemInfo  Base information about the item.
149
+	 *
150
+	 * @return array
151
+	 */
152
+	public function getErrorInfo(array $itemArray, array $itemInfo)
153
+	{
154
+		$errorInfo            = parent::getErrorInfo($itemArray, $itemInfo);
155
+		$errorInfo['error']   = false; // Warning, not error.
156
+		$errorInfo['message'] = '';
157
+
158
+		if (empty($itemArray['message']) === false) {
159
+			$errorInfo['message'] = $itemArray['message'];
160
+		}
161
+
162
+		return $errorInfo;
163
+	}
164
+
165
+
166
+	/**
167
+	 * Get the error message template for this sniff.
168
+	 *
169
+	 * @return string
170
+	 */
171
+	protected function getErrorMsgTemplate()
172
+	{
173
+		return 'The method %s() was not magical in PHP version %s and earlier. The associated magic functionality will not be invoked.';
174
+	}
175
+
176
+
177
+	/**
178
+	 * Allow for concrete child classes to filter the error message before it's passed to PHPCS.
179
+	 *
180
+	 * @param string $error     The error message which was created.
181
+	 * @param array  $itemInfo  Base information about the item this error message applies to.
182
+	 * @param array  $errorInfo Detail information about an item this error message applies to.
183
+	 *
184
+	 * @return string
185
+	 */
186
+	protected function filterErrorMsg($error, array $itemInfo, array $errorInfo)
187
+	{
188
+		if ($errorInfo['message'] !== '') {
189
+			$error = $errorInfo['message'];
190
+		}
191
+
192
+		return $error;
193
+	}
194 194
 }
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
      */
84 84
     public function register()
85 85
     {
86
-        return array(\T_FUNCTION);
86
+        return array( \T_FUNCTION );
87 87
     }
88 88
 
89 89
 
@@ -96,16 +96,16 @@  discard block
 block discarded – undo
96 96
      *
97 97
      * @return void
98 98
      */
99
-    public function process(File $phpcsFile, $stackPtr)
99
+    public function process( File $phpcsFile, $stackPtr )
100 100
     {
101
-        $functionName   = $phpcsFile->getDeclarationName($stackPtr);
102
-        $functionNameLc = strtolower($functionName);
101
+        $functionName   = $phpcsFile->getDeclarationName( $stackPtr );
102
+        $functionNameLc = strtolower( $functionName );
103 103
 
104
-        if (isset($this->newMagicMethods[$functionNameLc]) === false) {
104
+        if ( isset( $this->newMagicMethods[ $functionNameLc ] ) === false ) {
105 105
             return;
106 106
         }
107 107
 
108
-        if ($this->inClassScope($phpcsFile, $stackPtr, false) === false) {
108
+        if ( $this->inClassScope( $phpcsFile, $stackPtr, false ) === false ) {
109 109
             return;
110 110
         }
111 111
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
             'name'   => $functionName,
114 114
             'nameLc' => $functionNameLc,
115 115
         );
116
-        $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
116
+        $this->handleFeature( $phpcsFile, $stackPtr, $itemInfo );
117 117
     }
118 118
 
119 119
 
@@ -124,9 +124,9 @@  discard block
 block discarded – undo
124 124
      *
125 125
      * @return array Version and other information about the item.
126 126
      */
127
-    public function getItemArray(array $itemInfo)
127
+    public function getItemArray( array $itemInfo )
128 128
     {
129
-        return $this->newMagicMethods[$itemInfo['nameLc']];
129
+        return $this->newMagicMethods[ $itemInfo[ 'nameLc' ] ];
130 130
     }
131 131
 
132 132
 
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
      */
138 138
     protected function getNonVersionArrayKeys()
139 139
     {
140
-        return array('message');
140
+        return array( 'message' );
141 141
     }
142 142
 
143 143
 
@@ -149,14 +149,14 @@  discard block
 block discarded – undo
149 149
      *
150 150
      * @return array
151 151
      */
152
-    public function getErrorInfo(array $itemArray, array $itemInfo)
152
+    public function getErrorInfo( array $itemArray, array $itemInfo )
153 153
     {
154
-        $errorInfo            = parent::getErrorInfo($itemArray, $itemInfo);
155
-        $errorInfo['error']   = false; // Warning, not error.
156
-        $errorInfo['message'] = '';
154
+        $errorInfo            = parent::getErrorInfo( $itemArray, $itemInfo );
155
+        $errorInfo[ 'error' ]   = false; // Warning, not error.
156
+        $errorInfo[ 'message' ] = '';
157 157
 
158
-        if (empty($itemArray['message']) === false) {
159
-            $errorInfo['message'] = $itemArray['message'];
158
+        if ( empty( $itemArray[ 'message' ] ) === false ) {
159
+            $errorInfo[ 'message' ] = $itemArray[ 'message' ];
160 160
         }
161 161
 
162 162
         return $errorInfo;
@@ -183,10 +183,10 @@  discard block
 block discarded – undo
183 183
      *
184 184
      * @return string
185 185
      */
186
-    protected function filterErrorMsg($error, array $itemInfo, array $errorInfo)
186
+    protected function filterErrorMsg( $error, array $itemInfo, array $errorInfo )
187 187
     {
188
-        if ($errorInfo['message'] !== '') {
189
-            $error = $errorInfo['message'];
188
+        if ( $errorInfo[ 'message' ] !== '' ) {
189
+            $error = $errorInfo[ 'message' ];
190 190
         }
191 191
 
192 192
         return $error;
Please login to merge, or discard this patch.
Braces   +8 added lines, -16 removed lines patch added patch discarded remove patch
@@ -21,8 +21,7 @@  discard block
 block discarded – undo
21 21
  * @package  PHPCompatibility
22 22
  * @author   Juliette Reinders Folmer <[email protected]>
23 23
  */
24
-class NewMagicMethodsSniff extends AbstractNewFeatureSniff
25
-{
24
+class NewMagicMethodsSniff extends AbstractNewFeatureSniff {
26 25
 
27 26
     /**
28 27
      * A list of new magic methods, not considered magic in older versions.
@@ -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
         return array(\T_FUNCTION);
87 85
     }
88 86
 
@@ -96,8 +94,7 @@  discard block
 block discarded – undo
96 94
      *
97 95
      * @return void
98 96
      */
99
-    public function process(File $phpcsFile, $stackPtr)
100
-    {
97
+    public function process(File $phpcsFile, $stackPtr) {
101 98
         $functionName   = $phpcsFile->getDeclarationName($stackPtr);
102 99
         $functionNameLc = strtolower($functionName);
103 100
 
@@ -124,8 +121,7 @@  discard block
 block discarded – undo
124 121
      *
125 122
      * @return array Version and other information about the item.
126 123
      */
127
-    public function getItemArray(array $itemInfo)
128
-    {
124
+    public function getItemArray(array $itemInfo) {
129 125
         return $this->newMagicMethods[$itemInfo['nameLc']];
130 126
     }
131 127
 
@@ -135,8 +131,7 @@  discard block
 block discarded – undo
135 131
      *
136 132
      * @return array
137 133
      */
138
-    protected function getNonVersionArrayKeys()
139
-    {
134
+    protected function getNonVersionArrayKeys() {
140 135
         return array('message');
141 136
     }
142 137
 
@@ -149,8 +144,7 @@  discard block
 block discarded – undo
149 144
      *
150 145
      * @return array
151 146
      */
152
-    public function getErrorInfo(array $itemArray, array $itemInfo)
153
-    {
147
+    public function getErrorInfo(array $itemArray, array $itemInfo) {
154 148
         $errorInfo            = parent::getErrorInfo($itemArray, $itemInfo);
155 149
         $errorInfo['error']   = false; // Warning, not error.
156 150
         $errorInfo['message'] = '';
@@ -168,8 +162,7 @@  discard block
 block discarded – undo
168 162
      *
169 163
      * @return string
170 164
      */
171
-    protected function getErrorMsgTemplate()
172
-    {
165
+    protected function getErrorMsgTemplate() {
173 166
         return 'The method %s() was not magical in PHP version %s and earlier. The associated magic functionality will not be invoked.';
174 167
     }
175 168
 
@@ -183,8 +176,7 @@  discard block
 block discarded – undo
183 176
      *
184 177
      * @return string
185 178
      */
186
-    protected function filterErrorMsg($error, array $itemInfo, array $errorInfo)
187
-    {
179
+    protected function filterErrorMsg($error, array $itemInfo, array $errorInfo) {
188 180
         if ($errorInfo['message'] !== '') {
189 181
             $error = $errorInfo['message'];
190 182
         }
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
     /**
65 65
      * Returns an array of tokens this test wants to listen for.
66 66
      *
67
-     * @return array
67
+     * @return integer[]
68 68
      */
69 69
     public function register()
70 70
     {
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
     /**
168 168
      * Get an array of the non-PHP-version array keys used in a sub-array.
169 169
      *
170
-     * @return array
170
+     * @return string[]
171 171
      */
172 172
     protected function getNonVersionArrayKeys()
173 173
     {
Please login to merge, or discard this patch.
Sniffs/FunctionNameRestrictions/RemovedPHP4StyleConstructorsSniff.php 4 patches
Indentation   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -27,109 +27,109 @@
 block discarded – undo
27 27
 class RemovedPHP4StyleConstructorsSniff extends Sniff
28 28
 {
29 29
 
30
-    /**
31
-     * Returns an array of tokens this test wants to listen for.
32
-     *
33
-     * @return array
34
-     */
35
-    public function register()
36
-    {
37
-        return array(
38
-            \T_CLASS,
39
-            \T_INTERFACE,
40
-        );
41
-    }
42
-
43
-    /**
44
-     * Processes this test, when one of its tokens is encountered.
45
-     *
46
-     * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
47
-     * @param int                   $stackPtr  The position of the current token in the
48
-     *                                         stack passed in $tokens.
49
-     *
50
-     * @return void
51
-     */
52
-    public function process(File $phpcsFile, $stackPtr)
53
-    {
54
-        if ($this->supportsAbove('7.0') === false) {
55
-            return;
56
-        }
57
-
58
-        if ($this->determineNamespace($phpcsFile, $stackPtr) !== '') {
59
-            /*
30
+	/**
31
+	 * Returns an array of tokens this test wants to listen for.
32
+	 *
33
+	 * @return array
34
+	 */
35
+	public function register()
36
+	{
37
+		return array(
38
+			\T_CLASS,
39
+			\T_INTERFACE,
40
+		);
41
+	}
42
+
43
+	/**
44
+	 * Processes this test, when one of its tokens is encountered.
45
+	 *
46
+	 * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
47
+	 * @param int                   $stackPtr  The position of the current token in the
48
+	 *                                         stack passed in $tokens.
49
+	 *
50
+	 * @return void
51
+	 */
52
+	public function process(File $phpcsFile, $stackPtr)
53
+	{
54
+		if ($this->supportsAbove('7.0') === false) {
55
+			return;
56
+		}
57
+
58
+		if ($this->determineNamespace($phpcsFile, $stackPtr) !== '') {
59
+			/*
60 60
              * Namespaced methods with the same name as the class are treated as
61 61
              * regular methods, so we can bow out if we're in a namespace.
62 62
              *
63 63
              * Note: the exception to this is PHP 5.3.0-5.3.2. This is currently
64 64
              * not dealt with.
65 65
              */
66
-            return;
67
-        }
68
-
69
-        $tokens = $phpcsFile->getTokens();
70
-
71
-        $class = $tokens[$stackPtr];
72
-
73
-        if (isset($class['scope_closer']) === false) {
74
-            return;
75
-        }
76
-
77
-        $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
78
-        if ($nextNonEmpty === false || $tokens[$nextNonEmpty]['code'] !== \T_STRING) {
79
-            // Anonymous class in combination with PHPCS 2.3.x.
80
-            return;
81
-        }
82
-
83
-        $scopeCloser = $class['scope_closer'];
84
-        $className   = $tokens[$nextNonEmpty]['content'];
85
-
86
-        if (empty($className) || \is_string($className) === false) {
87
-            return;
88
-        }
89
-
90
-        $nextFunc            = $stackPtr;
91
-        $classNameLc         = strtolower($className);
92
-        $newConstructorFound = false;
93
-        $oldConstructorFound = false;
94
-        $oldConstructorPos   = -1;
95
-        while (($nextFunc = $phpcsFile->findNext(\T_FUNCTION, ($nextFunc + 1), $scopeCloser)) !== false) {
96
-            $functionScopeCloser = $nextFunc;
97
-            if (isset($tokens[$nextFunc]['scope_closer'])) {
98
-                // Normal (non-interface, non-abstract) method.
99
-                $functionScopeCloser = $tokens[$nextFunc]['scope_closer'];
100
-            }
101
-
102
-            $funcName = $phpcsFile->getDeclarationName($nextFunc);
103
-            if (empty($funcName) || \is_string($funcName) === false) {
104
-                $nextFunc = $functionScopeCloser;
105
-                continue;
106
-            }
107
-
108
-            $funcNameLc = strtolower($funcName);
109
-
110
-            if ($funcNameLc === '__construct') {
111
-                $newConstructorFound = true;
112
-            }
113
-
114
-            if ($funcNameLc === $classNameLc) {
115
-                $oldConstructorFound = true;
116
-                $oldConstructorPos   = $nextFunc;
117
-            }
118
-
119
-            // If both have been found, no need to continue looping through the functions.
120
-            if ($newConstructorFound === true && $oldConstructorFound === true) {
121
-                break;
122
-            }
123
-
124
-            $nextFunc = $functionScopeCloser;
125
-        }
126
-
127
-        if ($newConstructorFound === false && $oldConstructorFound === true) {
128
-            $phpcsFile->addWarning(
129
-                'Use of deprecated PHP4 style class constructor is not supported since PHP 7.',
130
-                $oldConstructorPos,
131
-                'Found'
132
-            );
133
-        }
134
-    }
66
+			return;
67
+		}
68
+
69
+		$tokens = $phpcsFile->getTokens();
70
+
71
+		$class = $tokens[$stackPtr];
72
+
73
+		if (isset($class['scope_closer']) === false) {
74
+			return;
75
+		}
76
+
77
+		$nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
78
+		if ($nextNonEmpty === false || $tokens[$nextNonEmpty]['code'] !== \T_STRING) {
79
+			// Anonymous class in combination with PHPCS 2.3.x.
80
+			return;
81
+		}
82
+
83
+		$scopeCloser = $class['scope_closer'];
84
+		$className   = $tokens[$nextNonEmpty]['content'];
85
+
86
+		if (empty($className) || \is_string($className) === false) {
87
+			return;
88
+		}
89
+
90
+		$nextFunc            = $stackPtr;
91
+		$classNameLc         = strtolower($className);
92
+		$newConstructorFound = false;
93
+		$oldConstructorFound = false;
94
+		$oldConstructorPos   = -1;
95
+		while (($nextFunc = $phpcsFile->findNext(\T_FUNCTION, ($nextFunc + 1), $scopeCloser)) !== false) {
96
+			$functionScopeCloser = $nextFunc;
97
+			if (isset($tokens[$nextFunc]['scope_closer'])) {
98
+				// Normal (non-interface, non-abstract) method.
99
+				$functionScopeCloser = $tokens[$nextFunc]['scope_closer'];
100
+			}
101
+
102
+			$funcName = $phpcsFile->getDeclarationName($nextFunc);
103
+			if (empty($funcName) || \is_string($funcName) === false) {
104
+				$nextFunc = $functionScopeCloser;
105
+				continue;
106
+			}
107
+
108
+			$funcNameLc = strtolower($funcName);
109
+
110
+			if ($funcNameLc === '__construct') {
111
+				$newConstructorFound = true;
112
+			}
113
+
114
+			if ($funcNameLc === $classNameLc) {
115
+				$oldConstructorFound = true;
116
+				$oldConstructorPos   = $nextFunc;
117
+			}
118
+
119
+			// If both have been found, no need to continue looping through the functions.
120
+			if ($newConstructorFound === true && $oldConstructorFound === true) {
121
+				break;
122
+			}
123
+
124
+			$nextFunc = $functionScopeCloser;
125
+		}
126
+
127
+		if ($newConstructorFound === false && $oldConstructorFound === true) {
128
+			$phpcsFile->addWarning(
129
+				'Use of deprecated PHP4 style class constructor is not supported since PHP 7.',
130
+				$oldConstructorPos,
131
+				'Found'
132
+			);
133
+		}
134
+	}
135 135
 }
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -49,13 +49,13 @@  discard block
 block discarded – undo
49 49
      *
50 50
      * @return void
51 51
      */
52
-    public function process(File $phpcsFile, $stackPtr)
52
+    public function process( File $phpcsFile, $stackPtr )
53 53
     {
54
-        if ($this->supportsAbove('7.0') === false) {
54
+        if ( $this->supportsAbove( '7.0' ) === false ) {
55 55
             return;
56 56
         }
57 57
 
58
-        if ($this->determineNamespace($phpcsFile, $stackPtr) !== '') {
58
+        if ( $this->determineNamespace( $phpcsFile, $stackPtr ) !== '' ) {
59 59
             /*
60 60
              * Namespaced methods with the same name as the class are treated as
61 61
              * regular methods, so we can bow out if we're in a namespace.
@@ -68,63 +68,63 @@  discard block
 block discarded – undo
68 68
 
69 69
         $tokens = $phpcsFile->getTokens();
70 70
 
71
-        $class = $tokens[$stackPtr];
71
+        $class = $tokens[ $stackPtr ];
72 72
 
73
-        if (isset($class['scope_closer']) === false) {
73
+        if ( isset( $class[ 'scope_closer' ] ) === false ) {
74 74
             return;
75 75
         }
76 76
 
77
-        $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
78
-        if ($nextNonEmpty === false || $tokens[$nextNonEmpty]['code'] !== \T_STRING) {
77
+        $nextNonEmpty = $phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true );
78
+        if ( $nextNonEmpty === false || $tokens[ $nextNonEmpty ][ 'code' ] !== \T_STRING ) {
79 79
             // Anonymous class in combination with PHPCS 2.3.x.
80 80
             return;
81 81
         }
82 82
 
83
-        $scopeCloser = $class['scope_closer'];
84
-        $className   = $tokens[$nextNonEmpty]['content'];
83
+        $scopeCloser = $class[ 'scope_closer' ];
84
+        $className   = $tokens[ $nextNonEmpty ][ 'content' ];
85 85
 
86
-        if (empty($className) || \is_string($className) === false) {
86
+        if ( empty( $className ) || \is_string( $className ) === false ) {
87 87
             return;
88 88
         }
89 89
 
90 90
         $nextFunc            = $stackPtr;
91
-        $classNameLc         = strtolower($className);
91
+        $classNameLc         = strtolower( $className );
92 92
         $newConstructorFound = false;
93 93
         $oldConstructorFound = false;
94 94
         $oldConstructorPos   = -1;
95
-        while (($nextFunc = $phpcsFile->findNext(\T_FUNCTION, ($nextFunc + 1), $scopeCloser)) !== false) {
95
+        while ( ( $nextFunc = $phpcsFile->findNext( \T_FUNCTION, ( $nextFunc + 1 ), $scopeCloser ) ) !== false ) {
96 96
             $functionScopeCloser = $nextFunc;
97
-            if (isset($tokens[$nextFunc]['scope_closer'])) {
97
+            if ( isset( $tokens[ $nextFunc ][ 'scope_closer' ] ) ) {
98 98
                 // Normal (non-interface, non-abstract) method.
99
-                $functionScopeCloser = $tokens[$nextFunc]['scope_closer'];
99
+                $functionScopeCloser = $tokens[ $nextFunc ][ 'scope_closer' ];
100 100
             }
101 101
 
102
-            $funcName = $phpcsFile->getDeclarationName($nextFunc);
103
-            if (empty($funcName) || \is_string($funcName) === false) {
102
+            $funcName = $phpcsFile->getDeclarationName( $nextFunc );
103
+            if ( empty( $funcName ) || \is_string( $funcName ) === false ) {
104 104
                 $nextFunc = $functionScopeCloser;
105 105
                 continue;
106 106
             }
107 107
 
108
-            $funcNameLc = strtolower($funcName);
108
+            $funcNameLc = strtolower( $funcName );
109 109
 
110
-            if ($funcNameLc === '__construct') {
110
+            if ( $funcNameLc === '__construct' ) {
111 111
                 $newConstructorFound = true;
112 112
             }
113 113
 
114
-            if ($funcNameLc === $classNameLc) {
114
+            if ( $funcNameLc === $classNameLc ) {
115 115
                 $oldConstructorFound = true;
116 116
                 $oldConstructorPos   = $nextFunc;
117 117
             }
118 118
 
119 119
             // If both have been found, no need to continue looping through the functions.
120
-            if ($newConstructorFound === true && $oldConstructorFound === true) {
120
+            if ( $newConstructorFound === true && $oldConstructorFound === true ) {
121 121
                 break;
122 122
             }
123 123
 
124 124
             $nextFunc = $functionScopeCloser;
125 125
         }
126 126
 
127
-        if ($newConstructorFound === false && $oldConstructorFound === true) {
127
+        if ( $newConstructorFound === false && $oldConstructorFound === true ) {
128 128
             $phpcsFile->addWarning(
129 129
                 'Use of deprecated PHP4 style class constructor is not supported since PHP 7.',
130 130
                 $oldConstructorPos,
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -24,16 +24,14 @@  discard block
 block discarded – undo
24 24
  * @package  PHPCompatibility
25 25
  * @author   Koen Eelen <[email protected]>
26 26
  */
27
-class RemovedPHP4StyleConstructorsSniff extends Sniff
28
-{
27
+class RemovedPHP4StyleConstructorsSniff extends Sniff {
29 28
 
30 29
     /**
31 30
      * Returns an array of tokens this test wants to listen for.
32 31
      *
33 32
      * @return array
34 33
      */
35
-    public function register()
36
-    {
34
+    public function register() {
37 35
         return array(
38 36
             \T_CLASS,
39 37
             \T_INTERFACE,
@@ -49,8 +47,7 @@  discard block
 block discarded – undo
49 47
      *
50 48
      * @return void
51 49
      */
52
-    public function process(File $phpcsFile, $stackPtr)
53
-    {
50
+    public function process(File $phpcsFile, $stackPtr) {
54 51
         if ($this->supportsAbove('7.0') === false) {
55 52
             return;
56 53
         }
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/FunctionNameRestrictions/ReservedFunctionNamesSniff.php 3 patches
Indentation   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -37,108 +37,108 @@
 block discarded – undo
37 37
 class ReservedFunctionNamesSniff extends PHPCS_CamelCapsFunctionNameSniff
38 38
 {
39 39
 
40
-    /**
41
-     * Overload the constructor to work round various PHPCS cross-version compatibility issues.
42
-     */
43
-    public function __construct()
44
-    {
45
-        $scopeTokens = array(\T_CLASS, \T_INTERFACE, \T_TRAIT);
46
-        if (\defined('T_ANON_CLASS')) {
47
-            $scopeTokens[] = \T_ANON_CLASS;
48
-        }
40
+	/**
41
+	 * Overload the constructor to work round various PHPCS cross-version compatibility issues.
42
+	 */
43
+	public function __construct()
44
+	{
45
+		$scopeTokens = array(\T_CLASS, \T_INTERFACE, \T_TRAIT);
46
+		if (\defined('T_ANON_CLASS')) {
47
+			$scopeTokens[] = \T_ANON_CLASS;
48
+		}
49 49
 
50
-        // Call the grand-parent constructor directly.
51
-        PHPCS_AbstractScopeSniff::__construct($scopeTokens, array(\T_FUNCTION), true);
50
+		// Call the grand-parent constructor directly.
51
+		PHPCS_AbstractScopeSniff::__construct($scopeTokens, array(\T_FUNCTION), true);
52 52
 
53
-        // Make sure debuginfo is included in the array. Upstream only includes it since 2.5.1.
54
-        $this->magicMethods['debuginfo'] = true;
55
-    }
53
+		// Make sure debuginfo is included in the array. Upstream only includes it since 2.5.1.
54
+		$this->magicMethods['debuginfo'] = true;
55
+	}
56 56
 
57 57
 
58
-    /**
59
-     * Processes the tokens within the scope.
60
-     *
61
-     * @param \PHP_CodeSniffer_File $phpcsFile The file being processed.
62
-     * @param int                   $stackPtr  The position where this token was
63
-     *                                         found.
64
-     * @param int                   $currScope The position of the current scope.
65
-     *
66
-     * @return void
67
-     */
68
-    protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScope)
69
-    {
70
-        $tokens = $phpcsFile->getTokens();
58
+	/**
59
+	 * Processes the tokens within the scope.
60
+	 *
61
+	 * @param \PHP_CodeSniffer_File $phpcsFile The file being processed.
62
+	 * @param int                   $stackPtr  The position where this token was
63
+	 *                                         found.
64
+	 * @param int                   $currScope The position of the current scope.
65
+	 *
66
+	 * @return void
67
+	 */
68
+	protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScope)
69
+	{
70
+		$tokens = $phpcsFile->getTokens();
71 71
 
72
-        /*
72
+		/*
73 73
          * Determine if this is a function which needs to be examined.
74 74
          * The `processTokenWithinScope()` is called for each valid scope a method is in,
75 75
          * so for nested classes, we need to make sure we only examine the token for
76 76
          * the lowest level valid scope.
77 77
          */
78
-        $conditions = $tokens[$stackPtr]['conditions'];
79
-        end($conditions);
80
-        $deepestScope = key($conditions);
81
-        if ($deepestScope !== $currScope) {
82
-            return;
83
-        }
78
+		$conditions = $tokens[$stackPtr]['conditions'];
79
+		end($conditions);
80
+		$deepestScope = key($conditions);
81
+		if ($deepestScope !== $currScope) {
82
+			return;
83
+		}
84 84
 
85
-        $methodName = $phpcsFile->getDeclarationName($stackPtr);
86
-        if ($methodName === null) {
87
-            // Ignore closures.
88
-            return;
89
-        }
85
+		$methodName = $phpcsFile->getDeclarationName($stackPtr);
86
+		if ($methodName === null) {
87
+			// Ignore closures.
88
+			return;
89
+		}
90 90
 
91
-        // Is this a magic method. i.e., is prefixed with "__" ?
92
-        if (preg_match('|^__[^_]|', $methodName) > 0) {
93
-            $magicPart = strtolower(substr($methodName, 2));
94
-            if (isset($this->magicMethods[$magicPart]) === false
95
-                && isset($this->methodsDoubleUnderscore[$magicPart]) === false
96
-            ) {
97
-                $className         = '[anonymous class]';
98
-                $scopeNextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($currScope + 1), null, true);
99
-                if ($scopeNextNonEmpty !== false && $tokens[$scopeNextNonEmpty]['code'] === \T_STRING) {
100
-                    $className = $tokens[$scopeNextNonEmpty]['content'];
101
-                }
91
+		// Is this a magic method. i.e., is prefixed with "__" ?
92
+		if (preg_match('|^__[^_]|', $methodName) > 0) {
93
+			$magicPart = strtolower(substr($methodName, 2));
94
+			if (isset($this->magicMethods[$magicPart]) === false
95
+				&& isset($this->methodsDoubleUnderscore[$magicPart]) === false
96
+			) {
97
+				$className         = '[anonymous class]';
98
+				$scopeNextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($currScope + 1), null, true);
99
+				if ($scopeNextNonEmpty !== false && $tokens[$scopeNextNonEmpty]['code'] === \T_STRING) {
100
+					$className = $tokens[$scopeNextNonEmpty]['content'];
101
+				}
102 102
 
103
-                $phpcsFile->addWarning(
104
-                    'Method name "%s" is discouraged; PHP has reserved all method names with a double underscore prefix for future use.',
105
-                    $stackPtr,
106
-                    'MethodDoubleUnderscore',
107
-                    array($className . '::' . $methodName)
108
-                );
109
-            }
110
-        }
111
-    }
103
+				$phpcsFile->addWarning(
104
+					'Method name "%s" is discouraged; PHP has reserved all method names with a double underscore prefix for future use.',
105
+					$stackPtr,
106
+					'MethodDoubleUnderscore',
107
+					array($className . '::' . $methodName)
108
+				);
109
+			}
110
+		}
111
+	}
112 112
 
113 113
 
114
-    /**
115
-     * Processes the tokens outside the scope.
116
-     *
117
-     * @param \PHP_CodeSniffer_File $phpcsFile The file being processed.
118
-     * @param int                   $stackPtr  The position where this token was
119
-     *                                         found.
120
-     *
121
-     * @return void
122
-     */
123
-    protected function processTokenOutsideScope(File $phpcsFile, $stackPtr)
124
-    {
125
-        $functionName = $phpcsFile->getDeclarationName($stackPtr);
126
-        if ($functionName === null) {
127
-            // Ignore closures.
128
-            return;
129
-        }
114
+	/**
115
+	 * Processes the tokens outside the scope.
116
+	 *
117
+	 * @param \PHP_CodeSniffer_File $phpcsFile The file being processed.
118
+	 * @param int                   $stackPtr  The position where this token was
119
+	 *                                         found.
120
+	 *
121
+	 * @return void
122
+	 */
123
+	protected function processTokenOutsideScope(File $phpcsFile, $stackPtr)
124
+	{
125
+		$functionName = $phpcsFile->getDeclarationName($stackPtr);
126
+		if ($functionName === null) {
127
+			// Ignore closures.
128
+			return;
129
+		}
130 130
 
131
-        // Is this a magic function. i.e., it is prefixed with "__".
132
-        if (preg_match('|^__[^_]|', $functionName) > 0) {
133
-            $magicPart = strtolower(substr($functionName, 2));
134
-            if (isset($this->magicFunctions[$magicPart]) === false) {
135
-                $phpcsFile->addWarning(
136
-                    'Function name "%s" is discouraged; PHP has reserved all method names with a double underscore prefix for future use.',
137
-                    $stackPtr,
138
-                    'FunctionDoubleUnderscore',
139
-                    array($functionName)
140
-                );
141
-            }
142
-        }
143
-    }
131
+		// Is this a magic function. i.e., it is prefixed with "__".
132
+		if (preg_match('|^__[^_]|', $functionName) > 0) {
133
+			$magicPart = strtolower(substr($functionName, 2));
134
+			if (isset($this->magicFunctions[$magicPart]) === false) {
135
+				$phpcsFile->addWarning(
136
+					'Function name "%s" is discouraged; PHP has reserved all method names with a double underscore prefix for future use.',
137
+					$stackPtr,
138
+					'FunctionDoubleUnderscore',
139
+					array($functionName)
140
+				);
141
+			}
142
+		}
143
+	}
144 144
 }
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -42,16 +42,16 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public function __construct()
44 44
     {
45
-        $scopeTokens = array(\T_CLASS, \T_INTERFACE, \T_TRAIT);
46
-        if (\defined('T_ANON_CLASS')) {
47
-            $scopeTokens[] = \T_ANON_CLASS;
45
+        $scopeTokens = array( \T_CLASS, \T_INTERFACE, \T_TRAIT );
46
+        if ( \defined( 'T_ANON_CLASS' ) ) {
47
+            $scopeTokens[ ] = \T_ANON_CLASS;
48 48
         }
49 49
 
50 50
         // Call the grand-parent constructor directly.
51
-        PHPCS_AbstractScopeSniff::__construct($scopeTokens, array(\T_FUNCTION), true);
51
+        PHPCS_AbstractScopeSniff::__construct( $scopeTokens, array( \T_FUNCTION ), true );
52 52
 
53 53
         // Make sure debuginfo is included in the array. Upstream only includes it since 2.5.1.
54
-        $this->magicMethods['debuginfo'] = true;
54
+        $this->magicMethods[ 'debuginfo' ] = true;
55 55
     }
56 56
 
57 57
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
      *
66 66
      * @return void
67 67
      */
68
-    protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScope)
68
+    protected function processTokenWithinScope( File $phpcsFile, $stackPtr, $currScope )
69 69
     {
70 70
         $tokens = $phpcsFile->getTokens();
71 71
 
@@ -75,36 +75,36 @@  discard block
 block discarded – undo
75 75
          * so for nested classes, we need to make sure we only examine the token for
76 76
          * the lowest level valid scope.
77 77
          */
78
-        $conditions = $tokens[$stackPtr]['conditions'];
79
-        end($conditions);
80
-        $deepestScope = key($conditions);
81
-        if ($deepestScope !== $currScope) {
78
+        $conditions = $tokens[ $stackPtr ][ 'conditions' ];
79
+        end( $conditions );
80
+        $deepestScope = key( $conditions );
81
+        if ( $deepestScope !== $currScope ) {
82 82
             return;
83 83
         }
84 84
 
85
-        $methodName = $phpcsFile->getDeclarationName($stackPtr);
86
-        if ($methodName === null) {
85
+        $methodName = $phpcsFile->getDeclarationName( $stackPtr );
86
+        if ( $methodName === null ) {
87 87
             // Ignore closures.
88 88
             return;
89 89
         }
90 90
 
91 91
         // Is this a magic method. i.e., is prefixed with "__" ?
92
-        if (preg_match('|^__[^_]|', $methodName) > 0) {
93
-            $magicPart = strtolower(substr($methodName, 2));
94
-            if (isset($this->magicMethods[$magicPart]) === false
95
-                && isset($this->methodsDoubleUnderscore[$magicPart]) === false
92
+        if ( preg_match( '|^__[^_]|', $methodName ) > 0 ) {
93
+            $magicPart = strtolower( substr( $methodName, 2 ) );
94
+            if ( isset( $this->magicMethods[ $magicPart ] ) === false
95
+                && isset( $this->methodsDoubleUnderscore[ $magicPart ] ) === false
96 96
             ) {
97 97
                 $className         = '[anonymous class]';
98
-                $scopeNextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($currScope + 1), null, true);
99
-                if ($scopeNextNonEmpty !== false && $tokens[$scopeNextNonEmpty]['code'] === \T_STRING) {
100
-                    $className = $tokens[$scopeNextNonEmpty]['content'];
98
+                $scopeNextNonEmpty = $phpcsFile->findNext( Tokens::$emptyTokens, ( $currScope + 1 ), null, true );
99
+                if ( $scopeNextNonEmpty !== false && $tokens[ $scopeNextNonEmpty ][ 'code' ] === \T_STRING ) {
100
+                    $className = $tokens[ $scopeNextNonEmpty ][ 'content' ];
101 101
                 }
102 102
 
103 103
                 $phpcsFile->addWarning(
104 104
                     'Method name "%s" is discouraged; PHP has reserved all method names with a double underscore prefix for future use.',
105 105
                     $stackPtr,
106 106
                     'MethodDoubleUnderscore',
107
-                    array($className . '::' . $methodName)
107
+                    array( $className . '::' . $methodName )
108 108
                 );
109 109
             }
110 110
         }
@@ -120,23 +120,23 @@  discard block
 block discarded – undo
120 120
      *
121 121
      * @return void
122 122
      */
123
-    protected function processTokenOutsideScope(File $phpcsFile, $stackPtr)
123
+    protected function processTokenOutsideScope( File $phpcsFile, $stackPtr )
124 124
     {
125
-        $functionName = $phpcsFile->getDeclarationName($stackPtr);
126
-        if ($functionName === null) {
125
+        $functionName = $phpcsFile->getDeclarationName( $stackPtr );
126
+        if ( $functionName === null ) {
127 127
             // Ignore closures.
128 128
             return;
129 129
         }
130 130
 
131 131
         // Is this a magic function. i.e., it is prefixed with "__".
132
-        if (preg_match('|^__[^_]|', $functionName) > 0) {
133
-            $magicPart = strtolower(substr($functionName, 2));
134
-            if (isset($this->magicFunctions[$magicPart]) === false) {
132
+        if ( preg_match( '|^__[^_]|', $functionName ) > 0 ) {
133
+            $magicPart = strtolower( substr( $functionName, 2 ) );
134
+            if ( isset( $this->magicFunctions[ $magicPart ] ) === false ) {
135 135
                 $phpcsFile->addWarning(
136 136
                     'Function name "%s" is discouraged; PHP has reserved all method names with a double underscore prefix for future use.',
137 137
                     $stackPtr,
138 138
                     'FunctionDoubleUnderscore',
139
-                    array($functionName)
139
+                    array( $functionName )
140 140
                 );
141 141
             }
142 142
         }
Please login to merge, or discard this patch.
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -34,14 +34,12 @@  discard block
 block discarded – undo
34 34
  * @package  PHPCompatibility
35 35
  * @author   Juliette Reinders Folmer <[email protected]>
36 36
  */
37
-class ReservedFunctionNamesSniff extends PHPCS_CamelCapsFunctionNameSniff
38
-{
37
+class ReservedFunctionNamesSniff extends PHPCS_CamelCapsFunctionNameSniff {
39 38
 
40 39
     /**
41 40
      * Overload the constructor to work round various PHPCS cross-version compatibility issues.
42 41
      */
43
-    public function __construct()
44
-    {
42
+    public function __construct() {
45 43
         $scopeTokens = array(\T_CLASS, \T_INTERFACE, \T_TRAIT);
46 44
         if (\defined('T_ANON_CLASS')) {
47 45
             $scopeTokens[] = \T_ANON_CLASS;
@@ -65,8 +63,7 @@  discard block
 block discarded – undo
65 63
      *
66 64
      * @return void
67 65
      */
68
-    protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScope)
69
-    {
66
+    protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScope) {
70 67
         $tokens = $phpcsFile->getTokens();
71 68
 
72 69
         /*
@@ -120,8 +117,7 @@  discard block
 block discarded – undo
120 117
      *
121 118
      * @return void
122 119
      */
123
-    protected function processTokenOutsideScope(File $phpcsFile, $stackPtr)
124
-    {
120
+    protected function processTokenOutsideScope(File $phpcsFile, $stackPtr) {
125 121
         $functionName = $phpcsFile->getDeclarationName($stackPtr);
126 122
         if ($functionName === null) {
127 123
             // Ignore closures.
Please login to merge, or discard this patch.
PHPCompatibility/Sniffs/ParameterValues/NewNegativeStringOffsetSniff.php 3 patches
Indentation   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -29,98 +29,98 @@
 block discarded – undo
29 29
 class NewNegativeStringOffsetSniff extends AbstractFunctionCallParameterSniff
30 30
 {
31 31
 
32
-    /**
33
-     * Functions to check for.
34
-     *
35
-     * @var array Function name => 1-based parameter offset of the affected parameters => parameter name.
36
-     */
37
-    protected $targetFunctions = array(
38
-        'file_get_contents'     => array(
39
-            4 => 'offset',
40
-        ),
41
-        'grapheme_extract'      => array(
42
-            4 => 'start',
43
-        ),
44
-        'grapheme_stripos'      => array(
45
-            3 => 'offset',
46
-        ),
47
-        'grapheme_strpos'       => array(
48
-            3 => 'offset',
49
-        ),
50
-        'iconv_strpos'          => array(
51
-            3 => 'offset',
52
-        ),
53
-        'mb_ereg_search_setpos' => array(
54
-            1 => 'position',
55
-        ),
56
-        'mb_strimwidth'         => array(
57
-            2 => 'start',
58
-            3 => 'width',
59
-        ),
60
-        'mb_stripos'            => array(
61
-            3 => 'offset',
62
-        ),
63
-        'mb_strpos'             => array(
64
-            3 => 'offset',
65
-        ),
66
-        'stripos'               => array(
67
-            3 => 'offset',
68
-        ),
69
-        'strpos'                => array(
70
-            3 => 'offset',
71
-        ),
72
-        'substr_count'          => array(
73
-            3 => 'offset',
74
-            4 => 'length',
75
-        ),
76
-    );
32
+	/**
33
+	 * Functions to check for.
34
+	 *
35
+	 * @var array Function name => 1-based parameter offset of the affected parameters => parameter name.
36
+	 */
37
+	protected $targetFunctions = array(
38
+		'file_get_contents'     => array(
39
+			4 => 'offset',
40
+		),
41
+		'grapheme_extract'      => array(
42
+			4 => 'start',
43
+		),
44
+		'grapheme_stripos'      => array(
45
+			3 => 'offset',
46
+		),
47
+		'grapheme_strpos'       => array(
48
+			3 => 'offset',
49
+		),
50
+		'iconv_strpos'          => array(
51
+			3 => 'offset',
52
+		),
53
+		'mb_ereg_search_setpos' => array(
54
+			1 => 'position',
55
+		),
56
+		'mb_strimwidth'         => array(
57
+			2 => 'start',
58
+			3 => 'width',
59
+		),
60
+		'mb_stripos'            => array(
61
+			3 => 'offset',
62
+		),
63
+		'mb_strpos'             => array(
64
+			3 => 'offset',
65
+		),
66
+		'stripos'               => array(
67
+			3 => 'offset',
68
+		),
69
+		'strpos'                => array(
70
+			3 => 'offset',
71
+		),
72
+		'substr_count'          => array(
73
+			3 => 'offset',
74
+			4 => 'length',
75
+		),
76
+	);
77 77
 
78 78
 
79
-    /**
80
-     * Do a version check to determine if this sniff needs to run at all.
81
-     *
82
-     * @return bool
83
-     */
84
-    protected function bowOutEarly()
85
-    {
86
-        return ($this->supportsBelow('7.0') === false);
87
-    }
79
+	/**
80
+	 * Do a version check to determine if this sniff needs to run at all.
81
+	 *
82
+	 * @return bool
83
+	 */
84
+	protected function bowOutEarly()
85
+	{
86
+		return ($this->supportsBelow('7.0') === false);
87
+	}
88 88
 
89
-    /**
90
-     * Process the parameters of a matched function.
91
-     *
92
-     * @param \PHP_CodeSniffer_File $phpcsFile    The file being scanned.
93
-     * @param int                   $stackPtr     The position of the current token in the stack.
94
-     * @param string                $functionName The token content (function name) which was matched.
95
-     * @param array                 $parameters   Array with information about the parameters.
96
-     *
97
-     * @return int|void Integer stack pointer to skip forward or void to continue
98
-     *                  normal file processing.
99
-     */
100
-    public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
101
-    {
102
-        $functionLC = strtolower($functionName);
103
-        foreach ($this->targetFunctions[$functionLC] as $pos => $name) {
104
-            if (isset($parameters[$pos]) === false) {
105
-                continue;
106
-            }
89
+	/**
90
+	 * Process the parameters of a matched function.
91
+	 *
92
+	 * @param \PHP_CodeSniffer_File $phpcsFile    The file being scanned.
93
+	 * @param int                   $stackPtr     The position of the current token in the stack.
94
+	 * @param string                $functionName The token content (function name) which was matched.
95
+	 * @param array                 $parameters   Array with information about the parameters.
96
+	 *
97
+	 * @return int|void Integer stack pointer to skip forward or void to continue
98
+	 *                  normal file processing.
99
+	 */
100
+	public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
101
+	{
102
+		$functionLC = strtolower($functionName);
103
+		foreach ($this->targetFunctions[$functionLC] as $pos => $name) {
104
+			if (isset($parameters[$pos]) === false) {
105
+				continue;
106
+			}
107 107
 
108
-            $targetParam = $parameters[$pos];
108
+			$targetParam = $parameters[$pos];
109 109
 
110
-            if ($this->isNegativeNumber($phpcsFile, $targetParam['start'], $targetParam['end']) === false) {
111
-                continue;
112
-            }
110
+			if ($this->isNegativeNumber($phpcsFile, $targetParam['start'], $targetParam['end']) === false) {
111
+				continue;
112
+			}
113 113
 
114
-            $phpcsFile->addError(
115
-                'Negative string offsets were not supported for the $%s parameter in %s() in PHP 7.0 or lower. Found %s',
116
-                $targetParam['start'],
117
-                'Found',
118
-                array(
119
-                    $name,
120
-                    $functionName,
121
-                    $targetParam['raw'],
122
-                )
123
-            );
124
-        }
125
-    }
114
+			$phpcsFile->addError(
115
+				'Negative string offsets were not supported for the $%s parameter in %s() in PHP 7.0 or lower. Found %s',
116
+				$targetParam['start'],
117
+				'Found',
118
+				array(
119
+					$name,
120
+					$functionName,
121
+					$targetParam['raw'],
122
+				)
123
+			);
124
+		}
125
+	}
126 126
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
      */
84 84
     protected function bowOutEarly()
85 85
     {
86
-        return ($this->supportsBelow('7.0') === false);
86
+        return ( $this->supportsBelow( '7.0' ) === false );
87 87
     }
88 88
 
89 89
     /**
@@ -97,28 +97,28 @@  discard block
 block discarded – undo
97 97
      * @return int|void Integer stack pointer to skip forward or void to continue
98 98
      *                  normal file processing.
99 99
      */
100
-    public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
100
+    public function processParameters( File $phpcsFile, $stackPtr, $functionName, $parameters )
101 101
     {
102
-        $functionLC = strtolower($functionName);
103
-        foreach ($this->targetFunctions[$functionLC] as $pos => $name) {
104
-            if (isset($parameters[$pos]) === false) {
102
+        $functionLC = strtolower( $functionName );
103
+        foreach ( $this->targetFunctions[ $functionLC ] as $pos => $name ) {
104
+            if ( isset( $parameters[ $pos ] ) === false ) {
105 105
                 continue;
106 106
             }
107 107
 
108
-            $targetParam = $parameters[$pos];
108
+            $targetParam = $parameters[ $pos ];
109 109
 
110
-            if ($this->isNegativeNumber($phpcsFile, $targetParam['start'], $targetParam['end']) === false) {
110
+            if ( $this->isNegativeNumber( $phpcsFile, $targetParam[ 'start' ], $targetParam[ 'end' ] ) === false ) {
111 111
                 continue;
112 112
             }
113 113
 
114 114
             $phpcsFile->addError(
115 115
                 'Negative string offsets were not supported for the $%s parameter in %s() in PHP 7.0 or lower. Found %s',
116
-                $targetParam['start'],
116
+                $targetParam[ 'start' ],
117 117
                 'Found',
118 118
                 array(
119 119
                     $name,
120 120
                     $functionName,
121
-                    $targetParam['raw'],
121
+                    $targetParam[ 'raw' ],
122 122
                 )
123 123
             );
124 124
         }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -26,8 +26,7 @@  discard block
 block discarded – undo
26 26
  * @package  PHPCompatibility
27 27
  * @author   Juliette Reinders Folmer <[email protected]>
28 28
  */
29
-class NewNegativeStringOffsetSniff extends AbstractFunctionCallParameterSniff
30
-{
29
+class NewNegativeStringOffsetSniff extends AbstractFunctionCallParameterSniff {
31 30
 
32 31
     /**
33 32
      * Functions to check for.
@@ -81,8 +80,7 @@  discard block
 block discarded – undo
81 80
      *
82 81
      * @return bool
83 82
      */
84
-    protected function bowOutEarly()
85
-    {
83
+    protected function bowOutEarly() {
86 84
         return ($this->supportsBelow('7.0') === false);
87 85
     }
88 86
 
@@ -97,8 +95,7 @@  discard block
 block discarded – undo
97 95
      * @return int|void Integer stack pointer to skip forward or void to continue
98 96
      *                  normal file processing.
99 97
      */
100
-    public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
101
-    {
98
+    public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters) {
102 99
         $functionLC = strtolower($functionName);
103 100
         foreach ($this->targetFunctions[$functionLC] as $pos => $name) {
104 101
             if (isset($parameters[$pos]) === false) {
Please login to merge, or discard this patch.
PHPCompatibility/Sniffs/ParameterValues/NewPCREModifiersSniff.php 3 patches
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -24,92 +24,92 @@
 block discarded – undo
24 24
 class NewPCREModifiersSniff extends RemovedPCREModifiersSniff
25 25
 {
26 26
 
27
-    /**
28
-     * Functions to check for.
29
-     *
30
-     * @var array
31
-     */
32
-    protected $targetFunctions = array(
33
-        'preg_replace'                => true,
34
-        'preg_filter'                 => true,
35
-        'preg_grep'                   => true,
36
-        'preg_match_all'              => true,
37
-        'preg_match'                  => true,
38
-        'preg_replace_callback_array' => true,
39
-        'preg_replace_callback'       => true,
40
-        'preg_replace'                => true,
41
-        'preg_split'                  => true,
42
-    );
27
+	/**
28
+	 * Functions to check for.
29
+	 *
30
+	 * @var array
31
+	 */
32
+	protected $targetFunctions = array(
33
+		'preg_replace'                => true,
34
+		'preg_filter'                 => true,
35
+		'preg_grep'                   => true,
36
+		'preg_match_all'              => true,
37
+		'preg_match'                  => true,
38
+		'preg_replace_callback_array' => true,
39
+		'preg_replace_callback'       => true,
40
+		'preg_replace'                => true,
41
+		'preg_split'                  => true,
42
+	);
43 43
 
44
-    /**
45
-     * Array listing newly introduced regex modifiers.
46
-     *
47
-     * The key should be the modifier (case-sensitive!).
48
-     * The value should be the PHP version in which the modifier was introduced.
49
-     *
50
-     * @var array
51
-     */
52
-    protected $newModifiers = array(
53
-        'J' => array(
54
-            '7.1' => false,
55
-            '7.2' => true,
56
-        ),
57
-    );
44
+	/**
45
+	 * Array listing newly introduced regex modifiers.
46
+	 *
47
+	 * The key should be the modifier (case-sensitive!).
48
+	 * The value should be the PHP version in which the modifier was introduced.
49
+	 *
50
+	 * @var array
51
+	 */
52
+	protected $newModifiers = array(
53
+		'J' => array(
54
+			'7.1' => false,
55
+			'7.2' => true,
56
+		),
57
+	);
58 58
 
59 59
 
60
-    /**
61
-     * Do a version check to determine if this sniff needs to run at all.
62
-     *
63
-     * @return bool
64
-     */
65
-    protected function bowOutEarly()
66
-    {
67
-        // Version used here should be the highest version from the `$newModifiers` array,
68
-        // i.e. the last PHP version in which a new modifier was introduced.
69
-        return ($this->supportsBelow('7.2') === false);
70
-    }
60
+	/**
61
+	 * Do a version check to determine if this sniff needs to run at all.
62
+	 *
63
+	 * @return bool
64
+	 */
65
+	protected function bowOutEarly()
66
+	{
67
+		// Version used here should be the highest version from the `$newModifiers` array,
68
+		// i.e. the last PHP version in which a new modifier was introduced.
69
+		return ($this->supportsBelow('7.2') === false);
70
+	}
71 71
 
72 72
 
73
-    /**
74
-     * Examine the regex modifier string.
75
-     *
76
-     * @param \PHP_CodeSniffer_File $phpcsFile    The file being scanned.
77
-     * @param int                   $stackPtr     The position of the current token in the
78
-     *                                            stack passed in $tokens.
79
-     * @param string                $functionName The function which contained the pattern.
80
-     * @param string                $modifiers    The regex modifiers found.
81
-     *
82
-     * @return void
83
-     */
84
-    protected function examineModifiers(File $phpcsFile, $stackPtr, $functionName, $modifiers)
85
-    {
86
-        $error = 'The PCRE regex modifier "%s" is not present in PHP version %s or earlier';
73
+	/**
74
+	 * Examine the regex modifier string.
75
+	 *
76
+	 * @param \PHP_CodeSniffer_File $phpcsFile    The file being scanned.
77
+	 * @param int                   $stackPtr     The position of the current token in the
78
+	 *                                            stack passed in $tokens.
79
+	 * @param string                $functionName The function which contained the pattern.
80
+	 * @param string                $modifiers    The regex modifiers found.
81
+	 *
82
+	 * @return void
83
+	 */
84
+	protected function examineModifiers(File $phpcsFile, $stackPtr, $functionName, $modifiers)
85
+	{
86
+		$error = 'The PCRE regex modifier "%s" is not present in PHP version %s or earlier';
87 87
 
88
-        foreach ($this->newModifiers as $modifier => $versionArray) {
89
-            if (strpos($modifiers, $modifier) === false) {
90
-                continue;
91
-            }
88
+		foreach ($this->newModifiers as $modifier => $versionArray) {
89
+			if (strpos($modifiers, $modifier) === false) {
90
+				continue;
91
+			}
92 92
 
93
-            $notInVersion = '';
94
-            foreach ($versionArray as $version => $present) {
95
-                if ($notInVersion === '' && $present === false
96
-                    && $this->supportsBelow($version) === true
97
-                ) {
98
-                    $notInVersion = $version;
99
-                }
100
-            }
93
+			$notInVersion = '';
94
+			foreach ($versionArray as $version => $present) {
95
+				if ($notInVersion === '' && $present === false
96
+					&& $this->supportsBelow($version) === true
97
+				) {
98
+					$notInVersion = $version;
99
+				}
100
+			}
101 101
 
102
-            if ($notInVersion === '') {
103
-                continue;
104
-            }
102
+			if ($notInVersion === '') {
103
+				continue;
104
+			}
105 105
 
106
-            $errorCode = $modifier . 'ModifierFound';
107
-            $data      = array(
108
-                $modifier,
109
-                $notInVersion,
110
-            );
106
+			$errorCode = $modifier . 'ModifierFound';
107
+			$data      = array(
108
+				$modifier,
109
+				$notInVersion,
110
+			);
111 111
 
112
-            $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
113
-        }
114
-    }
112
+			$phpcsFile->addError($error, $stackPtr, $errorCode, $data);
113
+		}
114
+	}
115 115
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
     {
67 67
         // Version used here should be the highest version from the `$newModifiers` array,
68 68
         // i.e. the last PHP version in which a new modifier was introduced.
69
-        return ($this->supportsBelow('7.2') === false);
69
+        return ( $this->supportsBelow( '7.2' ) === false );
70 70
     }
71 71
 
72 72
 
@@ -81,25 +81,25 @@  discard block
 block discarded – undo
81 81
      *
82 82
      * @return void
83 83
      */
84
-    protected function examineModifiers(File $phpcsFile, $stackPtr, $functionName, $modifiers)
84
+    protected function examineModifiers( File $phpcsFile, $stackPtr, $functionName, $modifiers )
85 85
     {
86 86
         $error = 'The PCRE regex modifier "%s" is not present in PHP version %s or earlier';
87 87
 
88
-        foreach ($this->newModifiers as $modifier => $versionArray) {
89
-            if (strpos($modifiers, $modifier) === false) {
88
+        foreach ( $this->newModifiers as $modifier => $versionArray ) {
89
+            if ( strpos( $modifiers, $modifier ) === false ) {
90 90
                 continue;
91 91
             }
92 92
 
93 93
             $notInVersion = '';
94
-            foreach ($versionArray as $version => $present) {
95
-                if ($notInVersion === '' && $present === false
96
-                    && $this->supportsBelow($version) === true
94
+            foreach ( $versionArray as $version => $present ) {
95
+                if ( $notInVersion === '' && $present === false
96
+                    && $this->supportsBelow( $version ) === true
97 97
                 ) {
98 98
                     $notInVersion = $version;
99 99
                 }
100 100
             }
101 101
 
102
-            if ($notInVersion === '') {
102
+            if ( $notInVersion === '' ) {
103 103
                 continue;
104 104
             }
105 105
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
                 $notInVersion,
110 110
             );
111 111
 
112
-            $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
112
+            $phpcsFile->addError( $error, $stackPtr, $errorCode, $data );
113 113
         }
114 114
     }
115 115
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -21,8 +21,7 @@  discard block
 block discarded – undo
21 21
  * @package  PHPCompatibility
22 22
  * @author   Juliette Reinders Folmer <[email protected]>
23 23
  */
24
-class NewPCREModifiersSniff extends RemovedPCREModifiersSniff
25
-{
24
+class NewPCREModifiersSniff extends RemovedPCREModifiersSniff {
26 25
 
27 26
     /**
28 27
      * Functions to check for.
@@ -62,8 +61,7 @@  discard block
 block discarded – undo
62 61
      *
63 62
      * @return bool
64 63
      */
65
-    protected function bowOutEarly()
66
-    {
64
+    protected function bowOutEarly() {
67 65
         // Version used here should be the highest version from the `$newModifiers` array,
68 66
         // i.e. the last PHP version in which a new modifier was introduced.
69 67
         return ($this->supportsBelow('7.2') === false);
@@ -81,8 +79,7 @@  discard block
 block discarded – undo
81 79
      *
82 80
      * @return void
83 81
      */
84
-    protected function examineModifiers(File $phpcsFile, $stackPtr, $functionName, $modifiers)
85
-    {
82
+    protected function examineModifiers(File $phpcsFile, $stackPtr, $functionName, $modifiers) {
86 83
         $error = 'The PCRE regex modifier "%s" is not present in PHP version %s or earlier';
87 84
 
88 85
         foreach ($this->newModifiers as $modifier => $versionArray) {
Please login to merge, or discard this patch.