3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types = 1); /** * @template-covariant T */ final class Collection { /** * @param list<T> $items */ public function __construct( private array $items = [], ) { } /** * @template TValue * @param Closure(T, int): TValue $callback * @return Collection<TValue> */ public function map(Closure $callback): self { $mapped = []; foreach ($this->items as $key => $item) { $mapped[] = $callback($item, $key); } return new self($mapped); } } enum X: string { case CASE1 = 'case1'; case CASE2 = 'case2'; } (new Collection(['case1']))->map(X::from(...));
Output for 8.1.30 - 8.1.33, 8.2.5 - 8.2.29, 8.3.5 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0
Fatal error: Uncaught ArgumentCountError: X::from() expects exactly 1 argument, 2 given in /in/YWSEo:25 Stack trace: #0 /in/YWSEo(25): X::from('case1', 0) #1 /in/YWSEo(37): Collection->map(Object(Closure)) #2 {main} thrown in /in/YWSEo on line 25
Process exited with code 255.
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.

preferences:
89.96 ms | 407 KiB | 5 Q