3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Foo { class Bar { }; } namespace { use Foo\Bar; class_alias(Bar::class, 'FooBar'); class FooBar {}; class GuineaPig { public function withNamespace(Bar $bar) { echo sprintf("Passing %s worked with %s\n", get_class($bar), __METHOD__); } public function withoutNamespace(FooBar $bar) { echo sprintf("Passing %s worked with %s\n", get_class($bar), __METHOD__); } } $bar = new Bar(); $foobar = new FooBar(); $pig = new GuineaPig(); $pig->withNamespace($bar); $pig->withoutNamespace($foobar); $pig->withNamespace($foobar); $pig->withoutNamespace($bar); }

preferences:
26.95 ms | 406 KiB | 5 Q