1--TEST-- 2ReflectionNamedType::getName() and ReflectionNamedType::__toString() 3--FILE-- 4<?php 5 6function testInternalTypes(?Traversable $traversable): ?string { 7 return 'test'; 8} 9 10function testUserDefinedTypes(?Test $traversable): ?Test { 11 return new Test; 12} 13 14$function = new ReflectionFunction('testInternalTypes'); 15$type = $function->getParameters()[0]->getType(); 16$return = $function->getReturnType(); 17 18var_dump($type->getName()); 19var_dump((string) $type); 20var_dump($return->getName()); 21var_dump((string) $return); 22 23$function = new ReflectionFunction('testUserDefinedTypes'); 24$type = $function->getParameters()[0]->getType(); 25$return = $function->getReturnType(); 26 27var_dump($type->getName()); 28var_dump((string) $type); 29var_dump($return->getName()); 30var_dump((string) $return); 31 32?> 33--EXPECTF-- 34string(11) "Traversable" 35 36Deprecated: Function ReflectionType::__toString() is deprecated in %s on line %d 37string(11) "Traversable" 38string(6) "string" 39 40Deprecated: Function ReflectionType::__toString() is deprecated in %s on line %d 41string(6) "string" 42string(4) "Test" 43 44Deprecated: Function ReflectionType::__toString() is deprecated in %s on line %d 45string(4) "Test" 46string(4) "Test" 47 48Deprecated: Function ReflectionType::__toString() is deprecated in %s on line %d 49string(4) "Test" 50