Closed thekid closed 1 year ago
Could be implemented by a) emitting this as a trait method, b) including this trait in the class:
interface Value {
public function toString();
public function compareTo($value);
}
trait __Value_Defaults {
public function compareTo($value) {
return $this <=> $value;
}
}
class Listing implements Value {
use __Value_Defaults;
public function toString() {
// Needs to be implemented
}
public function compareTo($value) {
// Can be implemented
}
}
...and c) changing the reflection API to suppress "magic" classes starting with __
.
There's now a PR for this @ https://github.com/php/php-src/pull/11467
Discussion on PHP internals mailing list @ https://externals.io/message/120582
RFC has been declined
Can we support the features shown in https://wiki.php.net/rfc/interface-default-methods?
Test cases can be found here: https://github.com/php/php-src/compare/master...morrisonlevi:php-src:interface-default-methods