3v4l.org

run code in 500+ PHP versions simultaneously
<?php enum MyEnum : int { case MyEnumCase1 = 1; } $value = MyEnum::MyEnumCase1; // A valid value. try { MyEnum::tryFrom($value); echo 'tryFrom() succeeded'."\n"; } catch (Throwable $exception) { echo 'tryFrom() failed'."\n"; echo $exception::class, ': ', $exception->getMessage(), "\n"; } /* tryFrom() failed TypeError: MyEnum::tryFrom(): Argument #1 ($value) must be of type int, MyEnum given */
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 8
Branch analysis from position: 8
2 jumps found. (Code = 107) Position 1 = 9, Position 2 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6TAmh
function name:  (null)
number of ops:  18
compiled vars:  !0 = $value, !1 = $exception
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                                'myenum'
    7     1        FETCH_CLASS_CONSTANT                                 ~2      'MyEnum', 'MyEnumCase1'
          2        ASSIGN                                                       !0, ~2
    9     3        INIT_STATIC_METHOD_CALL                                      'MyEnum', 'tryFrom'
          4        SEND_VAR_EX                                                  !0
          5        DO_FCALL                                          0          
   10     6        ECHO                                                         'tryFrom%28%29+succeeded%0A'
          7      > JMP                                                          ->17
   11     8  E > > CATCH                                           last         'Throwable'
   12     9    >   ECHO                                                         'tryFrom%28%29+failed%0A'
   13    10        FETCH_CLASS_NAME                                     ~5      !1
         11        ECHO                                                         ~5
         12        ECHO                                                         '%3A+'
         13        INIT_METHOD_CALL                                             !1, 'getMessage'
         14        DO_FCALL                                          0  $6      
         15        ECHO                                                         $6
         16        ECHO                                                         '%0A'
   19    17    > > RETURN                                                       1

Class MyEnum: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
126.66 ms | 474 KiB | 7 Q