3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $bar; public function getBar() { return $this->bar; } public function setBar($bar) { $this->bar = $bar; } } class Baz { private $container = []; public function add(Foo $foo) { $this->container[] = $foo; } public function getFirstOrDefault() { return isset($this->container[0]) ? $this->container[0] : null; } } $foo = new Foo(); $foo->setBar('baz'); $baz = new Baz(); $baz->add($foo); echo $baz->getFirstOrDefault()->getBar();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rogYW
function name:  (null)
number of ops:  18
compiled vars:  !0 = $foo, !1 = $baz
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   NEW                                              $2      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   18     3        INIT_METHOD_CALL                                         !0, 'setBar'
          4        SEND_VAL_EX                                              'baz'
          5        DO_FCALL                                      0          
   19     6        NEW                                              $6      'Baz'
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !1, $6
   20     9        INIT_METHOD_CALL                                         !1, 'add'
         10        SEND_VAR_EX                                              !0
         11        DO_FCALL                                      0          
   21    12        INIT_METHOD_CALL                                         !1, 'getFirstOrDefault'
         13        DO_FCALL                                      0  $10     
         14        INIT_METHOD_CALL                                         $10, 'getBar'
         15        DO_FCALL                                      0  $11     
         16        ECHO                                                     $11
         17      > RETURN                                                   1

Class Foo:
Function getbar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rogYW
function name:  getBar
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   FETCH_OBJ_R                                      ~0      'bar'
          1      > RETURN                                                   ~0
          2*     > RETURN                                                   null

End of function getbar

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

End of function setbar

End of class Foo.

Class Baz:
Function add:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rogYW
function name:  add
number of ops:  5
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        FETCH_OBJ_W                                      $1      'container'
          2        ASSIGN_DIM                                               $1
          3        OP_DATA                                                  !0
          4      > RETURN                                                   null

End of function add

Function getfirstordefault:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rogYW
function name:  getFirstOrDefault
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   FETCH_OBJ_IS                                     ~0      'container'
          1        ISSET_ISEMPTY_DIM_OBJ                         0          ~0, 0
          2      > JMPZ                                                     ~1, ->7
          3    >   FETCH_OBJ_R                                      ~2      'container'
          4        FETCH_DIM_R                                      ~3      ~2, 0
          5        QM_ASSIGN                                        ~4      ~3
          6      > JMP                                                      ->8
          7    >   QM_ASSIGN                                        ~4      null
          8    > > RETURN                                                   ~4
          9*     > RETURN                                                   null

End of function getfirstordefault

End of class Baz.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.75 ms | 1390 KiB | 13 Q