3v4l.org

run code in 300+ PHP versions simultaneously
<?php class EmptyObj{ protected function __construct(){} public static function get(){ static $obj; if(!$obj) $obj = new EmptyObj; return $obj; } public function __call($n, $a){ return $this; } public function __toString(){ return ''; } } class SomeClass{ public $image; public function __construct(){ $this->image = EmptyObj::get(); }} $a = new SomeClass; echo $a->image->oopsForgotToSetImage(); echo $a->image->ExecSomeFnWithExpectedObject()->getSomethingFromObj()->expectVal;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/elnsv
function name:  (null)
number of ops:  16
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   DECLARE_CLASS                                            'emptyobj'
   22     1        NEW                                              $1      'SomeClass'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   23     4        FETCH_OBJ_R                                      ~4      !0, 'image'
          5        INIT_METHOD_CALL                                         ~4, 'oopsForgotToSetImage'
          6        DO_FCALL                                      0  $5      
          7        ECHO                                                     $5
   24     8        FETCH_OBJ_R                                      ~6      !0, 'image'
          9        INIT_METHOD_CALL                                         ~6, 'ExecSomeFnWithExpectedObject'
         10        DO_FCALL                                      0  $7      
         11        INIT_METHOD_CALL                                         $7, 'getSomethingFromObj'
         12        DO_FCALL                                      0  $8      
         13        FETCH_OBJ_R                                      ~9      $8, 'expectVal'
         14        ECHO                                                     ~9
         15      > RETURN                                                   1

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

End of function __construct

Function get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
filename:       /in/elnsv
function name:  get
number of ops:  8
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   BIND_STATIC                                              !0
    6     1        BOOL_NOT                                         ~1      !0
          2      > JMPZ                                                     ~1, ->6
    7     3    >   NEW                                              $2      'EmptyObj'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $2
    8     6    > > RETURN                                                   !0
    9     7*     > RETURN                                                   null

End of function get

Function __call:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/elnsv
function name:  __call
number of ops:  5
compiled vars:  !0 = $n, !1 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   11     2        FETCH_THIS                                       ~2      
          3      > RETURN                                                   ~2
   12     4*     > RETURN                                                   null

End of function __call

Function __tostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/elnsv
function name:  __toString
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E > > RETURN                                                   ''
   15     1*       VERIFY_RETURN_TYPE                                       
          2*     > RETURN                                                   null

End of function __tostring

End of class EmptyObj.

Class SomeClass:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/elnsv
function name:  __construct
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   INIT_STATIC_METHOD_CALL                                  'EmptyObj', 'get'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN_OBJ                                               'image'
          3        OP_DATA                                                  $1
   21     4      > RETURN                                                   null

End of function __construct

End of class SomeClass.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.62 ms | 1399 KiB | 13 Q