3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php trait Adder { public function calculate(int $x, int $y) { return $x + $y; } } trait Subtractor { public function calculate(int $x, int $y) { return $x - $y; } } class StupidCalc { use Adder { calculate as public add; } use Subtractor { calculate as public sub; } function maybeAdd(int $x, int $y) { return $this->add($x, $y); } function maybeSub(int $x, int $y) { return $this->sub($x, $y); } } $calc = new StupidCalc(); echo $calc->maybeAdd(3, 2); echo $calc->maybeSub(3, 2);