3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); /** * @template T */ class Example { /** @param T $inner */ public function __construct(public mixed $inner) { } /** * @return T */ public function get(): mixed { return $this->inner; } /** * @template U * @param callable(T): U $callback * @return U */ public function map(callable $callback): mixed { return $callback($this->inner); } /** * @template U * @param callable(T): U $callback * @return Example<U> */ public function chainMap(callable $callback): Example { return new self($callback($this->inner)); } } $example = new Example(123); // phpstorm understands this as int|mixed $value = $example->get(); // phpstorm understands this as int|mixed $value = $example->map(fn (int $val): string => (string) $val); function requiresInt(int $input) { } // phpstorm still sees this more crazy one as int|mixed.. $value = $example->chainMap(fn ($val) => (string) $val) ->chainMap(fn ($val) => new Example($val)) ->chainMap(fn ($val) => new Example($val)) ->chainMap(fn ($val) => $val->get()->get()) ->get(); // but psalm understands // psalm: InvalidScalarArgument: Argument 1 of requiresInt expects int, "123" provided requiresInt($value);
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught TypeError: requiresInt(): Argument #1 ($input) must be of type int, string given, called in /in/FlDJZ on line 60 and defined in /in/FlDJZ:48 Stack trace: #0 /in/FlDJZ(60): requiresInt('123') #1 {main} thrown in /in/FlDJZ on line 48
Process exited with code 255.

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:
85.9 ms | 405 KiB | 5 Q