@@ -63,16 +63,19 @@ public function fix(\SplFileInfo $file, Tokens $tokens): void
6363 return ;
6464 }
6565
66- if ($ tokens [$ nextIndex ]->isGivenKind ([T_PRIVATE , T_PROTECTED , T_PUBLIC , T_VAR , T_STATIC ])) {
66+ /** @var Token $nextToken */
67+ $ nextToken = $ tokens [$ nextIndex ];
68+
69+ if ($ nextToken ->isGivenKind ([T_PRIVATE , T_PROTECTED , T_PUBLIC , T_VAR , T_STATIC ])) {
6770 continue ;
6871 }
6972
70- if ($ tokens [ $ nextIndex ] ->isGivenKind (T_VARIABLE )) {
71- $ this ->removeVarAnnotation ($ tokens , $ index , [$ tokens [ $ nextIndex ] ->getContent ()]);
73+ if ($ nextToken ->isGivenKind (T_VARIABLE )) {
74+ $ this ->removeVarAnnotation ($ tokens , $ index , [$ nextToken ->getContent ()]);
7275 continue ;
7376 }
7477
75- if ($ tokens [ $ nextIndex ] ->isGivenKind ([T_FOR , T_FOREACH , T_IF , T_SWITCH , T_WHILE ])) {
78+ if ($ nextToken ->isGivenKind ([T_FOR , T_FOREACH , T_IF , T_SWITCH , T_WHILE ])) {
7679 $ this ->removeVarAnnotationForControl ($ tokens , $ index , $ nextIndex );
7780 continue ;
7881 }
@@ -108,6 +111,7 @@ private function removeVarAnnotationForControl(Tokens $tokens, int $commentIndex
108111 $ variables = [];
109112
110113 for ($ index = $ index + 1 ; $ index < $ endIndex ; $ index ++) {
114+ /** @var Token $token */
111115 $ token = $ tokens [$ index ];
112116
113117 if ($ token ->isGivenKind (T_VARIABLE )) {
@@ -120,7 +124,10 @@ private function removeVarAnnotationForControl(Tokens $tokens, int $commentIndex
120124
121125 private function removeVarAnnotationNotMatchingPattern (Tokens $ tokens , int $ index , ?string $ pattern ): void
122126 {
123- $ doc = new DocBlock ($ tokens [$ index ]->getContent ());
127+ /** @var Token $token */
128+ $ token = $ tokens [$ index ];
129+
130+ $ doc = new DocBlock ($ token ->getContent ());
124131
125132 foreach ($ doc ->getAnnotationsOfType (['var ' ]) as $ annotation ) {
126133 if ($ pattern === null || Preg::match ($ pattern , $ annotation ->getContent ()) !== 1 ) {
@@ -130,7 +137,7 @@ private function removeVarAnnotationNotMatchingPattern(Tokens $tokens, int $inde
130137
131138 $ content = $ doc ->getContent ();
132139
133- if ($ content === $ tokens [ $ index ] ->getContent ()) {
140+ if ($ content === $ token ->getContent ()) {
134141 return ;
135142 }
136143
0 commit comments