3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait DeserializableEnum { public static function from($value) { return self::{$value}; } public static function tryFrom($value) { try { return self::from($value); } catch (Throwable) { return null; } } } enum Foo { use DeserializableEnum; case one; } var_dump( Foo::from("one"), Foo::tryFrom("aaa") );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DoXJo
function name:  (null)
number of ops:  12
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   DECLARE_CLASS                                            'foo'
   21     1        INIT_FCALL                                               'var_dump'
   22     2        INIT_STATIC_METHOD_CALL                                  'Foo', 'from'
          3        SEND_VAL_EX                                              'one'
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
   23     6        INIT_STATIC_METHOD_CALL                                  'Foo', 'tryFrom'
          7        SEND_VAL_EX                                              'aaa'
          8        DO_FCALL                                      0  $1      
          9        SEND_VAR                                                 $1
   21    10        DO_ICALL                                                 
   24    11      > RETURN                                                   1

Class DeserializableEnum:
Function from:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DoXJo
function name:  from
number of ops:  4
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        FETCH_CLASS_CONSTANT                             ~1      !0
          2      > RETURN                                                   ~1
    6     3*     > RETURN                                                   null

End of function from

Function tryfrom:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 6
Branch analysis from position: 6
2 jumps found. (Code = 107) Position 1 = 7, Position 2 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DoXJo
function name:  tryFrom
number of ops:  9
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1        INIT_STATIC_METHOD_CALL                                  'from'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
          5*       JMP                                                      ->8
   10     6  E > > CATCH                                       last         'Throwable'
   11     7    > > RETURN                                                   null
   13     8*     > RETURN                                                   null

End of function tryfrom

End of class DeserializableEnum.

Class Foo: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.16 ms | 1001 KiB | 14 Q