3v4l.org

run code in 300+ PHP versions simultaneously
<?php Enum Val: string { case Bar = 'bar'; case Baz = 'baz'; } class A { public function foo(string $s) { print $s; } } class B extends A { public function foo(string|Val $s) { if (is_string($s)) { print $s; } else { print $s->value; } } } $b = new B(); $b->foo('beep'); $b->foo(Val::Baz);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GnBJr
function name:  (null)
number of ops:  12
compiled vars:  !0 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'val'
   30     1        NEW                                              $1      'B'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   32     4        INIT_METHOD_CALL                                         !0, 'foo'
          5        SEND_VAL_EX                                              'beep'
          6        DO_FCALL                                      0          
   34     7        INIT_METHOD_CALL                                         !0, 'foo'
          8        FETCH_CLASS_CONSTANT                             ~5      'Val', 'Baz'
          9        SEND_VAL_EX                                              ~5
         10        DO_FCALL                                      0          
         11      > RETURN                                                   1

Class Val: [no user functions]
Class A:
Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GnBJr
function name:  foo
number of ops:  3
compiled vars:  !0 = $s
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   14     1        ECHO                                                     !0
   15     2      > RETURN                                                   null

End of function foo

End of class A.

Class B:
Function foo:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GnBJr
function name:  foo
number of ops:  8
compiled vars:  !0 = $s
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   22     1        TYPE_CHECK                                   64          !0
          2      > JMPZ                                                     ~1, ->5
   23     3    >   ECHO                                                     !0
   22     4      > JMP                                                      ->7
   25     5    >   FETCH_OBJ_R                                      ~2      !0, 'value'
          6        ECHO                                                     ~2
   27     7    > > RETURN                                                   null

End of function foo

End of class B.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
135.98 ms | 996 KiB | 13 Q