3v4l.org

run code in 300+ PHP versions simultaneously
<?php class c { protected $type = null; public function __construct($in) { $this->type = $in; } public function __toString() { return $this->type; } static function getInstanceA() { static $a = null; if ($a === null) { $a = new c('A'); } return $a; } static function getInstanceB() { static $a = null; if ($a === null) { $a = new c('B'); } return $a; } static function someA() { static $a = null; $a = 'this is fucked'; return $a; } } $z = c::someA(); $my_a = c::getInstanceA(); $my_b = c::getInstanceB(); echo $my_a; echo $my_b; echo $z;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Vv4eJ
function name:  (null)
number of ops:  14
compiled vars:  !0 = $z, !1 = $my_a, !2 = $my_b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'c'
   42     1        INIT_STATIC_METHOD_CALL                                  'c', 'someA'
          2        DO_FCALL                                      0  $3      
          3        ASSIGN                                                   !0, $3
   44     4        INIT_STATIC_METHOD_CALL                                  'c', 'getInstanceA'
          5        DO_FCALL                                      0  $5      
          6        ASSIGN                                                   !1, $5
   45     7        INIT_STATIC_METHOD_CALL                                  'c', 'getInstanceB'
          8        DO_FCALL                                      0  $7      
          9        ASSIGN                                                   !2, $7
   47    10        ECHO                                                     !1
   48    11        ECHO                                                     !2
   49    12        ECHO                                                     !0
         13      > RETURN                                                   1

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

End of function __construct

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

End of function __tostring

Function getinstancea:
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 = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/Vv4eJ
function name:  getInstanceA
number of ops:  9
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   BIND_STATIC                                              !0
   18     1        TYPE_CHECK                                    2          !0
          2      > JMPZ                                                     ~1, ->7
   19     3    >   NEW                                              $2      'c'
          4        SEND_VAL_EX                                              'A'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !0, $2
   21     7    > > RETURN                                                   !0
   22     8*     > RETURN                                                   null

End of function getinstancea

Function getinstanceb:
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 = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/Vv4eJ
function name:  getInstanceB
number of ops:  9
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   BIND_STATIC                                              !0
   27     1        TYPE_CHECK                                    2          !0
          2      > JMPZ                                                     ~1, ->7
   28     3    >   NEW                                              $2      'c'
          4        SEND_VAL_EX                                              'B'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !0, $2
   30     7    > > RETURN                                                   !0
   31     8*     > RETURN                                                   null

End of function getinstanceb

Function somea:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Vv4eJ
function name:  someA
number of ops:  4
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   BIND_STATIC                                              !0
   35     1        ASSIGN                                                   !0, 'this+is+fucked'
   36     2      > RETURN                                                   !0
   37     3*     > RETURN                                                   null

End of function somea

End of class c.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.88 ms | 1390 KiB | 13 Q