1--TEST-- 2Reflecting object return type 3--FILE-- 4<?php 5 6interface One { 7 public function a() : object; 8} 9 10class Two implements One { 11 public function a() : object {} 12} 13 14function a() : object {} 15 16$returnTypeOne = (new ReflectionClass(One::class))->getMethod('a')->getReturnType(); 17var_dump($returnTypeOne->isBuiltin(), $returnTypeOne->getName()); 18 19$returnTypeTwo = (new ReflectionClass(Two::class))->getMethod('a')->getReturnType(); 20var_dump($returnTypeTwo->isBuiltin(), $returnTypeTwo->getName()); 21 22$returnTypea = (new ReflectionFunction('a'))->getReturnType(); 23var_dump($returnTypea->isBuiltin(), $returnTypea->getName()); 24?> 25--EXPECT-- 26bool(true) 27string(6) "object" 28bool(true) 29string(6) "object" 30bool(true) 31string(6) "object" 32