@@ -91,11 +91,11 @@ public function testConvertLongSimpleTypeHintToShort(string $long, string $short
9191 $ this ->assertSame ($ short , TypeHintHelper::convertLongSimpleTypeHintToShort ($ long ));
9292 }
9393
94- public function testFunctionAnnotationTypeHintWithNamespace ()
94+ public function testFunctionReturnAnnotationWithNamespace ()
9595 {
9696 $ codeSnifferFile = $ this ->getCodeSnifferFile (__DIR__ . '/data/typeHintWithNamespace.php ' );
9797
98- $ functionPointer = $ this ->findFunctionPointerByName ($ codeSnifferFile , 'fooFunctionWithAnnotation ' );
98+ $ functionPointer = $ this ->findFunctionPointerByName ($ codeSnifferFile , 'fooFunctionWithReturnAnnotation ' );
9999 $ returnAnnotation = FunctionHelper::findReturnAnnotation ($ codeSnifferFile , $ functionPointer );
100100 $ this ->assertSame ('void ' , TypeHintHelper::getFullyQualifiedTypeHint ($ codeSnifferFile , $ functionPointer , $ returnAnnotation ->getContent ()));
101101 }
@@ -109,11 +109,30 @@ public function testFunctionReturnTypeHintWithNamespace()
109109 $ this ->assertSame ('\FooNamespace\FooClass ' , TypeHintHelper::getFullyQualifiedTypeHint ($ codeSnifferFile , $ functionPointer , $ returnTypeHint ->getTypeHint ()));
110110 }
111111
112- public function testMethodAnnotationTypeHintWithNamespace ()
112+ public function testFunctionParameterAnnotationWithNamespace ()
113113 {
114114 $ codeSnifferFile = $ this ->getCodeSnifferFile (__DIR__ . '/data/typeHintWithNamespace.php ' );
115115
116- $ methodPointer = $ this ->findFunctionPointerByName ($ codeSnifferFile , 'fooMethodWithAnnotation ' );
116+ $ functionPointer = $ this ->findFunctionPointerByName ($ codeSnifferFile , 'fooFunctionWithParameterAnnotation ' );
117+ $ parameterAnnotation = FunctionHelper::getParametersAnnotations ($ codeSnifferFile , $ functionPointer )[0 ];
118+ $ parameterTypeHint = preg_split ('~ \\s+~ ' , $ parameterAnnotation ->getContent ())[0 ];
119+ $ this ->assertSame ('\Doctrine\Common\Collections\ArrayCollection ' , TypeHintHelper::getFullyQualifiedTypeHint ($ codeSnifferFile , $ functionPointer , $ parameterTypeHint ));
120+ }
121+
122+ public function testFunctionParameterTypeHintWithNamespace ()
123+ {
124+ $ codeSnifferFile = $ this ->getCodeSnifferFile (__DIR__ . '/data/typeHintWithNamespace.php ' );
125+
126+ $ functionPointer = $ this ->findFunctionPointerByName ($ codeSnifferFile , 'fooFunctionWithParameterTypeHint ' );
127+ $ parameterTypeHint = FunctionHelper::getParametersTypeHints ($ codeSnifferFile , $ functionPointer )['$parameter ' ];
128+ $ this ->assertSame ('\Doctrine\Common\Collections\ArrayCollection ' , TypeHintHelper::getFullyQualifiedTypeHint ($ codeSnifferFile , $ functionPointer , $ parameterTypeHint ->getTypeHint ()));
129+ }
130+
131+ public function testMethodReturnAnnotationWithNamespace ()
132+ {
133+ $ codeSnifferFile = $ this ->getCodeSnifferFile (__DIR__ . '/data/typeHintWithNamespace.php ' );
134+
135+ $ methodPointer = $ this ->findFunctionPointerByName ($ codeSnifferFile , 'fooMethodWithReturnAnnotation ' );
117136 $ returnAnnotation = FunctionHelper::findReturnAnnotation ($ codeSnifferFile , $ methodPointer );
118137 $ this ->assertSame ('\FooNamespace\FooClass ' , TypeHintHelper::getFullyQualifiedTypeHint ($ codeSnifferFile , $ methodPointer , $ returnAnnotation ->getContent ()));
119138 }
@@ -127,11 +146,30 @@ public function testMethodReturnTypeHintWithNamespace()
127146 $ this ->assertSame ('bool ' , TypeHintHelper::getFullyQualifiedTypeHint ($ codeSnifferFile , $ methodPointer , $ returnTypeHint ->getTypeHint ()));
128147 }
129148
130- public function testFunctionAnnotationTypeHintWithoutNamespace ()
149+ public function testMethodParameterAnnotationWithNamespace ()
150+ {
151+ $ codeSnifferFile = $ this ->getCodeSnifferFile (__DIR__ . '/data/typeHintWithNamespace.php ' );
152+
153+ $ methodPointer = $ this ->findFunctionPointerByName ($ codeSnifferFile , 'fooMethodWithParameterAnnotation ' );
154+ $ parameterAnnotation = FunctionHelper::getParametersAnnotations ($ codeSnifferFile , $ methodPointer )[0 ];
155+ $ parameterTypeHint = preg_split ('~ \\s+~ ' , $ parameterAnnotation ->getContent ())[0 ];
156+ $ this ->assertSame ('\Doctrine\ORM\Mapping\Id ' , TypeHintHelper::getFullyQualifiedTypeHint ($ codeSnifferFile , $ methodPointer , $ parameterTypeHint ));
157+ }
158+
159+ public function testMethodParameterTypeHintWithNamespace ()
160+ {
161+ $ codeSnifferFile = $ this ->getCodeSnifferFile (__DIR__ . '/data/typeHintWithNamespace.php ' );
162+
163+ $ methodPointer = $ this ->findFunctionPointerByName ($ codeSnifferFile , 'fooMethodWithParameterTypeHint ' );
164+ $ parameterTypeHint = FunctionHelper::getParametersTypeHints ($ codeSnifferFile , $ methodPointer )['$parameter ' ];
165+ $ this ->assertSame ('\Doctrine\ORM\Mapping\Id ' , TypeHintHelper::getFullyQualifiedTypeHint ($ codeSnifferFile , $ methodPointer , $ parameterTypeHint ->getTypeHint ()));
166+ }
167+
168+ public function testFunctionReturnAnnotationWithoutNamespace ()
131169 {
132170 $ codeSnifferFile = $ this ->getCodeSnifferFile (__DIR__ . '/data/typeHintWithoutNamespace.php ' );
133171
134- $ functionPointer = $ this ->findFunctionPointerByName ($ codeSnifferFile , 'fooFunctionWithAnnotation ' );
172+ $ functionPointer = $ this ->findFunctionPointerByName ($ codeSnifferFile , 'fooFunctionWithReturnAnnotation ' );
135173 $ returnAnnotation = FunctionHelper::findReturnAnnotation ($ codeSnifferFile , $ functionPointer );
136174 $ this ->assertSame ('void ' , TypeHintHelper::getFullyQualifiedTypeHint ($ codeSnifferFile , $ functionPointer , $ returnAnnotation ->getContent ()));
137175 }
@@ -145,11 +183,30 @@ public function testFunctionReturnTypeHintWithoutNamespace()
145183 $ this ->assertSame ('\FooClass ' , TypeHintHelper::getFullyQualifiedTypeHint ($ codeSnifferFile , $ functionPointer , $ returnTypeHint ->getTypeHint ()));
146184 }
147185
148- public function testMethodAnnotationTypeHintWithoutNamespace ()
186+ public function testFunctionParameterAnnotationWithoutNamespace ()
149187 {
150188 $ codeSnifferFile = $ this ->getCodeSnifferFile (__DIR__ . '/data/typeHintWithoutNamespace.php ' );
151189
152- $ methodPointer = $ this ->findFunctionPointerByName ($ codeSnifferFile , 'fooMethodWithAnnotation ' );
190+ $ functionPointer = $ this ->findFunctionPointerByName ($ codeSnifferFile , 'fooFunctionWithParameterAnnotation ' );
191+ $ parameterAnnotation = FunctionHelper::getParametersAnnotations ($ codeSnifferFile , $ functionPointer )[0 ];
192+ $ parameterTypeHint = preg_split ('~ \\s+~ ' , $ parameterAnnotation ->getContent ())[0 ];
193+ $ this ->assertSame ('\Doctrine\Common\Collections\ArrayCollection ' , TypeHintHelper::getFullyQualifiedTypeHint ($ codeSnifferFile , $ functionPointer , $ parameterTypeHint ));
194+ }
195+
196+ public function testFunctionParameterTypeHintWithoutNamespace ()
197+ {
198+ $ codeSnifferFile = $ this ->getCodeSnifferFile (__DIR__ . '/data/typeHintWithoutNamespace.php ' );
199+
200+ $ functionPointer = $ this ->findFunctionPointerByName ($ codeSnifferFile , 'fooFunctionWithParameterTypeHint ' );
201+ $ parameterTypeHint = FunctionHelper::getParametersTypeHints ($ codeSnifferFile , $ functionPointer )['$parameter ' ];
202+ $ this ->assertSame ('\Doctrine\Common\Collections\ArrayCollection ' , TypeHintHelper::getFullyQualifiedTypeHint ($ codeSnifferFile , $ functionPointer , $ parameterTypeHint ->getTypeHint ()));
203+ }
204+
205+ public function testMethodReturnAnnotationWithoutNamespace ()
206+ {
207+ $ codeSnifferFile = $ this ->getCodeSnifferFile (__DIR__ . '/data/typeHintWithoutNamespace.php ' );
208+
209+ $ methodPointer = $ this ->findFunctionPointerByName ($ codeSnifferFile , 'fooMethodWithReturnAnnotation ' );
153210 $ returnAnnotation = FunctionHelper::findReturnAnnotation ($ codeSnifferFile , $ methodPointer );
154211 $ this ->assertSame ('\FooClass ' , TypeHintHelper::getFullyQualifiedTypeHint ($ codeSnifferFile , $ methodPointer , $ returnAnnotation ->getContent ()));
155212 }
@@ -163,4 +220,23 @@ public function testMethodReturnTypeHintWithoutNamespace()
163220 $ this ->assertSame ('bool ' , TypeHintHelper::getFullyQualifiedTypeHint ($ codeSnifferFile , $ methodPointer , $ returnTypeHint ->getTypeHint ()));
164221 }
165222
223+ public function testMethodParameterAnnotationWithoutNamespace ()
224+ {
225+ $ codeSnifferFile = $ this ->getCodeSnifferFile (__DIR__ . '/data/typeHintWithoutNamespace.php ' );
226+
227+ $ methodPointer = $ this ->findFunctionPointerByName ($ codeSnifferFile , 'fooMethodWithParameterAnnotation ' );
228+ $ parameterAnnotation = FunctionHelper::getParametersAnnotations ($ codeSnifferFile , $ methodPointer )[0 ];
229+ $ parameterTypeHint = preg_split ('~ \\s+~ ' , $ parameterAnnotation ->getContent ())[0 ];
230+ $ this ->assertSame ('\Doctrine\ORM\Mapping\Id ' , TypeHintHelper::getFullyQualifiedTypeHint ($ codeSnifferFile , $ methodPointer , $ parameterTypeHint ));
231+ }
232+
233+ public function testMethodParameterTypeHintWithoutNamespace ()
234+ {
235+ $ codeSnifferFile = $ this ->getCodeSnifferFile (__DIR__ . '/data/typeHintWithoutNamespace.php ' );
236+
237+ $ methodPointer = $ this ->findFunctionPointerByName ($ codeSnifferFile , 'fooMethodWithParameterTypeHint ' );
238+ $ parameterTypeHint = FunctionHelper::getParametersTypeHints ($ codeSnifferFile , $ methodPointer )['$parameter ' ];
239+ $ this ->assertSame ('\Doctrine\ORM\Mapping\Id ' , TypeHintHelper::getFullyQualifiedTypeHint ($ codeSnifferFile , $ methodPointer , $ parameterTypeHint ->getTypeHint ()));
240+ }
241+
166242}
0 commit comments