@ 2015-09-15T21:44:14Z <?php
declare(strict_types=1);
interface Hydrator
{
public function hydrate($incoming, $model) : string;
}
interface ContextualHydratorExtension extends Hydrator
{
public function hydrate($incoming, $model, $context = null) : string;
}
interface ContextualHydrator
{
public function hydrateWithContext($incoming, $model, $context = null) : string;
}
class PlsContextHydrator implements Hydrator, ContextualHydratorExtension, ContextualHydrator
{
public function hydrate($incoming, $model, $context = null) : string
{
return sprintf("%s('%s')", __METHOD__, implode(', ', func_get_args()));
}
public function hydrateWithContext($incoming, $model, $context = null) : string
{
return $this->hydrate($incoming, $model, $context);
}
}
$hydrator = new PlsContextHydrator();
var_dump(
$hydrator->hydrate('nah', 'maybes', 'whatever')
);
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 7.0.0 - 7.0.20 , 7.1.0 - 7.1.25 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.6 string(52) "PlsContextHydrator::hydrate('nah, maybes, whatever')"
Output for 5.4.0 - 5.4.45 , 5.5.24 - 5.5.35 , 5.6.8 - 5.6.28 Warning: Unsupported declare 'strict_types' in /in/71v8s on line 2
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/71v8s on line 6
Process exited with code 255 . preferences:dark mode live preview
205.61 ms | 402 KiB | 243 Q