<?php interface RequestInterface{} class Request implements RequestInterface {} interface Promise{} class PromiseImpl implements Promise {} interface Plugin { public function handleRequest(RequestInterface $request, callable $next, callable $first); } trait ForwardCompatibilityPlugin { abstract function doHandleRequest(RequestInterface $request, callable $next, callable $first); public function handleRequest(RequestInterface $request, callable $next, callable $first) { return $this->doHandleRequest($request, $next, $first); } } class MyPlugin implements Plugin { use ForwardCompatibilityPlugin; /** * {@inheritdoc} */ protected function doHandleRequest(RequestInterface $request, callable $next, callable $first) { echo "foobar\n"; return $next($request); } } $request = new Request(); $callable = function() { echo "callable\n"; return new PromiseImpl(); }; $plugin = new MyPlugin(); $plugin->handleRequest($request, $callable, $callable);
You have javascript disabled. You will not be able to edit any code.