3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @return non-empty-list<non-empty-string> */ function valueTypes(mixed $value): array { if (is_object($value)) { return [ $value::class, ...array_values(class_parents($value)), ...array_values(class_implements($value)), ]; } return [get_debug_type($value)]; } interface I1 {} interface I2 {} abstract class A implements I1 {} final class B extends A implements I2 {} var_dump(valueTypes(1)); var_dump(valueTypes('string')); var_dump(valueTypes(new B()));
Output for git.master, git.master_jit, rfc.property-hooks
array(1) { [0]=> string(3) "int" } array(1) { [0]=> string(6) "string" } array(4) { [0]=> string(1) "B" [1]=> string(1) "A" [2]=> string(2) "I1" [3]=> string(2) "I2" }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
26.34 ms | 405 KiB | 5 Q