Completed
Pull Request — develop (#1492)
by Zack
17:43
created
PHPCompatibility/Sniffs/Classes/NewTypedPropertiesSniff.php 4 patches
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -26,100 +26,100 @@
 block discarded – undo
26 26
 class NewTypedPropertiesSniff extends Sniff
27 27
 {
28 28
 
29
-    /**
30
-     * Valid property modifier keywords.
31
-     *
32
-     * @var array
33
-     */
34
-    private $modifierKeywords = array(
35
-        \T_PRIVATE   => \T_PRIVATE,
36
-        \T_PROTECTED => \T_PROTECTED,
37
-        \T_PUBLIC    => \T_PUBLIC,
38
-        \T_STATIC    => \T_STATIC,
39
-        \T_VAR       => \T_VAR,
40
-    );
29
+	/**
30
+	 * Valid property modifier keywords.
31
+	 *
32
+	 * @var array
33
+	 */
34
+	private $modifierKeywords = array(
35
+		\T_PRIVATE   => \T_PRIVATE,
36
+		\T_PROTECTED => \T_PROTECTED,
37
+		\T_PUBLIC    => \T_PUBLIC,
38
+		\T_STATIC    => \T_STATIC,
39
+		\T_VAR       => \T_VAR,
40
+	);
41 41
 
42 42
 
43
-    /**
44
-     * Returns an array of tokens this test wants to listen for.
45
-     *
46
-     * @return array
47
-     */
48
-    public function register()
49
-    {
50
-        return array(\T_VARIABLE);
51
-    }
43
+	/**
44
+	 * Returns an array of tokens this test wants to listen for.
45
+	 *
46
+	 * @return array
47
+	 */
48
+	public function register()
49
+	{
50
+		return array(\T_VARIABLE);
51
+	}
52 52
 
53
-    /**
54
-     * Processes this test, when one of its tokens is encountered.
55
-     *
56
-     * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
57
-     * @param int                   $stackPtr  The position of the current token in the
58
-     *                                         stack passed in $tokens.
59
-     *
60
-     * @return int|void Integer stack pointer to skip forward or void to continue
61
-     *                  normal file processing.
62
-     */
63
-    public function process(File $phpcsFile, $stackPtr)
64
-    {
65
-        if ($this->isClassProperty($phpcsFile, $stackPtr) === false) {
66
-            return;
67
-        }
53
+	/**
54
+	 * Processes this test, when one of its tokens is encountered.
55
+	 *
56
+	 * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
57
+	 * @param int                   $stackPtr  The position of the current token in the
58
+	 *                                         stack passed in $tokens.
59
+	 *
60
+	 * @return int|void Integer stack pointer to skip forward or void to continue
61
+	 *                  normal file processing.
62
+	 */
63
+	public function process(File $phpcsFile, $stackPtr)
64
+	{
65
+		if ($this->isClassProperty($phpcsFile, $stackPtr) === false) {
66
+			return;
67
+		}
68 68
 
69
-        $find  = $this->modifierKeywords;
70
-        $find += array(
71
-            \T_SEMICOLON          => \T_SEMICOLON,
72
-            \T_OPEN_CURLY_BRACKET => \T_OPEN_CURLY_BRACKET,
73
-        );
69
+		$find  = $this->modifierKeywords;
70
+		$find += array(
71
+			\T_SEMICOLON          => \T_SEMICOLON,
72
+			\T_OPEN_CURLY_BRACKET => \T_OPEN_CURLY_BRACKET,
73
+		);
74 74
 
75
-        $tokens   = $phpcsFile->getTokens();
76
-        $modifier = $phpcsFile->findPrevious($find, ($stackPtr - 1));
77
-        if ($modifier === false
78
-            || $tokens[$modifier]['code'] === \T_SEMICOLON
79
-            || $tokens[$modifier]['code'] === \T_OPEN_CURLY_BRACKET
80
-        ) {
81
-            // Parse error. Ignore.
82
-            return;
83
-        }
75
+		$tokens   = $phpcsFile->getTokens();
76
+		$modifier = $phpcsFile->findPrevious($find, ($stackPtr - 1));
77
+		if ($modifier === false
78
+			|| $tokens[$modifier]['code'] === \T_SEMICOLON
79
+			|| $tokens[$modifier]['code'] === \T_OPEN_CURLY_BRACKET
80
+		) {
81
+			// Parse error. Ignore.
82
+			return;
83
+		}
84 84
 
85
-        $type = $phpcsFile->findNext(Tokens::$emptyTokens, ($modifier + 1), null, true);
86
-        if ($tokens[$type]['code'] === \T_VARIABLE) {
87
-            return;
88
-        }
85
+		$type = $phpcsFile->findNext(Tokens::$emptyTokens, ($modifier + 1), null, true);
86
+		if ($tokens[$type]['code'] === \T_VARIABLE) {
87
+			return;
88
+		}
89 89
 
90
-        // Still here ? In that case, this will be a typed property.
91
-        if ($this->supportsBelow('7.3') === true) {
92
-            $phpcsFile->addError(
93
-                'Typed properties are not supported in PHP 7.3 or earlier',
94
-                $type,
95
-                'Found'
96
-            );
97
-        }
90
+		// Still here ? In that case, this will be a typed property.
91
+		if ($this->supportsBelow('7.3') === true) {
92
+			$phpcsFile->addError(
93
+				'Typed properties are not supported in PHP 7.3 or earlier',
94
+				$type,
95
+				'Found'
96
+			);
97
+		}
98 98
 
99
-        if ($this->supportsAbove('7.4') === true) {
100
-            // Examine the type to verify it's valid.
101
-            if ($tokens[$type]['type'] === 'T_NULLABLE'
102
-                // Needed to support PHPCS < 3.5.0 which doesn't correct to the nullable token type yet.
103
-                || $tokens[$type]['code'] === \T_INLINE_THEN
104
-            ) {
105
-                $type = $phpcsFile->findNext(Tokens::$emptyTokens, ($type + 1), null, true);
106
-            }
99
+		if ($this->supportsAbove('7.4') === true) {
100
+			// Examine the type to verify it's valid.
101
+			if ($tokens[$type]['type'] === 'T_NULLABLE'
102
+				// Needed to support PHPCS < 3.5.0 which doesn't correct to the nullable token type yet.
103
+				|| $tokens[$type]['code'] === \T_INLINE_THEN
104
+			) {
105
+				$type = $phpcsFile->findNext(Tokens::$emptyTokens, ($type + 1), null, true);
106
+			}
107 107
 
108
-            $content = $tokens[$type]['content'];
109
-            if ($content === 'void' || $content === 'callable') {
110
-                $phpcsFile->addError(
111
-                    '%s is not supported as a type declaration for properties',
112
-                    $type,
113
-                    'InvalidType',
114
-                    array($content)
115
-                );
116
-            }
117
-        }
108
+			$content = $tokens[$type]['content'];
109
+			if ($content === 'void' || $content === 'callable') {
110
+				$phpcsFile->addError(
111
+					'%s is not supported as a type declaration for properties',
112
+					$type,
113
+					'InvalidType',
114
+					array($content)
115
+				);
116
+			}
117
+		}
118 118
 
119
-        $endOfStatement = $phpcsFile->findNext(\T_SEMICOLON, ($stackPtr + 1));
120
-        if ($endOfStatement !== false) {
121
-            // Don't throw the same error multiple times for multi-property declarations.
122
-            return ($endOfStatement + 1);
123
-        }
124
-    }
119
+		$endOfStatement = $phpcsFile->findNext(\T_SEMICOLON, ($stackPtr + 1));
120
+		if ($endOfStatement !== false) {
121
+			// Don't throw the same error multiple times for multi-property declarations.
122
+			return ($endOfStatement + 1);
123
+		}
124
+	}
125 125
 }
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
      */
48 48
     public function register()
49 49
     {
50
-        return array(\T_VARIABLE);
50
+        return array( \T_VARIABLE );
51 51
     }
52 52
 
53 53
     /**
@@ -60,9 +60,9 @@  discard block
 block discarded – undo
60 60
      * @return int|void Integer stack pointer to skip forward or void to continue
61 61
      *                  normal file processing.
62 62
      */
63
-    public function process(File $phpcsFile, $stackPtr)
63
+    public function process( File $phpcsFile, $stackPtr )
64 64
     {
65
-        if ($this->isClassProperty($phpcsFile, $stackPtr) === false) {
65
+        if ( $this->isClassProperty( $phpcsFile, $stackPtr ) === false ) {
66 66
             return;
67 67
         }
68 68
 
@@ -73,22 +73,22 @@  discard block
 block discarded – undo
73 73
         );
74 74
 
75 75
         $tokens   = $phpcsFile->getTokens();
76
-        $modifier = $phpcsFile->findPrevious($find, ($stackPtr - 1));
77
-        if ($modifier === false
78
-            || $tokens[$modifier]['code'] === \T_SEMICOLON
79
-            || $tokens[$modifier]['code'] === \T_OPEN_CURLY_BRACKET
76
+        $modifier = $phpcsFile->findPrevious( $find, ( $stackPtr - 1 ) );
77
+        if ( $modifier === false
78
+            || $tokens[ $modifier ][ 'code' ] === \T_SEMICOLON
79
+            || $tokens[ $modifier ][ 'code' ] === \T_OPEN_CURLY_BRACKET
80 80
         ) {
81 81
             // Parse error. Ignore.
82 82
             return;
83 83
         }
84 84
 
85
-        $type = $phpcsFile->findNext(Tokens::$emptyTokens, ($modifier + 1), null, true);
86
-        if ($tokens[$type]['code'] === \T_VARIABLE) {
85
+        $type = $phpcsFile->findNext( Tokens::$emptyTokens, ( $modifier + 1 ), null, true );
86
+        if ( $tokens[ $type ][ 'code' ] === \T_VARIABLE ) {
87 87
             return;
88 88
         }
89 89
 
90 90
         // Still here ? In that case, this will be a typed property.
91
-        if ($this->supportsBelow('7.3') === true) {
91
+        if ( $this->supportsBelow( '7.3' ) === true ) {
92 92
             $phpcsFile->addError(
93 93
                 'Typed properties are not supported in PHP 7.3 or earlier',
94 94
                 $type,
@@ -96,30 +96,30 @@  discard block
 block discarded – undo
96 96
             );
97 97
         }
98 98
 
99
-        if ($this->supportsAbove('7.4') === true) {
99
+        if ( $this->supportsAbove( '7.4' ) === true ) {
100 100
             // Examine the type to verify it's valid.
101
-            if ($tokens[$type]['type'] === 'T_NULLABLE'
101
+            if ( $tokens[ $type ][ 'type' ] === 'T_NULLABLE'
102 102
                 // Needed to support PHPCS < 3.5.0 which doesn't correct to the nullable token type yet.
103
-                || $tokens[$type]['code'] === \T_INLINE_THEN
103
+                || $tokens[ $type ][ 'code' ] === \T_INLINE_THEN
104 104
             ) {
105
-                $type = $phpcsFile->findNext(Tokens::$emptyTokens, ($type + 1), null, true);
105
+                $type = $phpcsFile->findNext( Tokens::$emptyTokens, ( $type + 1 ), null, true );
106 106
             }
107 107
 
108
-            $content = $tokens[$type]['content'];
109
-            if ($content === 'void' || $content === 'callable') {
108
+            $content = $tokens[ $type ][ 'content' ];
109
+            if ( $content === 'void' || $content === 'callable' ) {
110 110
                 $phpcsFile->addError(
111 111
                     '%s is not supported as a type declaration for properties',
112 112
                     $type,
113 113
                     'InvalidType',
114
-                    array($content)
114
+                    array( $content )
115 115
                 );
116 116
             }
117 117
         }
118 118
 
119
-        $endOfStatement = $phpcsFile->findNext(\T_SEMICOLON, ($stackPtr + 1));
120
-        if ($endOfStatement !== false) {
119
+        $endOfStatement = $phpcsFile->findNext( \T_SEMICOLON, ( $stackPtr + 1 ) );
120
+        if ( $endOfStatement !== false ) {
121 121
             // Don't throw the same error multiple times for multi-property declarations.
122
-            return ($endOfStatement + 1);
122
+            return ( $endOfStatement + 1 );
123 123
         }
124 124
     }
125 125
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -23,8 +23,7 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @since 9.2.0
25 25
  */
26
-class NewTypedPropertiesSniff extends Sniff
27
-{
26
+class NewTypedPropertiesSniff extends Sniff {
28 27
 
29 28
     /**
30 29
      * Valid property modifier keywords.
@@ -45,8 +44,7 @@  discard block
 block discarded – undo
45 44
      *
46 45
      * @return array
47 46
      */
48
-    public function register()
49
-    {
47
+    public function register() {
50 48
         return array(\T_VARIABLE);
51 49
     }
52 50
 
@@ -60,8 +58,7 @@  discard block
 block discarded – undo
60 58
      * @return int|void Integer stack pointer to skip forward or void to continue
61 59
      *                  normal file processing.
62 60
      */
63
-    public function process(File $phpcsFile, $stackPtr)
64
-    {
61
+    public function process(File $phpcsFile, $stackPtr) {
65 62
         if ($this->isClassProperty($phpcsFile, $stackPtr) === false) {
66 63
             return;
67 64
         }
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/Classes/NewLateStaticBindingSniff.php 4 patches
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -26,54 +26,54 @@
 block discarded – undo
26 26
  */
27 27
 class NewLateStaticBindingSniff extends Sniff
28 28
 {
29
-    /**
30
-     * Returns an array of tokens this test wants to listen for.
31
-     *
32
-     * @return array
33
-     */
34
-    public function register()
35
-    {
36
-        return array(\T_STATIC);
37
-    }
29
+	/**
30
+	 * Returns an array of tokens this test wants to listen for.
31
+	 *
32
+	 * @return array
33
+	 */
34
+	public function register()
35
+	{
36
+		return array(\T_STATIC);
37
+	}
38 38
 
39 39
 
40
-    /**
41
-     * Processes this test, when one of its tokens is encountered.
42
-     *
43
-     * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
44
-     * @param int                   $stackPtr  The position of the current token in the
45
-     *                                         stack passed in $tokens.
46
-     *
47
-     * @return void
48
-     */
49
-    public function process(File $phpcsFile, $stackPtr)
50
-    {
51
-        $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
52
-        if ($nextNonEmpty === false) {
53
-            return;
54
-        }
40
+	/**
41
+	 * Processes this test, when one of its tokens is encountered.
42
+	 *
43
+	 * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
44
+	 * @param int                   $stackPtr  The position of the current token in the
45
+	 *                                         stack passed in $tokens.
46
+	 *
47
+	 * @return void
48
+	 */
49
+	public function process(File $phpcsFile, $stackPtr)
50
+	{
51
+		$nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
52
+		if ($nextNonEmpty === false) {
53
+			return;
54
+		}
55 55
 
56
-        $tokens = $phpcsFile->getTokens();
57
-        if ($tokens[$nextNonEmpty]['code'] !== \T_DOUBLE_COLON) {
58
-            return;
59
-        }
56
+		$tokens = $phpcsFile->getTokens();
57
+		if ($tokens[$nextNonEmpty]['code'] !== \T_DOUBLE_COLON) {
58
+			return;
59
+		}
60 60
 
61
-        $inClass = $this->inClassScope($phpcsFile, $stackPtr, false);
61
+		$inClass = $this->inClassScope($phpcsFile, $stackPtr, false);
62 62
 
63
-        if ($inClass === true && $this->supportsBelow('5.2') === true) {
64
-            $phpcsFile->addError(
65
-                'Late static binding is not supported in PHP 5.2 or earlier.',
66
-                $stackPtr,
67
-                'Found'
68
-            );
69
-        }
63
+		if ($inClass === true && $this->supportsBelow('5.2') === true) {
64
+			$phpcsFile->addError(
65
+				'Late static binding is not supported in PHP 5.2 or earlier.',
66
+				$stackPtr,
67
+				'Found'
68
+			);
69
+		}
70 70
 
71
-        if ($inClass === false) {
72
-            $phpcsFile->addError(
73
-                'Late static binding is not supported outside of class scope.',
74
-                $stackPtr,
75
-                'OutsideClassScope'
76
-            );
77
-        }
78
-    }
71
+		if ($inClass === false) {
72
+			$phpcsFile->addError(
73
+				'Late static binding is not supported outside of class scope.',
74
+				$stackPtr,
75
+				'OutsideClassScope'
76
+			);
77
+		}
78
+	}
79 79
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
      */
34 34
     public function register()
35 35
     {
36
-        return array(\T_STATIC);
36
+        return array( \T_STATIC );
37 37
     }
38 38
 
39 39
 
@@ -46,21 +46,21 @@  discard block
 block discarded – undo
46 46
      *
47 47
      * @return void
48 48
      */
49
-    public function process(File $phpcsFile, $stackPtr)
49
+    public function process( File $phpcsFile, $stackPtr )
50 50
     {
51
-        $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
52
-        if ($nextNonEmpty === false) {
51
+        $nextNonEmpty = $phpcsFile->findNext( Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true );
52
+        if ( $nextNonEmpty === false ) {
53 53
             return;
54 54
         }
55 55
 
56 56
         $tokens = $phpcsFile->getTokens();
57
-        if ($tokens[$nextNonEmpty]['code'] !== \T_DOUBLE_COLON) {
57
+        if ( $tokens[ $nextNonEmpty ][ 'code' ] !== \T_DOUBLE_COLON ) {
58 58
             return;
59 59
         }
60 60
 
61
-        $inClass = $this->inClassScope($phpcsFile, $stackPtr, false);
61
+        $inClass = $this->inClassScope( $phpcsFile, $stackPtr, false );
62 62
 
63
-        if ($inClass === true && $this->supportsBelow('5.2') === true) {
63
+        if ( $inClass === true && $this->supportsBelow( '5.2' ) === true ) {
64 64
             $phpcsFile->addError(
65 65
                 'Late static binding is not supported in PHP 5.2 or earlier.',
66 66
                 $stackPtr,
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
             );
69 69
         }
70 70
 
71
-        if ($inClass === false) {
71
+        if ( $inClass === false ) {
72 72
             $phpcsFile->addError(
73 73
                 'Late static binding is not supported outside of class scope.',
74 74
                 $stackPtr,
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -24,15 +24,13 @@  discard block
 block discarded – undo
24 24
  * @package  PHPCompatibility
25 25
  * @author   Juliette Reinders Folmer <[email protected]>
26 26
  */
27
-class NewLateStaticBindingSniff extends Sniff
28
-{
27
+class NewLateStaticBindingSniff extends Sniff {
29 28
     /**
30 29
      * Returns an array of tokens this test wants to listen for.
31 30
      *
32 31
      * @return array
33 32
      */
34
-    public function register()
35
-    {
33
+    public function register() {
36 34
         return array(\T_STATIC);
37 35
     }
38 36
 
@@ -46,8 +44,7 @@  discard block
 block discarded – undo
46 44
      *
47 45
      * @return void
48 46
      */
49
-    public function process(File $phpcsFile, $stackPtr)
50
-    {
47
+    public function process(File $phpcsFile, $stackPtr) {
51 48
         $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
52 49
         if ($nextNonEmpty === false) {
53 50
             return;
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/Lists/ForbiddenEmptyListAssignmentSniff.php 3 patches
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -29,83 +29,83 @@
 block discarded – undo
29 29
 class ForbiddenEmptyListAssignmentSniff extends Sniff
30 30
 {
31 31
 
32
-    /**
33
-     * List of tokens to disregard when determining whether the list() is empty.
34
-     *
35
-     * @var array
36
-     */
37
-    protected $ignoreTokens = array();
32
+	/**
33
+	 * List of tokens to disregard when determining whether the list() is empty.
34
+	 *
35
+	 * @var array
36
+	 */
37
+	protected $ignoreTokens = array();
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
-        // Set up a list of tokens to disregard when determining whether the list() is empty.
47
-        // Only needs to be set up once.
48
-        $this->ignoreTokens                       = Tokens::$emptyTokens;
49
-        $this->ignoreTokens[\T_COMMA]             = \T_COMMA;
50
-        $this->ignoreTokens[\T_OPEN_PARENTHESIS]  = \T_OPEN_PARENTHESIS;
51
-        $this->ignoreTokens[\T_CLOSE_PARENTHESIS] = \T_CLOSE_PARENTHESIS;
39
+	/**
40
+	 * Returns an array of tokens this test wants to listen for.
41
+	 *
42
+	 * @return array
43
+	 */
44
+	public function register()
45
+	{
46
+		// Set up a list of tokens to disregard when determining whether the list() is empty.
47
+		// Only needs to be set up once.
48
+		$this->ignoreTokens                       = Tokens::$emptyTokens;
49
+		$this->ignoreTokens[\T_COMMA]             = \T_COMMA;
50
+		$this->ignoreTokens[\T_OPEN_PARENTHESIS]  = \T_OPEN_PARENTHESIS;
51
+		$this->ignoreTokens[\T_CLOSE_PARENTHESIS] = \T_CLOSE_PARENTHESIS;
52 52
 
53
-        return array(
54
-            \T_LIST,
55
-            \T_OPEN_SHORT_ARRAY,
56
-        );
57
-    }
53
+		return array(
54
+			\T_LIST,
55
+			\T_OPEN_SHORT_ARRAY,
56
+		);
57
+	}
58 58
 
59
-    /**
60
-     * Processes this test, when one of its tokens is encountered.
61
-     *
62
-     * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
63
-     * @param int                   $stackPtr  The position of the current token in the
64
-     *                                         stack passed in $tokens.
65
-     *
66
-     * @return void
67
-     */
68
-    public function process(File $phpcsFile, $stackPtr)
69
-    {
70
-        if ($this->supportsAbove('7.0') === false) {
71
-            return;
72
-        }
59
+	/**
60
+	 * Processes this test, when one of its tokens is encountered.
61
+	 *
62
+	 * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
63
+	 * @param int                   $stackPtr  The position of the current token in the
64
+	 *                                         stack passed in $tokens.
65
+	 *
66
+	 * @return void
67
+	 */
68
+	public function process(File $phpcsFile, $stackPtr)
69
+	{
70
+		if ($this->supportsAbove('7.0') === false) {
71
+			return;
72
+		}
73 73
 
74
-        $tokens = $phpcsFile->getTokens();
74
+		$tokens = $phpcsFile->getTokens();
75 75
 
76
-        if ($tokens[$stackPtr]['code'] === \T_OPEN_SHORT_ARRAY) {
77
-            if ($this->isShortList($phpcsFile, $stackPtr) === false) {
78
-                return;
79
-            }
76
+		if ($tokens[$stackPtr]['code'] === \T_OPEN_SHORT_ARRAY) {
77
+			if ($this->isShortList($phpcsFile, $stackPtr) === false) {
78
+				return;
79
+			}
80 80
 
81
-            $open  = $stackPtr;
82
-            $close = $tokens[$stackPtr]['bracket_closer'];
83
-        } else {
84
-            // T_LIST.
85
-            $open = $phpcsFile->findNext(\T_OPEN_PARENTHESIS, $stackPtr, null, false, null, true);
86
-            if ($open === false || isset($tokens[$open]['parenthesis_closer']) === false) {
87
-                return;
88
-            }
81
+			$open  = $stackPtr;
82
+			$close = $tokens[$stackPtr]['bracket_closer'];
83
+		} else {
84
+			// T_LIST.
85
+			$open = $phpcsFile->findNext(\T_OPEN_PARENTHESIS, $stackPtr, null, false, null, true);
86
+			if ($open === false || isset($tokens[$open]['parenthesis_closer']) === false) {
87
+				return;
88
+			}
89 89
 
90
-            $close = $tokens[$open]['parenthesis_closer'];
91
-        }
90
+			$close = $tokens[$open]['parenthesis_closer'];
91
+		}
92 92
 
93
-        $error = true;
94
-        if (($close - $open) > 1) {
95
-            for ($cnt = $open + 1; $cnt < $close; $cnt++) {
96
-                if (isset($this->ignoreTokens[$tokens[$cnt]['code']]) === false) {
97
-                    $error = false;
98
-                    break;
99
-                }
100
-            }
101
-        }
93
+		$error = true;
94
+		if (($close - $open) > 1) {
95
+			for ($cnt = $open + 1; $cnt < $close; $cnt++) {
96
+				if (isset($this->ignoreTokens[$tokens[$cnt]['code']]) === false) {
97
+					$error = false;
98
+					break;
99
+				}
100
+			}
101
+		}
102 102
 
103
-        if ($error === true) {
104
-            $phpcsFile->addError(
105
-                'Empty list() assignments are not allowed since PHP 7.0',
106
-                $stackPtr,
107
-                'Found'
108
-            );
109
-        }
110
-    }
103
+		if ($error === true) {
104
+			$phpcsFile->addError(
105
+				'Empty list() assignments are not allowed since PHP 7.0',
106
+				$stackPtr,
107
+				'Found'
108
+			);
109
+		}
110
+	}
111 111
 }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -46,9 +46,9 @@  discard block
 block discarded – undo
46 46
         // Set up a list of tokens to disregard when determining whether the list() is empty.
47 47
         // Only needs to be set up once.
48 48
         $this->ignoreTokens                       = Tokens::$emptyTokens;
49
-        $this->ignoreTokens[\T_COMMA]             = \T_COMMA;
50
-        $this->ignoreTokens[\T_OPEN_PARENTHESIS]  = \T_OPEN_PARENTHESIS;
51
-        $this->ignoreTokens[\T_CLOSE_PARENTHESIS] = \T_CLOSE_PARENTHESIS;
49
+        $this->ignoreTokens[ \T_COMMA ]             = \T_COMMA;
50
+        $this->ignoreTokens[ \T_OPEN_PARENTHESIS ]  = \T_OPEN_PARENTHESIS;
51
+        $this->ignoreTokens[ \T_CLOSE_PARENTHESIS ] = \T_CLOSE_PARENTHESIS;
52 52
 
53 53
         return array(
54 54
             \T_LIST,
@@ -65,42 +65,42 @@  discard block
 block discarded – undo
65 65
      *
66 66
      * @return void
67 67
      */
68
-    public function process(File $phpcsFile, $stackPtr)
68
+    public function process( File $phpcsFile, $stackPtr )
69 69
     {
70
-        if ($this->supportsAbove('7.0') === false) {
70
+        if ( $this->supportsAbove( '7.0' ) === false ) {
71 71
             return;
72 72
         }
73 73
 
74 74
         $tokens = $phpcsFile->getTokens();
75 75
 
76
-        if ($tokens[$stackPtr]['code'] === \T_OPEN_SHORT_ARRAY) {
77
-            if ($this->isShortList($phpcsFile, $stackPtr) === false) {
76
+        if ( $tokens[ $stackPtr ][ 'code' ] === \T_OPEN_SHORT_ARRAY ) {
77
+            if ( $this->isShortList( $phpcsFile, $stackPtr ) === false ) {
78 78
                 return;
79 79
             }
80 80
 
81 81
             $open  = $stackPtr;
82
-            $close = $tokens[$stackPtr]['bracket_closer'];
82
+            $close = $tokens[ $stackPtr ][ 'bracket_closer' ];
83 83
         } else {
84 84
             // T_LIST.
85
-            $open = $phpcsFile->findNext(\T_OPEN_PARENTHESIS, $stackPtr, null, false, null, true);
86
-            if ($open === false || isset($tokens[$open]['parenthesis_closer']) === false) {
85
+            $open = $phpcsFile->findNext( \T_OPEN_PARENTHESIS, $stackPtr, null, false, null, true );
86
+            if ( $open === false || isset( $tokens[ $open ][ 'parenthesis_closer' ] ) === false ) {
87 87
                 return;
88 88
             }
89 89
 
90
-            $close = $tokens[$open]['parenthesis_closer'];
90
+            $close = $tokens[ $open ][ 'parenthesis_closer' ];
91 91
         }
92 92
 
93 93
         $error = true;
94
-        if (($close - $open) > 1) {
95
-            for ($cnt = $open + 1; $cnt < $close; $cnt++) {
96
-                if (isset($this->ignoreTokens[$tokens[$cnt]['code']]) === false) {
94
+        if ( ( $close - $open ) > 1 ) {
95
+            for ( $cnt = $open + 1; $cnt < $close; $cnt++ ) {
96
+                if ( isset( $this->ignoreTokens[ $tokens[ $cnt ][ 'code' ] ] ) === false ) {
97 97
                     $error = false;
98 98
                     break;
99 99
                 }
100 100
             }
101 101
         }
102 102
 
103
-        if ($error === true) {
103
+        if ( $error === true ) {
104 104
             $phpcsFile->addError(
105 105
                 'Empty list() assignments are not allowed since PHP 7.0',
106 106
                 $stackPtr,
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   Wim Godden <[email protected]>
28 28
  */
29
-class ForbiddenEmptyListAssignmentSniff extends Sniff
30
-{
29
+class ForbiddenEmptyListAssignmentSniff extends Sniff {
31 30
 
32 31
     /**
33 32
      * List of tokens to disregard when determining whether the list() is empty.
@@ -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
         // Set up a list of tokens to disregard when determining whether the list() is empty.
47 45
         // Only needs to be set up once.
48 46
         $this->ignoreTokens                       = Tokens::$emptyTokens;
@@ -65,8 +63,7 @@  discard block
 block discarded – undo
65 63
      *
66 64
      * @return void
67 65
      */
68
-    public function process(File $phpcsFile, $stackPtr)
69
-    {
66
+    public function process(File $phpcsFile, $stackPtr) {
70 67
         if ($this->supportsAbove('7.0') === false) {
71 68
             return;
72 69
         }
Please login to merge, or discard this patch.
php-compatibility/PHPCompatibility/Sniffs/Lists/NewKeyedListSniff.php 3 patches
Indentation   +180 added lines, -180 removed lines patch added patch discarded remove patch
@@ -28,184 +28,184 @@
 block discarded – undo
28 28
  */
29 29
 class NewKeyedListSniff extends Sniff
30 30
 {
31
-    /**
32
-     * Tokens which represent the start of a list construct.
33
-     *
34
-     * @var array
35
-     */
36
-    protected $sniffTargets =  array(
37
-        \T_LIST             => \T_LIST,
38
-        \T_OPEN_SHORT_ARRAY => \T_OPEN_SHORT_ARRAY,
39
-    );
40
-
41
-    /**
42
-     * The token(s) within the list construct which is being targeted.
43
-     *
44
-     * @var array
45
-     */
46
-    protected $targetsInList = array(
47
-        \T_DOUBLE_ARROW => \T_DOUBLE_ARROW,
48
-    );
49
-
50
-    /**
51
-     * All tokens needed to walk through the list construct and
52
-     * determine whether the target token is contained within.
53
-     *
54
-     * Set by the setUpAllTargets() method which is called from within register().
55
-     *
56
-     * @var array
57
-     */
58
-    protected $allTargets;
59
-
60
-
61
-    /**
62
-     * Returns an array of tokens this test wants to listen for.
63
-     *
64
-     * @return array
65
-     */
66
-    public function register()
67
-    {
68
-        $this->setUpAllTargets();
69
-
70
-        return $this->sniffTargets;
71
-    }
72
-
73
-    /**
74
-     * Prepare the $allTargets array only once.
75
-     *
76
-     * @return array
77
-     */
78
-    public function setUpAllTargets()
79
-    {
80
-        $this->allTargets = $this->sniffTargets + $this->targetsInList;
81
-    }
82
-
83
-    /**
84
-     * Do a version check to determine if this sniff needs to run at all.
85
-     *
86
-     * @return bool
87
-     */
88
-    protected function bowOutEarly()
89
-    {
90
-        return ($this->supportsBelow('7.0') === false);
91
-    }
92
-
93
-    /**
94
-     * Processes this test, when one of its tokens is encountered.
95
-     *
96
-     * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
97
-     * @param int                   $stackPtr  The position of the current token in the
98
-     *                                         stack passed in $tokens.
99
-     *
100
-     * @return void
101
-     */
102
-    public function process(File $phpcsFile, $stackPtr)
103
-    {
104
-        if ($this->bowOutEarly() === true) {
105
-            return;
106
-        }
107
-
108
-        $tokens = $phpcsFile->getTokens();
109
-
110
-        if ($tokens[$stackPtr]['code'] === \T_OPEN_SHORT_ARRAY
111
-            && $this->isShortList($phpcsFile, $stackPtr) === false
112
-        ) {
113
-            // Short array, not short list.
114
-            return;
115
-        }
116
-
117
-        if ($tokens[$stackPtr]['code'] === \T_LIST) {
118
-            $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
119
-            if ($nextNonEmpty === false
120
-                || $tokens[$nextNonEmpty]['code'] !== \T_OPEN_PARENTHESIS
121
-                || isset($tokens[$nextNonEmpty]['parenthesis_closer']) === false
122
-            ) {
123
-                // Parse error or live coding.
124
-                return;
125
-            }
126
-
127
-            $opener = $nextNonEmpty;
128
-            $closer = $tokens[$nextNonEmpty]['parenthesis_closer'];
129
-        } else {
130
-            // Short list syntax.
131
-            $opener = $stackPtr;
132
-
133
-            if (isset($tokens[$stackPtr]['bracket_closer'])) {
134
-                $closer = $tokens[$stackPtr]['bracket_closer'];
135
-            }
136
-        }
137
-
138
-        if (isset($opener, $closer) === false) {
139
-            return;
140
-        }
141
-
142
-        $this->examineList($phpcsFile, $opener, $closer);
143
-    }
144
-
145
-
146
-    /**
147
-     * Examine the contents of a list construct to determine whether an error needs to be thrown.
148
-     *
149
-     * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
150
-     * @param int                   $opener    The position of the list open token.
151
-     * @param int                   $closer    The position of the list close token.
152
-     *
153
-     * @return void
154
-     */
155
-    protected function examineList(File $phpcsFile, $opener, $closer)
156
-    {
157
-        $start = $opener;
158
-        while (($start = $this->hasTargetInList($phpcsFile, $start, $closer)) !== false) {
159
-            $phpcsFile->addError(
160
-                'Specifying keys in list constructs is not supported in PHP 7.0 or earlier.',
161
-                $start,
162
-                'Found'
163
-            );
164
-        }
165
-    }
166
-
167
-
168
-    /**
169
-     * Check whether a certain target token exists within a list construct.
170
-     *
171
-     * Skips past nested list constructs, so these can be examined based on their own token.
172
-     *
173
-     * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
174
-     * @param int                   $start     The position of the list open token or a token
175
-     *                                         within the list to start (resume) the examination from.
176
-     * @param int                   $closer    The position of the list close token.
177
-     *
178
-     * @return int|bool Stack pointer to the target token if encountered. False otherwise.
179
-     */
180
-    protected function hasTargetInList(File $phpcsFile, $start, $closer)
181
-    {
182
-        $tokens = $phpcsFile->getTokens();
183
-
184
-        for ($i = ($start + 1); $i < $closer; $i++) {
185
-            if (isset($this->allTargets[$tokens[$i]['code']]) === false) {
186
-                continue;
187
-            }
188
-
189
-            if (isset($this->targetsInList[$tokens[$i]['code']]) === true) {
190
-                return $i;
191
-            }
192
-
193
-            // Skip past nested list constructs.
194
-            if ($tokens[$i]['code'] === \T_LIST) {
195
-                $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($i + 1), null, true);
196
-                if ($nextNonEmpty !== false
197
-                    && $tokens[$nextNonEmpty]['code'] === \T_OPEN_PARENTHESIS
198
-                    && isset($tokens[$nextNonEmpty]['parenthesis_closer']) === true
199
-                ) {
200
-                    $i = $tokens[$nextNonEmpty]['parenthesis_closer'];
201
-                }
202
-            } elseif ($tokens[$i]['code'] === \T_OPEN_SHORT_ARRAY
203
-                && isset($tokens[$i]['bracket_closer'])
204
-            ) {
205
-                $i = $tokens[$i]['bracket_closer'];
206
-            }
207
-        }
208
-
209
-        return false;
210
-    }
31
+	/**
32
+	 * Tokens which represent the start of a list construct.
33
+	 *
34
+	 * @var array
35
+	 */
36
+	protected $sniffTargets =  array(
37
+		\T_LIST             => \T_LIST,
38
+		\T_OPEN_SHORT_ARRAY => \T_OPEN_SHORT_ARRAY,
39
+	);
40
+
41
+	/**
42
+	 * The token(s) within the list construct which is being targeted.
43
+	 *
44
+	 * @var array
45
+	 */
46
+	protected $targetsInList = array(
47
+		\T_DOUBLE_ARROW => \T_DOUBLE_ARROW,
48
+	);
49
+
50
+	/**
51
+	 * All tokens needed to walk through the list construct and
52
+	 * determine whether the target token is contained within.
53
+	 *
54
+	 * Set by the setUpAllTargets() method which is called from within register().
55
+	 *
56
+	 * @var array
57
+	 */
58
+	protected $allTargets;
59
+
60
+
61
+	/**
62
+	 * Returns an array of tokens this test wants to listen for.
63
+	 *
64
+	 * @return array
65
+	 */
66
+	public function register()
67
+	{
68
+		$this->setUpAllTargets();
69
+
70
+		return $this->sniffTargets;
71
+	}
72
+
73
+	/**
74
+	 * Prepare the $allTargets array only once.
75
+	 *
76
+	 * @return array
77
+	 */
78
+	public function setUpAllTargets()
79
+	{
80
+		$this->allTargets = $this->sniffTargets + $this->targetsInList;
81
+	}
82
+
83
+	/**
84
+	 * Do a version check to determine if this sniff needs to run at all.
85
+	 *
86
+	 * @return bool
87
+	 */
88
+	protected function bowOutEarly()
89
+	{
90
+		return ($this->supportsBelow('7.0') === false);
91
+	}
92
+
93
+	/**
94
+	 * Processes this test, when one of its tokens is encountered.
95
+	 *
96
+	 * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
97
+	 * @param int                   $stackPtr  The position of the current token in the
98
+	 *                                         stack passed in $tokens.
99
+	 *
100
+	 * @return void
101
+	 */
102
+	public function process(File $phpcsFile, $stackPtr)
103
+	{
104
+		if ($this->bowOutEarly() === true) {
105
+			return;
106
+		}
107
+
108
+		$tokens = $phpcsFile->getTokens();
109
+
110
+		if ($tokens[$stackPtr]['code'] === \T_OPEN_SHORT_ARRAY
111
+			&& $this->isShortList($phpcsFile, $stackPtr) === false
112
+		) {
113
+			// Short array, not short list.
114
+			return;
115
+		}
116
+
117
+		if ($tokens[$stackPtr]['code'] === \T_LIST) {
118
+			$nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
119
+			if ($nextNonEmpty === false
120
+				|| $tokens[$nextNonEmpty]['code'] !== \T_OPEN_PARENTHESIS
121
+				|| isset($tokens[$nextNonEmpty]['parenthesis_closer']) === false
122
+			) {
123
+				// Parse error or live coding.
124
+				return;
125
+			}
126
+
127
+			$opener = $nextNonEmpty;
128
+			$closer = $tokens[$nextNonEmpty]['parenthesis_closer'];
129
+		} else {
130
+			// Short list syntax.
131
+			$opener = $stackPtr;
132
+
133
+			if (isset($tokens[$stackPtr]['bracket_closer'])) {
134
+				$closer = $tokens[$stackPtr]['bracket_closer'];
135
+			}
136
+		}
137
+
138
+		if (isset($opener, $closer) === false) {
139
+			return;
140
+		}
141
+
142
+		$this->examineList($phpcsFile, $opener, $closer);
143
+	}
144
+
145
+
146
+	/**
147
+	 * Examine the contents of a list construct to determine whether an error needs to be thrown.
148
+	 *
149
+	 * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
150
+	 * @param int                   $opener    The position of the list open token.
151
+	 * @param int                   $closer    The position of the list close token.
152
+	 *
153
+	 * @return void
154
+	 */
155
+	protected function examineList(File $phpcsFile, $opener, $closer)
156
+	{
157
+		$start = $opener;
158
+		while (($start = $this->hasTargetInList($phpcsFile, $start, $closer)) !== false) {
159
+			$phpcsFile->addError(
160
+				'Specifying keys in list constructs is not supported in PHP 7.0 or earlier.',
161
+				$start,
162
+				'Found'
163
+			);
164
+		}
165
+	}
166
+
167
+
168
+	/**
169
+	 * Check whether a certain target token exists within a list construct.
170
+	 *
171
+	 * Skips past nested list constructs, so these can be examined based on their own token.
172
+	 *
173
+	 * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
174
+	 * @param int                   $start     The position of the list open token or a token
175
+	 *                                         within the list to start (resume) the examination from.
176
+	 * @param int                   $closer    The position of the list close token.
177
+	 *
178
+	 * @return int|bool Stack pointer to the target token if encountered. False otherwise.
179
+	 */
180
+	protected function hasTargetInList(File $phpcsFile, $start, $closer)
181
+	{
182
+		$tokens = $phpcsFile->getTokens();
183
+
184
+		for ($i = ($start + 1); $i < $closer; $i++) {
185
+			if (isset($this->allTargets[$tokens[$i]['code']]) === false) {
186
+				continue;
187
+			}
188
+
189
+			if (isset($this->targetsInList[$tokens[$i]['code']]) === true) {
190
+				return $i;
191
+			}
192
+
193
+			// Skip past nested list constructs.
194
+			if ($tokens[$i]['code'] === \T_LIST) {
195
+				$nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($i + 1), null, true);
196
+				if ($nextNonEmpty !== false
197
+					&& $tokens[$nextNonEmpty]['code'] === \T_OPEN_PARENTHESIS
198
+					&& isset($tokens[$nextNonEmpty]['parenthesis_closer']) === true
199
+				) {
200
+					$i = $tokens[$nextNonEmpty]['parenthesis_closer'];
201
+				}
202
+			} elseif ($tokens[$i]['code'] === \T_OPEN_SHORT_ARRAY
203
+				&& isset($tokens[$i]['bracket_closer'])
204
+			) {
205
+				$i = $tokens[$i]['bracket_closer'];
206
+			}
207
+		}
208
+
209
+		return false;
210
+	}
211 211
 }
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
      *
34 34
      * @var array
35 35
      */
36
-    protected $sniffTargets =  array(
36
+    protected $sniffTargets = array(
37 37
         \T_LIST             => \T_LIST,
38 38
         \T_OPEN_SHORT_ARRAY => \T_OPEN_SHORT_ARRAY,
39 39
     );
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
      */
88 88
     protected function bowOutEarly()
89 89
     {
90
-        return ($this->supportsBelow('7.0') === false);
90
+        return ( $this->supportsBelow( '7.0' ) === false );
91 91
     }
92 92
 
93 93
     /**
@@ -99,47 +99,47 @@  discard block
 block discarded – undo
99 99
      *
100 100
      * @return void
101 101
      */
102
-    public function process(File $phpcsFile, $stackPtr)
102
+    public function process( File $phpcsFile, $stackPtr )
103 103
     {
104
-        if ($this->bowOutEarly() === true) {
104
+        if ( $this->bowOutEarly() === true ) {
105 105
             return;
106 106
         }
107 107
 
108 108
         $tokens = $phpcsFile->getTokens();
109 109
 
110
-        if ($tokens[$stackPtr]['code'] === \T_OPEN_SHORT_ARRAY
111
-            && $this->isShortList($phpcsFile, $stackPtr) === false
110
+        if ( $tokens[ $stackPtr ][ 'code' ] === \T_OPEN_SHORT_ARRAY
111
+            && $this->isShortList( $phpcsFile, $stackPtr ) === false
112 112
         ) {
113 113
             // Short array, not short list.
114 114
             return;
115 115
         }
116 116
 
117
-        if ($tokens[$stackPtr]['code'] === \T_LIST) {
118
-            $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
119
-            if ($nextNonEmpty === false
120
-                || $tokens[$nextNonEmpty]['code'] !== \T_OPEN_PARENTHESIS
121
-                || isset($tokens[$nextNonEmpty]['parenthesis_closer']) === false
117
+        if ( $tokens[ $stackPtr ][ 'code' ] === \T_LIST ) {
118
+            $nextNonEmpty = $phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true );
119
+            if ( $nextNonEmpty === false
120
+                || $tokens[ $nextNonEmpty ][ 'code' ] !== \T_OPEN_PARENTHESIS
121
+                || isset( $tokens[ $nextNonEmpty ][ 'parenthesis_closer' ] ) === false
122 122
             ) {
123 123
                 // Parse error or live coding.
124 124
                 return;
125 125
             }
126 126
 
127 127
             $opener = $nextNonEmpty;
128
-            $closer = $tokens[$nextNonEmpty]['parenthesis_closer'];
128
+            $closer = $tokens[ $nextNonEmpty ][ 'parenthesis_closer' ];
129 129
         } else {
130 130
             // Short list syntax.
131 131
             $opener = $stackPtr;
132 132
 
133
-            if (isset($tokens[$stackPtr]['bracket_closer'])) {
134
-                $closer = $tokens[$stackPtr]['bracket_closer'];
133
+            if ( isset( $tokens[ $stackPtr ][ 'bracket_closer' ] ) ) {
134
+                $closer = $tokens[ $stackPtr ][ 'bracket_closer' ];
135 135
             }
136 136
         }
137 137
 
138
-        if (isset($opener, $closer) === false) {
138
+        if ( isset( $opener, $closer ) === false ) {
139 139
             return;
140 140
         }
141 141
 
142
-        $this->examineList($phpcsFile, $opener, $closer);
142
+        $this->examineList( $phpcsFile, $opener, $closer );
143 143
     }
144 144
 
145 145
 
@@ -152,10 +152,10 @@  discard block
 block discarded – undo
152 152
      *
153 153
      * @return void
154 154
      */
155
-    protected function examineList(File $phpcsFile, $opener, $closer)
155
+    protected function examineList( File $phpcsFile, $opener, $closer )
156 156
     {
157 157
         $start = $opener;
158
-        while (($start = $this->hasTargetInList($phpcsFile, $start, $closer)) !== false) {
158
+        while ( ( $start = $this->hasTargetInList( $phpcsFile, $start, $closer ) ) !== false ) {
159 159
             $phpcsFile->addError(
160 160
                 'Specifying keys in list constructs is not supported in PHP 7.0 or earlier.',
161 161
                 $start,
@@ -177,32 +177,32 @@  discard block
 block discarded – undo
177 177
      *
178 178
      * @return int|bool Stack pointer to the target token if encountered. False otherwise.
179 179
      */
180
-    protected function hasTargetInList(File $phpcsFile, $start, $closer)
180
+    protected function hasTargetInList( File $phpcsFile, $start, $closer )
181 181
     {
182 182
         $tokens = $phpcsFile->getTokens();
183 183
 
184
-        for ($i = ($start + 1); $i < $closer; $i++) {
185
-            if (isset($this->allTargets[$tokens[$i]['code']]) === false) {
184
+        for ( $i = ( $start + 1 ); $i < $closer; $i++ ) {
185
+            if ( isset( $this->allTargets[ $tokens[ $i ][ 'code' ] ] ) === false ) {
186 186
                 continue;
187 187
             }
188 188
 
189
-            if (isset($this->targetsInList[$tokens[$i]['code']]) === true) {
189
+            if ( isset( $this->targetsInList[ $tokens[ $i ][ 'code' ] ] ) === true ) {
190 190
                 return $i;
191 191
             }
192 192
 
193 193
             // Skip past nested list constructs.
194
-            if ($tokens[$i]['code'] === \T_LIST) {
195
-                $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($i + 1), null, true);
196
-                if ($nextNonEmpty !== false
197
-                    && $tokens[$nextNonEmpty]['code'] === \T_OPEN_PARENTHESIS
198
-                    && isset($tokens[$nextNonEmpty]['parenthesis_closer']) === true
194
+            if ( $tokens[ $i ][ 'code' ] === \T_LIST ) {
195
+                $nextNonEmpty = $phpcsFile->findNext( Tokens::$emptyTokens, ( $i + 1 ), null, true );
196
+                if ( $nextNonEmpty !== false
197
+                    && $tokens[ $nextNonEmpty ][ 'code' ] === \T_OPEN_PARENTHESIS
198
+                    && isset( $tokens[ $nextNonEmpty ][ 'parenthesis_closer' ] ) === true
199 199
                 ) {
200
-                    $i = $tokens[$nextNonEmpty]['parenthesis_closer'];
200
+                    $i = $tokens[ $nextNonEmpty ][ 'parenthesis_closer' ];
201 201
                 }
202
-            } elseif ($tokens[$i]['code'] === \T_OPEN_SHORT_ARRAY
203
-                && isset($tokens[$i]['bracket_closer'])
202
+            } elseif ( $tokens[ $i ][ 'code' ] === \T_OPEN_SHORT_ARRAY
203
+                && isset( $tokens[ $i ][ 'bracket_closer' ] )
204 204
             ) {
205
-                $i = $tokens[$i]['bracket_closer'];
205
+                $i = $tokens[ $i ][ 'bracket_closer' ];
206 206
             }
207 207
         }
208 208
 
Please login to merge, or discard this patch.
Braces   +7 added lines, -14 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 NewKeyedListSniff extends Sniff
30
-{
29
+class NewKeyedListSniff extends Sniff {
31 30
     /**
32 31
      * Tokens which represent the start of a list construct.
33 32
      *
@@ -63,8 +62,7 @@  discard block
 block discarded – undo
63 62
      *
64 63
      * @return array
65 64
      */
66
-    public function register()
67
-    {
65
+    public function register() {
68 66
         $this->setUpAllTargets();
69 67
 
70 68
         return $this->sniffTargets;
@@ -75,8 +73,7 @@  discard block
 block discarded – undo
75 73
      *
76 74
      * @return array
77 75
      */
78
-    public function setUpAllTargets()
79
-    {
76
+    public function setUpAllTargets() {
80 77
         $this->allTargets = $this->sniffTargets + $this->targetsInList;
81 78
     }
82 79
 
@@ -85,8 +82,7 @@  discard block
 block discarded – undo
85 82
      *
86 83
      * @return bool
87 84
      */
88
-    protected function bowOutEarly()
89
-    {
85
+    protected function bowOutEarly() {
90 86
         return ($this->supportsBelow('7.0') === false);
91 87
     }
92 88
 
@@ -99,8 +95,7 @@  discard block
 block discarded – undo
99 95
      *
100 96
      * @return void
101 97
      */
102
-    public function process(File $phpcsFile, $stackPtr)
103
-    {
98
+    public function process(File $phpcsFile, $stackPtr) {
104 99
         if ($this->bowOutEarly() === true) {
105 100
             return;
106 101
         }
@@ -152,8 +147,7 @@  discard block
 block discarded – undo
152 147
      *
153 148
      * @return void
154 149
      */
155
-    protected function examineList(File $phpcsFile, $opener, $closer)
156
-    {
150
+    protected function examineList(File $phpcsFile, $opener, $closer) {
157 151
         $start = $opener;
158 152
         while (($start = $this->hasTargetInList($phpcsFile, $start, $closer)) !== false) {
159 153
             $phpcsFile->addError(
@@ -177,8 +171,7 @@  discard block
 block discarded – undo
177 171
      *
178 172
      * @return int|bool Stack pointer to the target token if encountered. False otherwise.
179 173
      */
180
-    protected function hasTargetInList(File $phpcsFile, $start, $closer)
181
-    {
174
+    protected function hasTargetInList(File $phpcsFile, $start, $closer) {
182 175
         $tokens = $phpcsFile->getTokens();
183 176
 
184 177
         for ($i = ($start + 1); $i < $closer; $i++) {
Please login to merge, or discard this patch.
php-compatibility/PHPCompatibility/Sniffs/Lists/NewShortListSniff.php 4 patches
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -30,51 +30,51 @@
 block discarded – undo
30 30
 class NewShortListSniff extends Sniff
31 31
 {
32 32
 
33
-    /**
34
-     * Returns an array of tokens this test wants to listen for.
35
-     *
36
-     * @return array
37
-     */
38
-    public function register()
39
-    {
40
-        return array(\T_OPEN_SHORT_ARRAY);
41
-    }
33
+	/**
34
+	 * Returns an array of tokens this test wants to listen for.
35
+	 *
36
+	 * @return array
37
+	 */
38
+	public function register()
39
+	{
40
+		return array(\T_OPEN_SHORT_ARRAY);
41
+	}
42 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 int|void Integer stack pointer to skip forward or void to continue
51
-     *                  normal file processing.
52
-     */
53
-    public function process(File $phpcsFile, $stackPtr)
54
-    {
55
-        if ($this->supportsBelow('7.0') === false) {
56
-            return;
57
-        }
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 int|void Integer stack pointer to skip forward or void to continue
51
+	 *                  normal file processing.
52
+	 */
53
+	public function process(File $phpcsFile, $stackPtr)
54
+	{
55
+		if ($this->supportsBelow('7.0') === false) {
56
+			return;
57
+		}
58 58
 
59
-        if ($this->isShortList($phpcsFile, $stackPtr) === false) {
60
-            return;
61
-        }
59
+		if ($this->isShortList($phpcsFile, $stackPtr) === false) {
60
+			return;
61
+		}
62 62
 
63
-        $tokens = $phpcsFile->getTokens();
64
-        $closer = $tokens[$stackPtr]['bracket_closer'];
63
+		$tokens = $phpcsFile->getTokens();
64
+		$closer = $tokens[$stackPtr]['bracket_closer'];
65 65
 
66
-        $hasVariable = $phpcsFile->findNext(\T_VARIABLE, ($stackPtr + 1), $closer);
67
-        if ($hasVariable === false) {
68
-            // List syntax is only valid if there are variables in it.
69
-            return;
70
-        }
66
+		$hasVariable = $phpcsFile->findNext(\T_VARIABLE, ($stackPtr + 1), $closer);
67
+		if ($hasVariable === false) {
68
+			// List syntax is only valid if there are variables in it.
69
+			return;
70
+		}
71 71
 
72
-        $phpcsFile->addError(
73
-            'The shorthand list syntax "[]" to destructure arrays is not available in PHP 7.0 or earlier.',
74
-            $stackPtr,
75
-            'Found'
76
-        );
72
+		$phpcsFile->addError(
73
+			'The shorthand list syntax "[]" to destructure arrays is not available in PHP 7.0 or earlier.',
74
+			$stackPtr,
75
+			'Found'
76
+		);
77 77
 
78
-        return ($closer + 1);
79
-    }
78
+		return ($closer + 1);
79
+	}
80 80
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
      */
38 38
     public function register()
39 39
     {
40
-        return array(\T_OPEN_SHORT_ARRAY);
40
+        return array( \T_OPEN_SHORT_ARRAY );
41 41
     }
42 42
 
43 43
     /**
@@ -50,21 +50,21 @@  discard block
 block discarded – undo
50 50
      * @return int|void Integer stack pointer to skip forward or void to continue
51 51
      *                  normal file processing.
52 52
      */
53
-    public function process(File $phpcsFile, $stackPtr)
53
+    public function process( File $phpcsFile, $stackPtr )
54 54
     {
55
-        if ($this->supportsBelow('7.0') === false) {
55
+        if ( $this->supportsBelow( '7.0' ) === false ) {
56 56
             return;
57 57
         }
58 58
 
59
-        if ($this->isShortList($phpcsFile, $stackPtr) === false) {
59
+        if ( $this->isShortList( $phpcsFile, $stackPtr ) === false ) {
60 60
             return;
61 61
         }
62 62
 
63 63
         $tokens = $phpcsFile->getTokens();
64
-        $closer = $tokens[$stackPtr]['bracket_closer'];
64
+        $closer = $tokens[ $stackPtr ][ 'bracket_closer' ];
65 65
 
66
-        $hasVariable = $phpcsFile->findNext(\T_VARIABLE, ($stackPtr + 1), $closer);
67
-        if ($hasVariable === false) {
66
+        $hasVariable = $phpcsFile->findNext( \T_VARIABLE, ( $stackPtr + 1 ), $closer );
67
+        if ( $hasVariable === false ) {
68 68
             // List syntax is only valid if there are variables in it.
69 69
             return;
70 70
         }
@@ -75,6 +75,6 @@  discard block
 block discarded – undo
75 75
             'Found'
76 76
         );
77 77
 
78
-        return ($closer + 1);
78
+        return ( $closer + 1 );
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
@@ -27,16 +27,14 @@  discard block
 block discarded – undo
27 27
  * @package  PHPCompatibility
28 28
  * @author   Juliette Reinders Folmer <[email protected]>
29 29
  */
30
-class NewShortListSniff extends Sniff
31
-{
30
+class NewShortListSniff extends Sniff {
32 31
 
33 32
     /**
34 33
      * Returns an array of tokens this test wants to listen for.
35 34
      *
36 35
      * @return array
37 36
      */
38
-    public function register()
39
-    {
37
+    public function register() {
40 38
         return array(\T_OPEN_SHORT_ARRAY);
41 39
     }
42 40
 
@@ -50,8 +48,7 @@  discard block
 block discarded – undo
50 48
      * @return int|void Integer stack pointer to skip forward or void to continue
51 49
      *                  normal file processing.
52 50
      */
53
-    public function process(File $phpcsFile, $stackPtr)
54
-    {
51
+    public function process(File $phpcsFile, $stackPtr) {
55 52
         if ($this->supportsBelow('7.0') === false) {
56 53
             return;
57 54
         }
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
     /**
32 32
      * Returns an array of tokens this test wants to listen for.
33 33
      *
34
-     * @return array
34
+     * @return string[]
35 35
      */
36 36
     public function register()
37 37
     {
Please login to merge, or discard this patch.
PHPCompatibility/Sniffs/Lists/NewListReferenceAssignmentSniff.php 3 patches
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -25,43 +25,43 @@
 block discarded – undo
25 25
  */
26 26
 class NewListReferenceAssignmentSniff extends NewKeyedListSniff
27 27
 {
28
-    /**
29
-     * The token(s) within the list construct which is being targeted.
30
-     *
31
-     * @var array
32
-     */
33
-    protected $targetsInList = array(
34
-        \T_BITWISE_AND => \T_BITWISE_AND,
35
-    );
28
+	/**
29
+	 * The token(s) within the list construct which is being targeted.
30
+	 *
31
+	 * @var array
32
+	 */
33
+	protected $targetsInList = array(
34
+		\T_BITWISE_AND => \T_BITWISE_AND,
35
+	);
36 36
 
37
-    /**
38
-     * Do a version check to determine if this sniff needs to run at all.
39
-     *
40
-     * @return bool
41
-     */
42
-    protected function bowOutEarly()
43
-    {
44
-        return ($this->supportsBelow('7.2') === false);
45
-    }
37
+	/**
38
+	 * Do a version check to determine if this sniff needs to run at all.
39
+	 *
40
+	 * @return bool
41
+	 */
42
+	protected function bowOutEarly()
43
+	{
44
+		return ($this->supportsBelow('7.2') === false);
45
+	}
46 46
 
47
-    /**
48
-     * Examine the contents of a list construct to determine whether an error needs to be thrown.
49
-     *
50
-     * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
51
-     * @param int                   $opener    The position of the list open token.
52
-     * @param int                   $closer    The position of the list close token.
53
-     *
54
-     * @return void
55
-     */
56
-    protected function examineList(File $phpcsFile, $opener, $closer)
57
-    {
58
-        $start = $opener;
59
-        while (($start = $this->hasTargetInList($phpcsFile, $start, $closer)) !== false) {
60
-            $phpcsFile->addError(
61
-                'Reference assignments within list constructs are not supported in PHP 7.2 or earlier.',
62
-                $start,
63
-                'Found'
64
-            );
65
-        }
66
-    }
47
+	/**
48
+	 * Examine the contents of a list construct to determine whether an error needs to be thrown.
49
+	 *
50
+	 * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
51
+	 * @param int                   $opener    The position of the list open token.
52
+	 * @param int                   $closer    The position of the list close token.
53
+	 *
54
+	 * @return void
55
+	 */
56
+	protected function examineList(File $phpcsFile, $opener, $closer)
57
+	{
58
+		$start = $opener;
59
+		while (($start = $this->hasTargetInList($phpcsFile, $start, $closer)) !== false) {
60
+			$phpcsFile->addError(
61
+				'Reference assignments within list constructs are not supported in PHP 7.2 or earlier.',
62
+				$start,
63
+				'Found'
64
+			);
65
+		}
66
+	}
67 67
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
      */
42 42
     protected function bowOutEarly()
43 43
     {
44
-        return ($this->supportsBelow('7.2') === false);
44
+        return ( $this->supportsBelow( '7.2' ) === false );
45 45
     }
46 46
 
47 47
     /**
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
      *
54 54
      * @return void
55 55
      */
56
-    protected function examineList(File $phpcsFile, $opener, $closer)
56
+    protected function examineList( File $phpcsFile, $opener, $closer )
57 57
     {
58 58
         $start = $opener;
59
-        while (($start = $this->hasTargetInList($phpcsFile, $start, $closer)) !== false) {
59
+        while ( ( $start = $this->hasTargetInList( $phpcsFile, $start, $closer ) ) !== false ) {
60 60
             $phpcsFile->addError(
61 61
                 'Reference assignments within list constructs are not supported in PHP 7.2 or earlier.',
62 62
                 $start,
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -23,8 +23,7 @@  discard block
 block discarded – undo
23 23
  * @package  PHPCompatibility
24 24
  * @author   Juliette Reinders Folmer <[email protected]>
25 25
  */
26
-class NewListReferenceAssignmentSniff extends NewKeyedListSniff
27
-{
26
+class NewListReferenceAssignmentSniff extends NewKeyedListSniff {
28 27
     /**
29 28
      * The token(s) within the list construct which is being targeted.
30 29
      *
@@ -39,8 +38,7 @@  discard block
 block discarded – undo
39 38
      *
40 39
      * @return bool
41 40
      */
42
-    protected function bowOutEarly()
43
-    {
41
+    protected function bowOutEarly() {
44 42
         return ($this->supportsBelow('7.2') === false);
45 43
     }
46 44
 
@@ -53,8 +51,7 @@  discard block
 block discarded – undo
53 51
      *
54 52
      * @return void
55 53
      */
56
-    protected function examineList(File $phpcsFile, $opener, $closer)
57
-    {
54
+    protected function examineList(File $phpcsFile, $opener, $closer) {
58 55
         $start = $opener;
59 56
         while (($start = $this->hasTargetInList($phpcsFile, $start, $closer)) !== false) {
60 57
             $phpcsFile->addError(
Please login to merge, or discard this patch.
php-compatibility/PHPCompatibility/Sniffs/Lists/AssignmentOrderSniff.php 3 patches
Indentation   +131 added lines, -131 removed lines patch added patch discarded remove patch
@@ -30,154 +30,154 @@
 block discarded – undo
30 30
 class AssignmentOrderSniff extends Sniff
31 31
 {
32 32
 
33
-    /**
34
-     * Returns an array of tokens this test wants to listen for.
35
-     *
36
-     * @return array
37
-     */
38
-    public function register()
39
-    {
40
-        return array(
41
-            \T_LIST,
42
-            \T_OPEN_SHORT_ARRAY,
43
-        );
44
-    }
45
-
46
-
47
-    /**
48
-     * Processes this test, when one of its tokens is encountered.
49
-     *
50
-     * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
51
-     * @param int                   $stackPtr  The position of the current token in the
52
-     *                                         stack passed in $tokens.
53
-     *
54
-     * @return void|int Void if not a valid list. If a list construct has been
55
-     *                  examined, the stack pointer to the list closer to skip
56
-     *                  passed any nested lists which don't need to be examined again.
57
-     */
58
-    public function process(File $phpcsFile, $stackPtr)
59
-    {
60
-        if ($this->supportsAbove('7.0') === false) {
61
-            return;
62
-        }
63
-
64
-        $tokens = $phpcsFile->getTokens();
65
-
66
-        if ($tokens[$stackPtr]['code'] === \T_OPEN_SHORT_ARRAY
67
-            && $this->isShortList($phpcsFile, $stackPtr) === false
68
-        ) {
69
-            // Short array, not short list.
70
-            return;
71
-        }
72
-
73
-        if ($tokens[$stackPtr]['code'] === \T_LIST) {
74
-            $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
75
-            if ($nextNonEmpty === false
76
-                || $tokens[$nextNonEmpty]['code'] !== \T_OPEN_PARENTHESIS
77
-                || isset($tokens[$nextNonEmpty]['parenthesis_closer']) === false
78
-            ) {
79
-                // Parse error or live coding.
80
-                return;
81
-            }
82
-
83
-            $opener = $nextNonEmpty;
84
-            $closer = $tokens[$nextNonEmpty]['parenthesis_closer'];
85
-        } else {
86
-            // Short list syntax.
87
-            $opener = $stackPtr;
88
-
89
-            if (isset($tokens[$stackPtr]['bracket_closer'])) {
90
-                $closer = $tokens[$stackPtr]['bracket_closer'];
91
-            }
92
-        }
93
-
94
-        if (isset($opener, $closer) === false) {
95
-            return;
96
-        }
97
-
98
-        /*
33
+	/**
34
+	 * Returns an array of tokens this test wants to listen for.
35
+	 *
36
+	 * @return array
37
+	 */
38
+	public function register()
39
+	{
40
+		return array(
41
+			\T_LIST,
42
+			\T_OPEN_SHORT_ARRAY,
43
+		);
44
+	}
45
+
46
+
47
+	/**
48
+	 * Processes this test, when one of its tokens is encountered.
49
+	 *
50
+	 * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
51
+	 * @param int                   $stackPtr  The position of the current token in the
52
+	 *                                         stack passed in $tokens.
53
+	 *
54
+	 * @return void|int Void if not a valid list. If a list construct has been
55
+	 *                  examined, the stack pointer to the list closer to skip
56
+	 *                  passed any nested lists which don't need to be examined again.
57
+	 */
58
+	public function process(File $phpcsFile, $stackPtr)
59
+	{
60
+		if ($this->supportsAbove('7.0') === false) {
61
+			return;
62
+		}
63
+
64
+		$tokens = $phpcsFile->getTokens();
65
+
66
+		if ($tokens[$stackPtr]['code'] === \T_OPEN_SHORT_ARRAY
67
+			&& $this->isShortList($phpcsFile, $stackPtr) === false
68
+		) {
69
+			// Short array, not short list.
70
+			return;
71
+		}
72
+
73
+		if ($tokens[$stackPtr]['code'] === \T_LIST) {
74
+			$nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
75
+			if ($nextNonEmpty === false
76
+				|| $tokens[$nextNonEmpty]['code'] !== \T_OPEN_PARENTHESIS
77
+				|| isset($tokens[$nextNonEmpty]['parenthesis_closer']) === false
78
+			) {
79
+				// Parse error or live coding.
80
+				return;
81
+			}
82
+
83
+			$opener = $nextNonEmpty;
84
+			$closer = $tokens[$nextNonEmpty]['parenthesis_closer'];
85
+		} else {
86
+			// Short list syntax.
87
+			$opener = $stackPtr;
88
+
89
+			if (isset($tokens[$stackPtr]['bracket_closer'])) {
90
+				$closer = $tokens[$stackPtr]['bracket_closer'];
91
+			}
92
+		}
93
+
94
+		if (isset($opener, $closer) === false) {
95
+			return;
96
+		}
97
+
98
+		/*
99 99
          * OK, so we have the opener & closer, now we need to check all the variables in the
100 100
          * list() to see if there are duplicates as that's the problem.
101 101
          */
102
-        $hasVars = $phpcsFile->findNext(array(\T_VARIABLE, \T_DOLLAR), ($opener + 1), $closer);
103
-        if ($hasVars === false) {
104
-            // Empty list, not our concern.
105
-            return ($closer + 1);
106
-        }
107
-
108
-        // Set the variable delimiters based on the list type being examined.
109
-        $stopPoints = array(\T_COMMA);
110
-        if ($tokens[$stackPtr]['code'] === \T_OPEN_SHORT_ARRAY) {
111
-            $stopPoints[] = \T_CLOSE_SHORT_ARRAY;
112
-        } else {
113
-            $stopPoints[] = \T_CLOSE_PARENTHESIS;
114
-        }
115
-
116
-        $listVars      = array();
117
-        $lastStopPoint = $opener;
118
-
119
-        /*
102
+		$hasVars = $phpcsFile->findNext(array(\T_VARIABLE, \T_DOLLAR), ($opener + 1), $closer);
103
+		if ($hasVars === false) {
104
+			// Empty list, not our concern.
105
+			return ($closer + 1);
106
+		}
107
+
108
+		// Set the variable delimiters based on the list type being examined.
109
+		$stopPoints = array(\T_COMMA);
110
+		if ($tokens[$stackPtr]['code'] === \T_OPEN_SHORT_ARRAY) {
111
+			$stopPoints[] = \T_CLOSE_SHORT_ARRAY;
112
+		} else {
113
+			$stopPoints[] = \T_CLOSE_PARENTHESIS;
114
+		}
115
+
116
+		$listVars      = array();
117
+		$lastStopPoint = $opener;
118
+
119
+		/*
120 120
          * Create a list of all variables used within the `list()` construct.
121 121
          * We're not concerned with whether these are nested or not, as any duplicate
122 122
          * variable name used will be problematic, independent of nesting.
123 123
          */
124
-        do {
125
-            $nextStopPoint = $phpcsFile->findNext($stopPoints, ($lastStopPoint + 1), $closer);
126
-            if ($nextStopPoint === false) {
127
-                $nextStopPoint = $closer;
128
-            }
129
-
130
-            // Also detect this in PHP 7.1 keyed lists.
131
-            $hasDoubleArrow = $phpcsFile->findNext(\T_DOUBLE_ARROW, ($lastStopPoint + 1), $nextStopPoint);
132
-            if ($hasDoubleArrow !== false) {
133
-                $lastStopPoint = $hasDoubleArrow;
134
-            }
135
-
136
-            // Find the start of the variable, allowing for variable variables.
137
-            $nextStartPoint = $phpcsFile->findNext(array(\T_VARIABLE, \T_DOLLAR), ($lastStopPoint + 1), $nextStopPoint);
138
-            if ($nextStartPoint === false) {
139
-                // Skip past empty bits in the list, i.e. `list( $a, , ,)`.
140
-                $lastStopPoint = $nextStopPoint;
141
-                continue;
142
-            }
143
-
144
-            /*
124
+		do {
125
+			$nextStopPoint = $phpcsFile->findNext($stopPoints, ($lastStopPoint + 1), $closer);
126
+			if ($nextStopPoint === false) {
127
+				$nextStopPoint = $closer;
128
+			}
129
+
130
+			// Also detect this in PHP 7.1 keyed lists.
131
+			$hasDoubleArrow = $phpcsFile->findNext(\T_DOUBLE_ARROW, ($lastStopPoint + 1), $nextStopPoint);
132
+			if ($hasDoubleArrow !== false) {
133
+				$lastStopPoint = $hasDoubleArrow;
134
+			}
135
+
136
+			// Find the start of the variable, allowing for variable variables.
137
+			$nextStartPoint = $phpcsFile->findNext(array(\T_VARIABLE, \T_DOLLAR), ($lastStopPoint + 1), $nextStopPoint);
138
+			if ($nextStartPoint === false) {
139
+				// Skip past empty bits in the list, i.e. `list( $a, , ,)`.
140
+				$lastStopPoint = $nextStopPoint;
141
+				continue;
142
+			}
143
+
144
+			/*
145 145
              * Gather the content of all non-empty tokens to determine the "variable name".
146 146
              * Variable name in this context includes array or object property syntaxes, such
147 147
              * as `$a['name']` and `$b->property`.
148 148
              */
149
-            $varContent = '';
149
+			$varContent = '';
150 150
 
151
-            for ($i = $nextStartPoint; $i < $nextStopPoint; $i++) {
152
-                if (isset(Tokens::$emptyTokens[$tokens[$i]['code']])) {
153
-                    continue;
154
-                }
151
+			for ($i = $nextStartPoint; $i < $nextStopPoint; $i++) {
152
+				if (isset(Tokens::$emptyTokens[$tokens[$i]['code']])) {
153
+					continue;
154
+				}
155 155
 
156
-                $varContent .= $tokens[$i]['content'];
157
-            }
156
+				$varContent .= $tokens[$i]['content'];
157
+			}
158 158
 
159
-            if ($varContent !== '') {
160
-                $listVars[] = $varContent;
161
-            }
159
+			if ($varContent !== '') {
160
+				$listVars[] = $varContent;
161
+			}
162 162
 
163
-            $lastStopPoint = $nextStopPoint;
163
+			$lastStopPoint = $nextStopPoint;
164 164
 
165
-        } while ($lastStopPoint < $closer);
165
+		} while ($lastStopPoint < $closer);
166 166
 
167
-        if (empty($listVars)) {
168
-            // Shouldn't be possible, but just in case.
169
-            return ($closer + 1);
170
-        }
167
+		if (empty($listVars)) {
168
+			// Shouldn't be possible, but just in case.
169
+			return ($closer + 1);
170
+		}
171 171
 
172
-        // Verify that all variables used in the list() construct are unique.
173
-        if (\count($listVars) !== \count(array_unique($listVars))) {
174
-            $phpcsFile->addError(
175
-                'list() will assign variable from left-to-right since PHP 7.0. Ensure all variables in list() are unique to prevent unexpected results.',
176
-                $stackPtr,
177
-                'Affected'
178
-            );
179
-        }
172
+		// Verify that all variables used in the list() construct are unique.
173
+		if (\count($listVars) !== \count(array_unique($listVars))) {
174
+			$phpcsFile->addError(
175
+				'list() will assign variable from left-to-right since PHP 7.0. Ensure all variables in list() are unique to prevent unexpected results.',
176
+				$stackPtr,
177
+				'Affected'
178
+			);
179
+		}
180 180
 
181
-        return ($closer + 1);
182
-    }
181
+		return ($closer + 1);
182
+	}
183 183
 }
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -55,43 +55,43 @@  discard block
 block discarded – undo
55 55
      *                  examined, the stack pointer to the list closer to skip
56 56
      *                  passed any nested lists which don't need to be examined again.
57 57
      */
58
-    public function process(File $phpcsFile, $stackPtr)
58
+    public function process( File $phpcsFile, $stackPtr )
59 59
     {
60
-        if ($this->supportsAbove('7.0') === false) {
60
+        if ( $this->supportsAbove( '7.0' ) === false ) {
61 61
             return;
62 62
         }
63 63
 
64 64
         $tokens = $phpcsFile->getTokens();
65 65
 
66
-        if ($tokens[$stackPtr]['code'] === \T_OPEN_SHORT_ARRAY
67
-            && $this->isShortList($phpcsFile, $stackPtr) === false
66
+        if ( $tokens[ $stackPtr ][ 'code' ] === \T_OPEN_SHORT_ARRAY
67
+            && $this->isShortList( $phpcsFile, $stackPtr ) === false
68 68
         ) {
69 69
             // Short array, not short list.
70 70
             return;
71 71
         }
72 72
 
73
-        if ($tokens[$stackPtr]['code'] === \T_LIST) {
74
-            $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
75
-            if ($nextNonEmpty === false
76
-                || $tokens[$nextNonEmpty]['code'] !== \T_OPEN_PARENTHESIS
77
-                || isset($tokens[$nextNonEmpty]['parenthesis_closer']) === false
73
+        if ( $tokens[ $stackPtr ][ 'code' ] === \T_LIST ) {
74
+            $nextNonEmpty = $phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true );
75
+            if ( $nextNonEmpty === false
76
+                || $tokens[ $nextNonEmpty ][ 'code' ] !== \T_OPEN_PARENTHESIS
77
+                || isset( $tokens[ $nextNonEmpty ][ 'parenthesis_closer' ] ) === false
78 78
             ) {
79 79
                 // Parse error or live coding.
80 80
                 return;
81 81
             }
82 82
 
83 83
             $opener = $nextNonEmpty;
84
-            $closer = $tokens[$nextNonEmpty]['parenthesis_closer'];
84
+            $closer = $tokens[ $nextNonEmpty ][ 'parenthesis_closer' ];
85 85
         } else {
86 86
             // Short list syntax.
87 87
             $opener = $stackPtr;
88 88
 
89
-            if (isset($tokens[$stackPtr]['bracket_closer'])) {
90
-                $closer = $tokens[$stackPtr]['bracket_closer'];
89
+            if ( isset( $tokens[ $stackPtr ][ 'bracket_closer' ] ) ) {
90
+                $closer = $tokens[ $stackPtr ][ 'bracket_closer' ];
91 91
             }
92 92
         }
93 93
 
94
-        if (isset($opener, $closer) === false) {
94
+        if ( isset( $opener, $closer ) === false ) {
95 95
             return;
96 96
         }
97 97
 
@@ -99,18 +99,18 @@  discard block
 block discarded – undo
99 99
          * OK, so we have the opener & closer, now we need to check all the variables in the
100 100
          * list() to see if there are duplicates as that's the problem.
101 101
          */
102
-        $hasVars = $phpcsFile->findNext(array(\T_VARIABLE, \T_DOLLAR), ($opener + 1), $closer);
103
-        if ($hasVars === false) {
102
+        $hasVars = $phpcsFile->findNext( array( \T_VARIABLE, \T_DOLLAR ), ( $opener + 1 ), $closer );
103
+        if ( $hasVars === false ) {
104 104
             // Empty list, not our concern.
105
-            return ($closer + 1);
105
+            return ( $closer + 1 );
106 106
         }
107 107
 
108 108
         // Set the variable delimiters based on the list type being examined.
109
-        $stopPoints = array(\T_COMMA);
110
-        if ($tokens[$stackPtr]['code'] === \T_OPEN_SHORT_ARRAY) {
111
-            $stopPoints[] = \T_CLOSE_SHORT_ARRAY;
109
+        $stopPoints = array( \T_COMMA );
110
+        if ( $tokens[ $stackPtr ][ 'code' ] === \T_OPEN_SHORT_ARRAY ) {
111
+            $stopPoints[ ] = \T_CLOSE_SHORT_ARRAY;
112 112
         } else {
113
-            $stopPoints[] = \T_CLOSE_PARENTHESIS;
113
+            $stopPoints[ ] = \T_CLOSE_PARENTHESIS;
114 114
         }
115 115
 
116 116
         $listVars      = array();
@@ -122,20 +122,20 @@  discard block
 block discarded – undo
122 122
          * variable name used will be problematic, independent of nesting.
123 123
          */
124 124
         do {
125
-            $nextStopPoint = $phpcsFile->findNext($stopPoints, ($lastStopPoint + 1), $closer);
126
-            if ($nextStopPoint === false) {
125
+            $nextStopPoint = $phpcsFile->findNext( $stopPoints, ( $lastStopPoint + 1 ), $closer );
126
+            if ( $nextStopPoint === false ) {
127 127
                 $nextStopPoint = $closer;
128 128
             }
129 129
 
130 130
             // Also detect this in PHP 7.1 keyed lists.
131
-            $hasDoubleArrow = $phpcsFile->findNext(\T_DOUBLE_ARROW, ($lastStopPoint + 1), $nextStopPoint);
132
-            if ($hasDoubleArrow !== false) {
131
+            $hasDoubleArrow = $phpcsFile->findNext( \T_DOUBLE_ARROW, ( $lastStopPoint + 1 ), $nextStopPoint );
132
+            if ( $hasDoubleArrow !== false ) {
133 133
                 $lastStopPoint = $hasDoubleArrow;
134 134
             }
135 135
 
136 136
             // Find the start of the variable, allowing for variable variables.
137
-            $nextStartPoint = $phpcsFile->findNext(array(\T_VARIABLE, \T_DOLLAR), ($lastStopPoint + 1), $nextStopPoint);
138
-            if ($nextStartPoint === false) {
137
+            $nextStartPoint = $phpcsFile->findNext( array( \T_VARIABLE, \T_DOLLAR ), ( $lastStopPoint + 1 ), $nextStopPoint );
138
+            if ( $nextStartPoint === false ) {
139 139
                 // Skip past empty bits in the list, i.e. `list( $a, , ,)`.
140 140
                 $lastStopPoint = $nextStopPoint;
141 141
                 continue;
@@ -148,29 +148,29 @@  discard block
 block discarded – undo
148 148
              */
149 149
             $varContent = '';
150 150
 
151
-            for ($i = $nextStartPoint; $i < $nextStopPoint; $i++) {
152
-                if (isset(Tokens::$emptyTokens[$tokens[$i]['code']])) {
151
+            for ( $i = $nextStartPoint; $i < $nextStopPoint; $i++ ) {
152
+                if ( isset( Tokens::$emptyTokens[ $tokens[ $i ][ 'code' ] ] ) ) {
153 153
                     continue;
154 154
                 }
155 155
 
156
-                $varContent .= $tokens[$i]['content'];
156
+                $varContent .= $tokens[ $i ][ 'content' ];
157 157
             }
158 158
 
159
-            if ($varContent !== '') {
160
-                $listVars[] = $varContent;
159
+            if ( $varContent !== '' ) {
160
+                $listVars[ ] = $varContent;
161 161
             }
162 162
 
163 163
             $lastStopPoint = $nextStopPoint;
164 164
 
165
-        } while ($lastStopPoint < $closer);
165
+        } while ( $lastStopPoint < $closer );
166 166
 
167
-        if (empty($listVars)) {
167
+        if ( empty( $listVars ) ) {
168 168
             // Shouldn't be possible, but just in case.
169
-            return ($closer + 1);
169
+            return ( $closer + 1 );
170 170
         }
171 171
 
172 172
         // Verify that all variables used in the list() construct are unique.
173
-        if (\count($listVars) !== \count(array_unique($listVars))) {
173
+        if ( \count( $listVars ) !== \count( array_unique( $listVars ) ) ) {
174 174
             $phpcsFile->addError(
175 175
                 'list() will assign variable from left-to-right since PHP 7.0. Ensure all variables in list() are unique to prevent unexpected results.',
176 176
                 $stackPtr,
@@ -178,6 +178,6 @@  discard block
 block discarded – undo
178 178
             );
179 179
         }
180 180
 
181
-        return ($closer + 1);
181
+        return ( $closer + 1 );
182 182
     }
183 183
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -27,16 +27,14 @@  discard block
 block discarded – undo
27 27
  * @package  PHPCompatibility
28 28
  * @author   Juliette Reinders Folmer <[email protected]>
29 29
  */
30
-class AssignmentOrderSniff extends Sniff
31
-{
30
+class AssignmentOrderSniff extends Sniff {
32 31
 
33 32
     /**
34 33
      * Returns an array of tokens this test wants to listen for.
35 34
      *
36 35
      * @return array
37 36
      */
38
-    public function register()
39
-    {
37
+    public function register() {
40 38
         return array(
41 39
             \T_LIST,
42 40
             \T_OPEN_SHORT_ARRAY,
@@ -55,8 +53,7 @@  discard block
 block discarded – undo
55 53
      *                  examined, the stack pointer to the list closer to skip
56 54
      *                  passed any nested lists which don't need to be examined again.
57 55
      */
58
-    public function process(File $phpcsFile, $stackPtr)
59
-    {
56
+    public function process(File $phpcsFile, $stackPtr) {
60 57
         if ($this->supportsAbove('7.0') === false) {
61 58
             return;
62 59
         }
Please login to merge, or discard this patch.
PHPCompatibility/Sniffs/Syntax/NewDynamicAccessToStaticSniff.php 4 patches
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -30,56 +30,56 @@
 block discarded – undo
30 30
 class NewDynamicAccessToStaticSniff extends Sniff
31 31
 {
32 32
 
33
-    /**
34
-     * Returns an array of tokens this test wants to listen for.
35
-     *
36
-     * @return array
37
-     */
38
-    public function register()
39
-    {
40
-        return array(
41
-            \T_DOUBLE_COLON,
42
-        );
43
-    }
33
+	/**
34
+	 * Returns an array of tokens this test wants to listen for.
35
+	 *
36
+	 * @return array
37
+	 */
38
+	public function register()
39
+	{
40
+		return array(
41
+			\T_DOUBLE_COLON,
42
+		);
43
+	}
44 44
 
45
-    /**
46
-     * Processes this test, when one of its tokens is encountered.
47
-     *
48
-     * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
49
-     * @param int                   $stackPtr  The position of the current token in the
50
-     *                                         stack passed in $tokens.
51
-     *
52
-     * @return void
53
-     */
54
-    public function process(File $phpcsFile, $stackPtr)
55
-    {
56
-        if ($this->supportsBelow('5.2') === false) {
57
-            return;
58
-        }
45
+	/**
46
+	 * Processes this test, when one of its tokens is encountered.
47
+	 *
48
+	 * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
49
+	 * @param int                   $stackPtr  The position of the current token in the
50
+	 *                                         stack passed in $tokens.
51
+	 *
52
+	 * @return void
53
+	 */
54
+	public function process(File $phpcsFile, $stackPtr)
55
+	{
56
+		if ($this->supportsBelow('5.2') === false) {
57
+			return;
58
+		}
59 59
 
60
-        $tokens       = $phpcsFile->getTokens();
61
-        $prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
60
+		$tokens       = $phpcsFile->getTokens();
61
+		$prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
62 62
 
63
-        // Disregard `static::` as well. Late static binding is reported by another sniff.
64
-        if ($tokens[$prevNonEmpty]['code'] === \T_SELF
65
-            || $tokens[$prevNonEmpty]['code'] === \T_PARENT
66
-            || $tokens[$prevNonEmpty]['code'] === \T_STATIC
67
-        ) {
68
-            return;
69
-        }
63
+		// Disregard `static::` as well. Late static binding is reported by another sniff.
64
+		if ($tokens[$prevNonEmpty]['code'] === \T_SELF
65
+			|| $tokens[$prevNonEmpty]['code'] === \T_PARENT
66
+			|| $tokens[$prevNonEmpty]['code'] === \T_STATIC
67
+		) {
68
+			return;
69
+		}
70 70
 
71
-        if ($tokens[$prevNonEmpty]['code'] === \T_STRING) {
72
-            $prevPrevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($prevNonEmpty - 1), null, true);
71
+		if ($tokens[$prevNonEmpty]['code'] === \T_STRING) {
72
+			$prevPrevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($prevNonEmpty - 1), null, true);
73 73
 
74
-            if ($tokens[$prevPrevNonEmpty]['code'] !== \T_OBJECT_OPERATOR) {
75
-                return;
76
-            }
77
-        }
74
+			if ($tokens[$prevPrevNonEmpty]['code'] !== \T_OBJECT_OPERATOR) {
75
+				return;
76
+			}
77
+		}
78 78
 
79
-        $phpcsFile->addError(
80
-            'Static class properties and methods, as well as class constants, could not be accessed using a dynamic (variable) classname in PHP 5.2 or earlier.',
81
-            $stackPtr,
82
-            'Found'
83
-        );
84
-    }
79
+		$phpcsFile->addError(
80
+			'Static class properties and methods, as well as class constants, could not be accessed using a dynamic (variable) classname in PHP 5.2 or earlier.',
81
+			$stackPtr,
82
+			'Found'
83
+		);
84
+	}
85 85
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -51,27 +51,27 @@
 block discarded – undo
51 51
      *
52 52
      * @return void
53 53
      */
54
-    public function process(File $phpcsFile, $stackPtr)
54
+    public function process( File $phpcsFile, $stackPtr )
55 55
     {
56
-        if ($this->supportsBelow('5.2') === false) {
56
+        if ( $this->supportsBelow( '5.2' ) === false ) {
57 57
             return;
58 58
         }
59 59
 
60 60
         $tokens       = $phpcsFile->getTokens();
61
-        $prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
61
+        $prevNonEmpty = $phpcsFile->findPrevious( Tokens::$emptyTokens, ( $stackPtr - 1 ), null, true );
62 62
 
63 63
         // Disregard `static::` as well. Late static binding is reported by another sniff.
64
-        if ($tokens[$prevNonEmpty]['code'] === \T_SELF
65
-            || $tokens[$prevNonEmpty]['code'] === \T_PARENT
66
-            || $tokens[$prevNonEmpty]['code'] === \T_STATIC
64
+        if ( $tokens[ $prevNonEmpty ][ 'code' ] === \T_SELF
65
+            || $tokens[ $prevNonEmpty ][ 'code' ] === \T_PARENT
66
+            || $tokens[ $prevNonEmpty ][ 'code' ] === \T_STATIC
67 67
         ) {
68 68
             return;
69 69
         }
70 70
 
71
-        if ($tokens[$prevNonEmpty]['code'] === \T_STRING) {
72
-            $prevPrevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($prevNonEmpty - 1), null, true);
71
+        if ( $tokens[ $prevNonEmpty ][ 'code' ] === \T_STRING ) {
72
+            $prevPrevNonEmpty = $phpcsFile->findPrevious( Tokens::$emptyTokens, ( $prevNonEmpty - 1 ), null, true );
73 73
 
74
-            if ($tokens[$prevPrevNonEmpty]['code'] !== \T_OBJECT_OPERATOR) {
74
+            if ( $tokens[ $prevPrevNonEmpty ][ 'code' ] !== \T_OBJECT_OPERATOR ) {
75 75
                 return;
76 76
             }
77 77
         }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -27,16 +27,14 @@  discard block
 block discarded – undo
27 27
  * @package  PHPCompatibility
28 28
  * @author   Juliette Reinders Folmer <[email protected]>
29 29
  */
30
-class NewDynamicAccessToStaticSniff extends Sniff
31
-{
30
+class NewDynamicAccessToStaticSniff extends Sniff {
32 31
 
33 32
     /**
34 33
      * Returns an array of tokens this test wants to listen for.
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
         );
@@ -51,8 +49,7 @@  discard block
 block discarded – undo
51 49
      *
52 50
      * @return void
53 51
      */
54
-    public function process(File $phpcsFile, $stackPtr)
55
-    {
52
+    public function process(File $phpcsFile, $stackPtr) {
56 53
         if ($this->supportsBelow('5.2') === false) {
57 54
             return;
58 55
         }
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.
php-compatibility/PHPCompatibility/Sniffs/Syntax/NewShortArraySniff.php 4 patches
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -28,47 +28,47 @@
 block discarded – undo
28 28
 class NewShortArraySniff extends Sniff
29 29
 {
30 30
 
31
-    /**
32
-     * Returns an array of tokens this test wants to listen for.
33
-     *
34
-     * @return array
35
-     */
36
-    public function register()
37
-    {
38
-        return array(
39
-            \T_OPEN_SHORT_ARRAY,
40
-            \T_CLOSE_SHORT_ARRAY,
41
-        );
42
-    }
31
+	/**
32
+	 * Returns an array of tokens this test wants to listen for.
33
+	 *
34
+	 * @return array
35
+	 */
36
+	public function register()
37
+	{
38
+		return array(
39
+			\T_OPEN_SHORT_ARRAY,
40
+			\T_CLOSE_SHORT_ARRAY,
41
+		);
42
+	}
43 43
 
44 44
 
45
-    /**
46
-     * Processes this test, when one of its tokens is encountered.
47
-     *
48
-     * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
49
-     * @param int                   $stackPtr  The position of the current token in
50
-     *                                         the stack passed in $tokens.
51
-     *
52
-     * @return void
53
-     */
54
-    public function process(File $phpcsFile, $stackPtr)
55
-    {
56
-        if ($this->supportsBelow('5.3') === false) {
57
-            return;
58
-        }
45
+	/**
46
+	 * Processes this test, when one of its tokens is encountered.
47
+	 *
48
+	 * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
49
+	 * @param int                   $stackPtr  The position of the current token in
50
+	 *                                         the stack passed in $tokens.
51
+	 *
52
+	 * @return void
53
+	 */
54
+	public function process(File $phpcsFile, $stackPtr)
55
+	{
56
+		if ($this->supportsBelow('5.3') === false) {
57
+			return;
58
+		}
59 59
 
60
-        $tokens = $phpcsFile->getTokens();
61
-        $token  = $tokens[$stackPtr];
60
+		$tokens = $phpcsFile->getTokens();
61
+		$token  = $tokens[$stackPtr];
62 62
 
63
-        $error = '%s is available since 5.4';
64
-        $data  = array();
63
+		$error = '%s is available since 5.4';
64
+		$data  = array();
65 65
 
66
-        if ($token['type'] === 'T_OPEN_SHORT_ARRAY') {
67
-            $data[] = 'Short array syntax (open)';
68
-        } elseif ($token['type'] === 'T_CLOSE_SHORT_ARRAY') {
69
-            $data[] = 'Short array syntax (close)';
70
-        }
66
+		if ($token['type'] === 'T_OPEN_SHORT_ARRAY') {
67
+			$data[] = 'Short array syntax (open)';
68
+		} elseif ($token['type'] === 'T_CLOSE_SHORT_ARRAY') {
69
+			$data[] = 'Short array syntax (close)';
70
+		}
71 71
 
72
-        $phpcsFile->addError($error, $stackPtr, 'Found', $data);
73
-    }
72
+		$phpcsFile->addError($error, $stackPtr, 'Found', $data);
73
+	}
74 74
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -51,24 +51,24 @@
 block discarded – undo
51 51
      *
52 52
      * @return void
53 53
      */
54
-    public function process(File $phpcsFile, $stackPtr)
54
+    public function process( File $phpcsFile, $stackPtr )
55 55
     {
56
-        if ($this->supportsBelow('5.3') === false) {
56
+        if ( $this->supportsBelow( '5.3' ) === false ) {
57 57
             return;
58 58
         }
59 59
 
60 60
         $tokens = $phpcsFile->getTokens();
61
-        $token  = $tokens[$stackPtr];
61
+        $token  = $tokens[ $stackPtr ];
62 62
 
63 63
         $error = '%s is available since 5.4';
64 64
         $data  = array();
65 65
 
66
-        if ($token['type'] === 'T_OPEN_SHORT_ARRAY') {
67
-            $data[] = 'Short array syntax (open)';
68
-        } elseif ($token['type'] === 'T_CLOSE_SHORT_ARRAY') {
69
-            $data[] = 'Short array syntax (close)';
66
+        if ( $token[ 'type' ] === 'T_OPEN_SHORT_ARRAY' ) {
67
+            $data[ ] = 'Short array syntax (open)';
68
+        } elseif ( $token[ 'type' ] === 'T_CLOSE_SHORT_ARRAY' ) {
69
+            $data[ ] = 'Short array syntax (close)';
70 70
         }
71 71
 
72
-        $phpcsFile->addError($error, $stackPtr, 'Found', $data);
72
+        $phpcsFile->addError( $error, $stackPtr, 'Found', $data );
73 73
     }
74 74
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -25,16 +25,14 @@  discard block
 block discarded – undo
25 25
  * @package  PHPCompatibility
26 26
  * @author   Alex Miroshnikov <[email protected]>
27 27
  */
28
-class NewShortArraySniff extends Sniff
29
-{
28
+class NewShortArraySniff extends Sniff {
30 29
 
31 30
     /**
32 31
      * Returns an array of tokens this test wants to listen for.
33 32
      *
34 33
      * @return array
35 34
      */
36
-    public function register()
37
-    {
35
+    public function register() {
38 36
         return array(
39 37
             \T_OPEN_SHORT_ARRAY,
40 38
             \T_CLOSE_SHORT_ARRAY,
@@ -51,8 +49,7 @@  discard block
 block discarded – undo
51 49
      *
52 50
      * @return void
53 51
      */
54
-    public function process(File $phpcsFile, $stackPtr)
55
-    {
52
+    public function process(File $phpcsFile, $stackPtr) {
56 53
         if ($this->supportsBelow('5.3') === false) {
57 54
             return;
58 55
         }
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
     /**
32 32
      * Returns an array of tokens this test wants to listen for.
33 33
      *
34
-     * @return array
34
+     * @return string[]
35 35
      */
36 36
     public function register()
37 37
     {
Please login to merge, or discard this patch.