3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Vite { protected $buildDirectory; public function useBuildDirectory($path) { $this->buildDirectory = $path; } public function __invoke($entry, $buildDirectory = 'default') { return func_get_args()[1] ?? $this->buildDirectory ?? 'default'; } } $vite = new Vite(); var_dump([ 'expect' => 'default', 'recieved' => $vite([]) ]); var_dump([ 'expect' => 'foo', 'recieved' => $vite([], 'foo') ]); $vite->useBuildDirectory('custom'); var_dump([ 'expect' => 'custom', 'recieved' => $vite([]) ]); var_dump([ 'expect' => 'foo', 'recieved' => $vite([], 'foo') ]);
Output for 7.4.0 - 7.4.33, 8.0.1 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.32, 8.3.0 - 8.3.32, 8.4.1 - 8.4.23, 8.5.0 - 8.5.8
array(2) { ["expect"]=> string(7) "default" ["recieved"]=> string(7) "default" } array(2) { ["expect"]=> string(3) "foo" ["recieved"]=> string(3) "foo" } array(2) { ["expect"]=> string(6) "custom" ["recieved"]=> string(6) "custom" } array(2) { ["expect"]=> string(3) "foo" ["recieved"]=> string(3) "foo" }

preferences:
99.07 ms | 1344 KiB | 4 Q