diff options
Diffstat (limited to 'Zend/tests/stringable_automatic_implementation.phpt')
-rw-r--r-- | Zend/tests/stringable_automatic_implementation.phpt | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Zend/tests/stringable_automatic_implementation.phpt b/Zend/tests/stringable_automatic_implementation.phpt new file mode 100644 index 0000000000..5c45c03acb --- /dev/null +++ b/Zend/tests/stringable_automatic_implementation.phpt @@ -0,0 +1,35 @@ +--TEST-- +Stringable is automatically implemented +--FILE-- +<?php + +class Test { + public function __toString() { + return "foo"; + } +} + +var_dump(new Test instanceof Stringable); +var_dump((new ReflectionClass(Test::class))->getInterfaceNames()); + +class Test2 extends Test { + public function __toString() { + return "bar"; + } +} + +var_dump(new Test2 instanceof Stringable); +var_dump((new ReflectionClass(Test2::class))->getInterfaceNames()); + +?> +--EXPECT-- +bool(true) +array(1) { + [0]=> + string(10) "Stringable" +} +bool(true) +array(1) { + [0]=> + string(10) "Stringable" +} |