<?php
//file testWorks.php
interface IStringable1 {
public function toString();
}
class MyTestWorks1 implements IStringable1 {
public function toString($a = '', $b = NULL) {
echo "My Test is instantiated", PHP_EOL;
}
}
$obj = new MyTestWorks1();
$obj->toString();
//file testBroken.php
interface IStringable2
{
public function toString();
}
trait TStringable2
{
public function toString($a = '', $b = NULL) {
echo "My Test is instantiated", PHP_EOL;
}
}
class MyTestWorks2 implements IStringable2{
use TStringable2;
}
$obj = new MyTestWorks2();
$obj->toString();
My Test is instantiated
Fatal error: Declaration of TStringable2::toString($a = '', $b = NULL) must be compatible with IStringable2::toString() in /in/42bbB on line 28
Process exited with code 255.