3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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 { $args_format = rtrim(str_repeat('\'%s\', ', func_num_args()), ', '); $args_formatted = sprintf($args_format, ...func_get_args()); return sprintf("%s(%s)", __METHOD__, $args_formatted); } public function hydrateWithContext($incoming, $model, $context = null) : string { return $this->hydrate($incoming, $model, $context); } } $hydrator = new PlsContextHydrator(); var_dump( $hydrator->hydrate('nah', 'maybes', 'whatever') );
based on 71v8s
Output for 7.0.0 - 7.2.0
string(56) "PlsContextHydrator::hydrate('nah', 'maybes', 'whatever')"
Output for 5.4.0 - 5.6.28
Warning: Unsupported declare 'strict_types' in /in/mYjX6 on line 2 Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/mYjX6 on line 6
Process exited with code 255.