3v4l.org

run code in 300+ PHP versions simultaneously
<?php enum x:string { case a = 'foo'; } var_dump(x::tryFrom(123)); enum y:int { case a = 123; } var_dump(y::tryFrom('foo'));
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
NULL Fatal error: Uncaught TypeError: y::tryFrom(): Argument #1 ($value) must be of type int, string given in /in/54qFs:13 Stack trace: #0 /in/54qFs(13): y::tryFrom('foo') #1 {main} thrown in /in/54qFs on line 13
Process exited with code 255.

preferences:
154.28 ms | 1400 KiB | 62 Q