3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { function __construct() { echo get_class($this->getInstance()), PHP_EOL, get_class(static::getInstance()), PHP_EOL, get_class(self::getInstance()), PHP_EOL; } public static function getInstance() { static $getInstance; if (null == $getInstance) $getInstance = self::makeInstance(); return $getInstance; } public static function makeInstance() { return new stdClass(); } } $a = new A(); class B extends A { function __construct() { echo get_class($this->getInstance()), PHP_EOL, get_class(static::getInstance()), PHP_EOL, get_class(self::getInstance()), PHP_EOL; } public static function makeInstance() { return new ArrayObject(); } public function __destruct() { die(); } } $a = new B();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CVSFs
function name:  (null)
number of ops:  7
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   NEW                                              $1      'A'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   49     3        NEW                                              $4      'B'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $4
          6      > RETURN                                                   1

Class A:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CVSFs
function name:  __construct
number of ops:  16
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   INIT_METHOD_CALL                                         'getInstance'
          1        DO_FCALL                                      0  $0      
          2        GET_CLASS                                        ~1      $0
          3        ECHO                                                     ~1
          4        ECHO                                                     '%0A'
    8     5        INIT_STATIC_METHOD_CALL                                  'getInstance'
          6        DO_FCALL                                      0  $2      
          7        GET_CLASS                                        ~3      $2
          8        ECHO                                                     ~3
          9        ECHO                                                     '%0A'
    9    10        INIT_STATIC_METHOD_CALL                                  'getInstance'
         11        DO_FCALL                                      0  $4      
         12        GET_CLASS                                        ~5      $4
         13        ECHO                                                     ~5
         14        ECHO                                                     '%0A'
   10    15      > RETURN                                                   null

End of function __construct

Function getinstance:
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/CVSFs
function name:  getInstance
number of ops:  8
compiled vars:  !0 = $getInstance
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   BIND_STATIC                                              !0
   16     1        IS_EQUAL                                                 !0, null
          2      > JMPZ                                                     ~1, ->6
          3    >   INIT_STATIC_METHOD_CALL                                  'makeInstance'
          4        DO_FCALL                                      0  $2      
          5        ASSIGN                                                   !0, $2
   18     6    > > RETURN                                                   !0
   19     7*     > RETURN                                                   null

End of function getinstance

Function makeinstance:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CVSFs
function name:  makeInstance
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   NEW                                              $0      'stdClass'
          1        DO_FCALL                                      0          
          2      > RETURN                                                   $0
   24     3*     > RETURN                                                   null

End of function makeinstance

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/CVSFs
function name:  __construct
number of ops:  16
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   INIT_METHOD_CALL                                         'getInstance'
          1        DO_FCALL                                      0  $0      
          2        GET_CLASS                                        ~1      $0
          3        ECHO                                                     ~1
          4        ECHO                                                     '%0A'
   34     5        INIT_STATIC_METHOD_CALL                                  'getInstance'
          6        DO_FCALL                                      0  $2      
          7        GET_CLASS                                        ~3      $2
          8        ECHO                                                     ~3
          9        ECHO                                                     '%0A'
   35    10        INIT_STATIC_METHOD_CALL                                  'getInstance'
         11        DO_FCALL                                      0  $4      
         12        GET_CLASS                                        ~5      $4
         13        ECHO                                                     ~5
         14        ECHO                                                     '%0A'
   36    15      > RETURN                                                   null

End of function __construct

Function makeinstance:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CVSFs
function name:  makeInstance
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   NEW                                              $0      'ArrayObject'
          1        DO_FCALL                                      0          
          2      > RETURN                                                   $0
   41     3*     > RETURN                                                   null

End of function makeinstance

Function __destruct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/CVSFs
function name:  __destruct
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E > > EXIT                                                     
   46     1*     > RETURN                                                   null

End of function __destruct

Function getinstance:
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/CVSFs
function name:  getInstance
number of ops:  8
compiled vars:  !0 = $getInstance
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   BIND_STATIC                                              !0
   16     1        IS_EQUAL                                                 !0, null
          2      > JMPZ                                                     ~1, ->6
          3    >   INIT_STATIC_METHOD_CALL                                  'makeInstance'
          4        DO_FCALL                                      0  $2      
          5        ASSIGN                                                   !0, $2
   18     6    > > RETURN                                                   !0
   19     7*     > RETURN                                                   null

End of function getinstance

End of class B.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.66 ms | 1403 KiB | 13 Q