3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { private function __construct(){ echo 1; } public static function getInstance() { static $instance; if (! isset($instance)) { $c=__CLASS__; $instance=new $c(); } return $instance; } } class B extends A{ function __construct(){ self::getInstance(); self::getInstance(); } } $e = new B();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/muAJQ
function name:  (null)
number of ops:  4
compiled vars:  !0 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   NEW                                              $1      'B'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
          3      > RETURN                                                   1

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

End of function __construct

Function getinstance:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/muAJQ
function name:  getInstance
number of ops:  11
compiled vars:  !0 = $instance, !1 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   BIND_STATIC                                              !0
   11     1        ISSET_ISEMPTY_CV                                 ~2      !0
          2        BOOL_NOT                                         ~3      ~2
          3      > JMPZ                                                     ~3, ->9
   12     4    >   ASSIGN                                                   !1, 'A'
   13     5        FETCH_CLASS                                   0  $5      !1
          6        NEW                                              $6      $5
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !0, $6
   15     9    > > RETURN                                                   !0
   16    10*     > RETURN                                                   null

End of function getinstance

End of class A.

Class B:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/muAJQ
function name:  __construct
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   INIT_STATIC_METHOD_CALL                                  'getInstance'
          1        DO_FCALL                                      0          
   22     2        INIT_STATIC_METHOD_CALL                                  'getInstance'
          3        DO_FCALL                                      0          
   23     4      > RETURN                                                   null

End of function __construct

Function getinstance:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/muAJQ
function name:  getInstance
number of ops:  11
compiled vars:  !0 = $instance, !1 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   BIND_STATIC                                              !0
   11     1        ISSET_ISEMPTY_CV                                 ~2      !0
          2        BOOL_NOT                                         ~3      ~2
          3      > JMPZ                                                     ~3, ->9
   12     4    >   ASSIGN                                                   !1, 'A'
   13     5        FETCH_CLASS                                   0  $5      !1
          6        NEW                                              $6      $5
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !0, $6
   15     9    > > RETURN                                                   !0
   16    10*     > RETURN                                                   null

End of function getinstance

End of class B.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.3 ms | 1390 KiB | 13 Q