22
33/**
44 * Test: Nette\DI\PhpReflection::getReturnType
5- * @phpversion >= 7
5+ * @phpversion 7
66 */
77
88namespace NS
@@ -14,22 +14,34 @@ namespace NS
1414 function noType ()
1515 {}
1616
17+ function classType (): B
18+ {}
19+
20+ function nativeType (): string
21+ {}
22+
23+ function selfType (): self
24+ {}
25+
1726 /** @return B */
18- function annotationSingle ()
27+ function annotationClassType ()
1928 {}
2029
2130 /** @return B|string */
22- function annotationComplex ()
31+ function annotationUnionType ()
2332 {}
2433
25- function nativeType (): string
34+ /** @return String */
35+ function annotationNativeType ()
2636 {}
2737
28- function selfType (): self
38+ /** @return self */
39+ function annotationSelfType ()
2940 {}
3041 }
3142
32- function classType (): B
43+ /** @return B */
44+ function annotationClassType ()
3345 {}
3446}
3547
@@ -44,14 +56,20 @@ namespace
4456
4557 Assert::null (PhpReflection::getReturnType (new \ReflectionMethod (NS \A::class, 'noType ' )));
4658
47- Assert::same ('Test\B ' , PhpReflection::getReturnType (new \ReflectionMethod (NS \A::class, 'annotationSingle ' )));
48-
49- Assert::same ('Test\B ' , PhpReflection::getReturnType (new \ReflectionMethod (NS \A::class, 'annotationComplex ' )));
59+ Assert::same ('Test\B ' , PhpReflection::getReturnType (new \ReflectionMethod (NS \A::class, 'classType ' )));
5060
5161 Assert::same ('string ' , PhpReflection::getReturnType (new \ReflectionMethod (NS \A::class, 'nativeType ' )));
5262
5363 Assert::same ('NS\A ' , PhpReflection::getReturnType (new \ReflectionMethod (NS \A::class, 'selfType ' )));
5464
65+ Assert::same ('Test\B ' , PhpReflection::getReturnType (new \ReflectionMethod (NS \A::class, 'annotationClassType ' )));
66+
67+ Assert::same ('Test\B ' , PhpReflection::getReturnType (new \ReflectionMethod (NS \A::class, 'annotationUnionType ' )));
68+
69+ Assert::same ('string ' , PhpReflection::getReturnType (new \ReflectionMethod (NS \A::class, 'annotationNativeType ' )));
70+
71+ Assert::same ('NS\A ' , PhpReflection::getReturnType (new \ReflectionMethod (NS \A::class, 'annotationSelfType ' )));
72+
5573 // class name expanding is NOT supported for global functions
56- Assert::same ('Test\ B ' , PhpReflection::getReturnType (new \ReflectionFunction (NS \classType::class )));
74+ Assert::same ('B ' , PhpReflection::getReturnType (new \ReflectionFunction (' NS\annotationClassType ' )));
5775}
0 commit comments