1--TEST-- 2Stringable is automatically implemented 3--FILE-- 4<?php 5 6class Test { 7 public function __toString() { 8 return "foo"; 9 } 10} 11 12var_dump(new Test instanceof Stringable); 13var_dump((new ReflectionClass(Test::class))->getInterfaceNames()); 14 15class Test2 extends Test { 16 public function __toString() { 17 return "bar"; 18 } 19} 20 21var_dump(new Test2 instanceof Stringable); 22var_dump((new ReflectionClass(Test2::class))->getInterfaceNames()); 23 24?> 25--EXPECT-- 26bool(true) 27array(1) { 28 [0]=> 29 string(10) "Stringable" 30} 31bool(true) 32array(1) { 33 [0]=> 34 string(10) "Stringable" 35} 36