3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { protected $foo; function __construct($foo) { $this->foo = $foo; } function modify($foo) { $o = clone $this; if (is_callable([$o, '__construct'])) { $o->__construct($foo); } return $o; } function getFoo() { return $this->foo; } } $f = new Foo("foo"); var_dump($f->getFoo()); var_dump($f->modify("bar"));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OEuD5
function name:  (null)
number of ops:  16
compiled vars:  !0 = $f
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   NEW                                              $1      'Foo'
          1        SEND_VAL_EX                                              'foo'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   29     4        INIT_FCALL                                               'var_dump'
          5        INIT_METHOD_CALL                                         !0, 'getFoo'
          6        DO_FCALL                                      0  $4      
          7        SEND_VAR                                                 $4
          8        DO_ICALL                                                 
   31     9        INIT_FCALL                                               'var_dump'
         10        INIT_METHOD_CALL                                         !0, 'modify'
         11        SEND_VAL_EX                                              'bar'
         12        DO_FCALL                                      0  $6      
         13        SEND_VAR                                                 $6
         14        DO_ICALL                                                 
         15      > RETURN                                                   1

Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OEuD5
function name:  __construct
number of ops:  4
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    8     1        ASSIGN_OBJ                                               'foo'
          2        OP_DATA                                                  !0
    9     3      > RETURN                                                   null

End of function __construct

Function modify:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/OEuD5
function name:  modify
number of ops:  15
compiled vars:  !0 = $foo, !1 = $o
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   13     1        FETCH_THIS                                       ~2      
          2        CLONE                                            ~3      ~2
          3        ASSIGN                                                   !1, ~3
   15     4        INIT_FCALL                                               'is_callable'
          5        INIT_ARRAY                                       ~5      !1
          6        ADD_ARRAY_ELEMENT                                ~5      '__construct'
          7        SEND_VAL                                                 ~5
          8        DO_ICALL                                         $6      
          9      > JMPZ                                                     $6, ->13
   16    10    >   INIT_METHOD_CALL                                         !1, '__construct'
         11        SEND_VAR_EX                                              !0
         12        DO_FCALL                                      0          
   19    13    > > RETURN                                                   !1
   20    14*     > RETURN                                                   null

End of function modify

Function getfoo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OEuD5
function name:  getFoo
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   FETCH_OBJ_R                                      ~0      'foo'
          1      > RETURN                                                   ~0
   25     2*     > RETURN                                                   null

End of function getfoo

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.77 ms | 1400 KiB | 17 Q