@@ -230,32 +230,25 @@ private function fixFunctionDocComment($content, Tokens $tokens, $functionIndex,
230230
231231 /**
232232 * @param string $content
233- * @param int $docCommentIndex
233+ * @param int $index Index of the DocComment token
234234 *
235235 * @return string
236236 */
237- private function fixPropertyDocComment ($ content , Tokens $ tokens , $ docCommentIndex , array $ shortNames )
237+ private function fixPropertyDocComment ($ content , Tokens $ tokens , $ index , array $ shortNames )
238238 {
239239 $ docBlock = new DocBlock ($ content );
240240
241- $ index = $ tokens ->getNextMeaningfulToken ($ docCommentIndex );
242-
243- $ kindsBeforeProperty = [T_STATIC , T_PRIVATE , T_PROTECTED , T_PUBLIC ];
244-
245- if (!$ tokens [$ index ]->isGivenKind ($ kindsBeforeProperty )) {
246- return $ content ;
247- }
248-
249241 do {
250242 $ index = $ tokens ->getNextMeaningfulToken ($ index );
243+ } while ($ tokens [$ index ]->isGivenKind ([T_STATIC , T_PRIVATE , T_PROTECTED , T_PUBLIC ]));
251244
252- $ propertyTypeInfo = $ this ->parseTypeHint ($ tokens , $ index );
253- foreach ( $ docBlock -> getAnnotationsOfType ( ' var ' ) as $ annotation ) {
254- if ( $ this -> annotationIsSuperfluous ( $ annotation , $ propertyTypeInfo , $ shortNames ) ) {
255- $ annotation -> remove ();
256- }
245+ $ propertyTypeInfo = $ this ->getPropertyTypeInfo ($ tokens , $ index );
246+
247+ foreach ( $ docBlock -> getAnnotationsOfType ( ' var ' ) as $ annotation ) {
248+ if ( $ this -> annotationIsSuperfluous ( $ annotation , $ propertyTypeInfo , $ shortNames )) {
249+ $ annotation -> remove ();
257250 }
258- } while ( $ tokens [ $ index ]-> isGivenKind ( $ kindsBeforeProperty ));
251+ }
259252
260253 return $ docBlock ->getContent ();
261254 }
@@ -318,6 +311,23 @@ private function getReturnTypeInfo(Tokens $tokens, $closingParenthesisIndex)
318311 ];
319312 }
320313
314+ /**
315+ * @param int $index The index of the first token of the type hint
316+ *
317+ * @return array
318+ */
319+ private function getPropertyTypeInfo (Tokens $ tokens , $ index )
320+ {
321+ if ($ tokens [$ index ]->isGivenKind (T_VARIABLE )) {
322+ return [
323+ 'type ' => null ,
324+ 'allows_null ' => true ,
325+ ];
326+ }
327+
328+ return $ this ->parseTypeHint ($ tokens , $ index );
329+ }
330+
321331 /**
322332 * @param int $index The index of the first token of the type hint
323333 *
0 commit comments