@@ -50,11 +50,9 @@ class TokenHelper
5050 */
5151 public static function findNext (\PHP_CodeSniffer_File $ phpcsFile , $ types , int $ startPointer , int $ endPointer = null )
5252 {
53+ /** @var int|false $token */
5354 $ token = $ phpcsFile ->findNext ($ types , $ startPointer , $ endPointer , false );
54- if ($ token === false ) {
55- return null ;
56- }
57- return $ token ;
55+ return $ token === false ? null : $ token ;
5856 }
5957
6058 /**
@@ -67,11 +65,9 @@ public static function findNext(\PHP_CodeSniffer_File $phpcsFile, $types, int $s
6765 */
6866 public static function findNextContent (\PHP_CodeSniffer_File $ phpcsFile , $ types , string $ content , int $ startPointer , int $ endPointer = null )
6967 {
68+ /** @var int|false $token */
7069 $ token = $ phpcsFile ->findNext ($ types , $ startPointer , $ endPointer , false , $ content );
71- if ($ token === false ) {
72- return null ;
73- }
74- return $ token ;
70+ return $ token === false ? null : $ token ;
7571 }
7672
7773 /**
@@ -94,11 +90,9 @@ public static function findNextEffective(\PHP_CodeSniffer_File $phpcsFile, int $
9490 */
9591 public static function findNextExcluding (\PHP_CodeSniffer_File $ phpcsFile , $ types , int $ startPointer , int $ endPointer = null )
9692 {
93+ /** @var int|false $token */
9794 $ token = $ phpcsFile ->findNext ($ types , $ startPointer , $ endPointer , true );
98- if ($ token === false ) {
99- return null ;
100- }
101- return $ token ;
95+ return $ token === false ? null : $ token ;
10296 }
10397
10498 /**
@@ -110,11 +104,9 @@ public static function findNextExcluding(\PHP_CodeSniffer_File $phpcsFile, $type
110104 */
111105 public static function findNextLocal (\PHP_CodeSniffer_File $ phpcsFile , $ types , int $ startPointer , int $ endPointer = null )
112106 {
107+ /** @var int|false $token */
113108 $ token = $ phpcsFile ->findNext ($ types , $ startPointer , $ endPointer , false , null , true );
114- if ($ token === false ) {
115- return null ;
116- }
117- return $ token ;
109+ return $ token === false ? null : $ token ;
118110 }
119111
120112 /**
@@ -126,11 +118,9 @@ public static function findNextLocal(\PHP_CodeSniffer_File $phpcsFile, $types, i
126118 */
127119 public static function findNextLocalExcluding (\PHP_CodeSniffer_File $ phpcsFile , $ types , int $ startPointer , int $ endPointer = null )
128120 {
121+ /** @var int|false $token */
129122 $ token = $ phpcsFile ->findNext ($ types , $ startPointer , $ endPointer , true , null , true );
130- if ($ token === false ) {
131- return null ;
132- }
133- return $ token ;
123+ return $ token === false ? null : $ token ;
134124 }
135125
136126 /**
@@ -153,11 +143,9 @@ public static function findNextAnyToken(\PHP_CodeSniffer_File $phpcsFile, int $s
153143 */
154144 public static function findPrevious (\PHP_CodeSniffer_File $ phpcsFile , $ types , int $ startPointer , int $ endPointer = null )
155145 {
146+ /** @var int|false $token */
156147 $ token = $ phpcsFile ->findPrevious ($ types , $ startPointer , $ endPointer , false );
157- if ($ token === false ) {
158- return null ;
159- }
160- return $ token ;
148+ return $ token === false ? null : $ token ;
161149 }
162150
163151 /**
@@ -180,11 +168,9 @@ public static function findPreviousEffective(\PHP_CodeSniffer_File $phpcsFile, i
180168 */
181169 public static function findPreviousExcluding (\PHP_CodeSniffer_File $ phpcsFile , $ types , int $ startPointer , int $ endPointer = null )
182170 {
171+ /** @var int|false $token */
183172 $ token = $ phpcsFile ->findPrevious ($ types , $ startPointer , $ endPointer , true );
184- if ($ token === false ) {
185- return null ;
186- }
187- return $ token ;
173+ return $ token === false ? null : $ token ;
188174 }
189175
190176 /**
0 commit comments