Completed
Pull Request — master (#120)
by
unknown
01:23
created
src/Codor/Sniffs/TypeHints/MixedReturnTypeSniff.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
      */
18 18
     public function register(): array
19 19
     {
20
-        return [T_FUNCTION];
20
+        return [ T_FUNCTION ];
21 21
     }
22 22
 
23 23
     /**
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 
36 36
         $commentEnd = $this->findCommentEnd($phpcsFile, $stackPtr, $tokens);
37 37
 
38
-        $commentStart = $tokens[$commentEnd]['comment_opener'];
38
+        $commentStart = $tokens[ $commentEnd ][ 'comment_opener' ];
39 39
 
40 40
         $this->processReturn($phpcsFile, $commentStart);
41 41
     }
@@ -82,8 +82,8 @@  discard block
 block discarded – undo
82 82
      */
83 83
     private function findReturnTag(array $tokens, int $commentStart): ?int
84 84
     {
85
-        return array_reduce($tokens[$commentStart]['comment_tags'], function ($carry, $tag) use ($tokens) {
86
-            return $carry || ($tokens[$tag]['content'] === self::RETURN_TAG_NAME) ? $tag : null;
85
+        return array_reduce($tokens[ $commentStart ][ 'comment_tags' ], function($carry, $tag) use ($tokens) {
86
+            return $carry || ($tokens[ $tag ][ 'content' ] === self::RETURN_TAG_NAME) ? $tag : null;
87 87
         }, null);
88 88
     }
89 89
 
@@ -95,11 +95,11 @@  discard block
 block discarded – undo
95 95
      */
96 96
     private function parseTagForReturnType(array $tokens, int $returnPosition): ?string
97 97
     {
98
-        $content = $tokens[$returnPosition + 2]['content'];
98
+        $content = $tokens[ $returnPosition + 2 ][ 'content' ];
99 99
         // Support both a return type and a description.
100 100
         preg_match('`^((?:\|?(?:array\([^\)]*\)|[\\\\a-z0-9\[\]]+))*)( .*)?`i', $content, $returnParts);
101 101
 
102
-        return $returnParts[1] ?? null;
102
+        return $returnParts[ 1 ] ?? null;
103 103
     }
104 104
 
105 105
     /**
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
         $find = PHP_CodeSniffer_Tokens::$methodPrefixes + T_WHITESPACE;
116 116
 
117 117
         $commentEnd = $phpcsFile->findPrevious($find, $stackPtr - 1, null, true);
118
-        if ($tokens[$commentEnd]['code'] !== T_COMMENT) {
118
+        if ($tokens[ $commentEnd ][ 'code' ] !== T_COMMENT) {
119 119
             return $commentEnd;
120 120
         }
121 121
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
         // using the wrong comment type. If there is other code on the line,
125 125
         // assume they relate to that code.
126 126
         $prev = $phpcsFile->findPrevious($find, $commentEnd - 1, null, true);
127
-        if ($prev !== false && $tokens[$prev]['line'] === $tokens[$commentEnd]['line']) {
127
+        if ($prev !== false && $tokens[ $prev ][ 'line' ] === $tokens[ $commentEnd ][ 'line' ]) {
128 128
             $commentEnd = $prev;
129 129
         }
130 130
 
Please login to merge, or discard this patch.