3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php abstract class T { static public $instanses; final private function __construct(){ } public static function getInstance() { var_dump(static::$instanses); if (!(static::$instanses instanceof static)) { static::$instanses = new static; } var_dump(static::$instanses); return static::$instanses; } } class A extends T { static public $instanses; } class B extends A { static public $instanses; } $t = A::getInstance(); var_dump($t); $t1 = B::getInstance(); var_dump($t1); new B(); ?>
based on ni8iO
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/cOJUK
function name:  (null)
number of ops:  20
compiled vars:  !0 = $t, !1 = $t1
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   NOP                                                      
  22     1        NOP                                                      
         2        NOP                                                      
  27     3        NOP                                                      
         4        NOP                                                      
  32     5        INIT_STATIC_METHOD_CALL                                  'A', 'getInstance'
         6        DO_FCALL                                      0  $7      
         7        ASSIGN                                                   !0, $7
  33     8        INIT_FCALL                                               'var_dump'
         9        SEND_VAR                                                 !0
        10        DO_ICALL                                                 
  35    11        INIT_STATIC_METHOD_CALL                                  'B', 'getInstance'
        12        DO_FCALL                                      0  $10     
        13        ASSIGN                                                   !1, $10
  36    14        INIT_FCALL                                               'var_dump'
        15        SEND_VAR                                                 !1
        16        DO_ICALL                                                 
  38    17        NEW                                                      :8
        18        DO_FCALL                                      0          
        19      > RETURN                                                   1

Class T:
Function __construct:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/cOJUK
function name:  __construct
number of ops:  1
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   9     0  E > > RETURN                                                   null

End of function __construct

Function getinstance:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = 11, Position 2 = 17
Branch analysis from position: 11
Jump found. Position 1 = -2
Branch analysis from position: 17
filename:       /in/cOJUK
function name:  getInstance
number of ops:  26
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  13     0  E >   INIT_FCALL                                               'var_dump'
         1        FETCH_CLASS                                 515  :0      
         2        FETCH_R                      static member       $1      'instanses'
         3        SEND_VAR                                                 $1
         4        DO_ICALL                                                 
  14     5        FETCH_CLASS                                 515  :3      
         6        FETCH_R                      static member       $4      'instanses'
         7        FETCH_CLASS                                 131  :5      
         8        INSTANCEOF                                       ~6      $4, $5
         9        BOOL_NOT                                         ~7      ~6
        10      > JMPZ                                                     ~7, ->17
  15    11    >   FETCH_CLASS                                 515  :8      
        12        FETCH_W                      static member       $9      'instanses'
        13        FETCH_CLASS                                 515  :10     
        14        NEW                                              $11     :10
        15        DO_FCALL                                      0          
        16        ASSIGN                                                   $9, $11
  17    17    >   INIT_FCALL                                               'var_dump'
        18        FETCH_CLASS                                 515  :14     
        19        FETCH_R                      static member       $15     'instanses'
        20        SEND_VAR                                                 $15
        21        DO_ICALL                                                 
  18    22        FETCH_CLASS                                 515  :17     
        23        FETCH_R                      static member       $18     'instanses'
        24      > RETURN                                                   $18
  19    25*     > RETURN                                                   null

End of function getinstance

End of class T.

Class A:
Function __construct:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/cOJUK
function name:  __construct
number of ops:  1
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   9     0  E > > RETURN                                                   null

End of function __construct

Function getinstance:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = 11, Position 2 = 17
Branch analysis from position: 11
Jump found. Position 1 = -2
Branch analysis from position: 17
filename:       /in/cOJUK
function name:  getInstance
number of ops:  26
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  13     0  E >   INIT_FCALL                                               'var_dump'
         1        FETCH_CLASS                                 515  :0      
         2        FETCH_R                      static member       $1      'instanses'
         3        SEND_VAR                                                 $1
         4        DO_ICALL                                                 
  14     5        FETCH_CLASS                                 515  :3      
         6        FETCH_R                      static member       $4      'instanses'
         7        FETCH_CLASS                                 131  :5      
         8        INSTANCEOF                                       ~6      $4, $5
         9        BOOL_NOT                                         ~7      ~6
        10      > JMPZ                                                     ~7, ->17
  15    11    >   FETCH_CLASS                                 515  :8      
        12        FETCH_W                      static member       $9      'instanses'
        13        FETCH_CLASS                                 515  :10     
        14        NEW                                              $11     :10
        15        DO_FCALL                                      0          
        16        ASSIGN                                                   $9, $11
  17    17    >   INIT_FCALL                                               'var_dump'
        18        FETCH_CLASS                                 515  :14     
        19        FETCH_R                      static member       $15     'instanses'
        20        SEND_VAR                                                 $15
        21        DO_ICALL                                                 
  18    22        FETCH_CLASS                                 515  :17     
        23        FETCH_R                      static member       $18     'instanses'
        24      > RETURN                                                   $18
  19    25*     > RETURN                                                   null

End of function getinstance

End of class A.

Class B:
Function __construct:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/cOJUK
function name:  __construct
number of ops:  1
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   9     0  E > > RETURN                                                   null

End of function __construct

Function getinstance:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = 11, Position 2 = 17
Branch analysis from position: 11
Jump found. Position 1 = -2
Branch analysis from position: 17
filename:       /in/cOJUK
function name:  getInstance
number of ops:  26
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  13     0  E >   INIT_FCALL                                               'var_dump'
         1        FETCH_CLASS                                 515  :0      
         2        FETCH_R                      static member       $1      'instanses'
         3        SEND_VAR                                                 $1
         4        DO_ICALL                                                 
  14     5        FETCH_CLASS                                 515  :3      
         6        FETCH_R                      static member       $4      'instanses'
         7        FETCH_CLASS                                 131  :5      
         8        INSTANCEOF                                       ~6      $4, $5
         9        BOOL_NOT                                         ~7      ~6
        10      > JMPZ                                                     ~7, ->17
  15    11    >   FETCH_CLASS                                 515  :8      
        12        FETCH_W                      static member       $9      'instanses'
        13        FETCH_CLASS                                 515  :10     
        14        NEW                                              $11     :10
        15        DO_FCALL                                      0          
        16        ASSIGN                                                   $9, $11
  17    17    >   INIT_FCALL                                               'var_dump'
        18        FETCH_CLASS                                 515  :14     
        19        FETCH_R                      static member       $15     'instanses'
        20        SEND_VAR                                                 $15
        21        DO_ICALL                                                 
  18    22        FETCH_CLASS                                 515  :17     
        23        FETCH_R                      static member       $18     'instanses'
        24      > RETURN                                                   $18
  19    25*     > RETURN                                                   null

End of function getinstance

End of class B.

Generated using Vulcan Logic Dumper, using php 7.3.0