php-src/Zend/tests/stringable_trait_invalid.phpt
Nikita Popov d478ae73b1 Don't implement Stringable on traits
Traits do not support interfaces, so we should not implement
Stringable on them.

Also check the __toString() return type in the same way other
magic methods do, otherwise we would now miss the check in the
trait case.
2021-11-05 09:42:58 +01:00

15 lines
257 B
PHP

--TEST--
__toString() from trait with invalid return type
--FILE--
<?php
trait T {
public function __toString(): int {
return "ok";
}
}
?>
--EXPECTF--
Fatal error: T::__toString(): Return type must be string when declared in %s on line %d