3v4l.org

run code in 500+ PHP versions simultaneously
<?php declare(strict_types=1); error_reporting(-1); ini_set('display_errors', 'On'); class BaseModel { protected static $singleton; public static function __getInstance(): self { if (static::$singleton === null) { static::$singleton = __CLASS__; static::$singleton = new static::$singleton(); } return static::$singleton; } } class AModel extends BaseModel { protected static $singleton; /** ... */ } class BModel extends BaseModel { protected static $singleton; /** ... */ } echo get_class(AModel::__getInstance()), "\n"; echo get_class(BModel::__getInstance());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/N9kCi7
function name:  (null)
number of ops:  17
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    4     0  E >   INIT_FCALL                                                   'error_reporting'
          1        SEND_VAL                                                     -1
          2        DO_ICALL                                                     
    5     3        INIT_FCALL                                                   'ini_set'
          4        SEND_VAL                                                     'display_errors'
          5        SEND_VAL                                                     'On'
          6        DO_ICALL                                                     
   26     7        INIT_STATIC_METHOD_CALL                                      'AModel', '__getInstance'
          8        DO_FCALL                                          0  $2      
          9        GET_CLASS                                            ~3      $2
         10        ECHO                                                         ~3
         11        ECHO                                                         '%0A'
   27    12        INIT_STATIC_METHOD_CALL                                      'BModel', '__getInstance'
         13        DO_FCALL                                          0  $4      
         14        GET_CLASS                                            ~5      $4
         15        ECHO                                                         ~5
         16      > RETURN                                                       1

Class BaseModel:
Function __getinstance:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 11
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/N9kCi7
function name:  __getInstance
number of ops:  16
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   10     0  E >   FETCH_STATIC_PROP_R              unknown             ~0      'singleton'
          1        TYPE_CHECK                                        2          ~0
          2      > JMPZ                                                         ~1, ->11
   11     3    >   ASSIGN_STATIC_PROP                                           'singleton'
          4        OP_DATA                                                      'BaseModel'
   12     5        FETCH_STATIC_PROP_R              unknown             ~4      'singleton'
          6        FETCH_CLASS                                       0  $5      ~4
          7        NEW                                                  $6      $5
          8        DO_FCALL                                          0          
          9        ASSIGN_STATIC_PROP                                           'singleton'
         10        OP_DATA                                                      $6
   14    11    >   FETCH_STATIC_PROP_R              unknown             ~8      'singleton'
         12        VERIFY_RETURN_TYPE                                           ~8
         13      > RETURN                                                       ~8
   15    14*       VERIFY_RETURN_TYPE                                           
         15*     > RETURN                                                       null

End of function __getinstance

End of class BaseModel.

Class AModel:
Function __getinstance:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 11
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/N9kCi7
function name:  __getInstance
number of ops:  16
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   10     0  E >   FETCH_STATIC_PROP_R              unknown             ~0      'singleton'
          1        TYPE_CHECK                                        2          ~0
          2      > JMPZ                                                         ~1, ->11
   11     3    >   ASSIGN_STATIC_PROP                                           'singleton'
          4        OP_DATA                                                      'BaseModel'
   12     5        FETCH_STATIC_PROP_R              unknown             ~4      'singleton'
          6        FETCH_CLASS                                       0  $5      ~4
          7        NEW                                                  $6      $5
          8        DO_FCALL                                          0          
          9        ASSIGN_STATIC_PROP                                           'singleton'
         10        OP_DATA                                                      $6
   14    11    >   FETCH_STATIC_PROP_R              unknown             ~8      'singleton'
         12        VERIFY_RETURN_TYPE                                           ~8
         13      > RETURN                                                       ~8
   15    14*       VERIFY_RETURN_TYPE                                           
         15*     > RETURN                                                       null

End of function __getinstance

End of class AModel.

Class BModel:
Function __getinstance:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 11
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/N9kCi7
function name:  __getInstance
number of ops:  16
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   10     0  E >   FETCH_STATIC_PROP_R              unknown             ~0      'singleton'
          1        TYPE_CHECK                                        2          ~0
          2      > JMPZ                                                         ~1, ->11
   11     3    >   ASSIGN_STATIC_PROP                                           'singleton'
          4        OP_DATA                                                      'BaseModel'
   12     5        FETCH_STATIC_PROP_R              unknown             ~4      'singleton'
          6        FETCH_CLASS                                       0  $5      ~4
          7        NEW                                                  $6      $5
          8        DO_FCALL                                          0          
          9        ASSIGN_STATIC_PROP                                           'singleton'
         10        OP_DATA                                                      $6
   14    11    >   FETCH_STATIC_PROP_R              unknown             ~8      'singleton'
         12        VERIFY_RETURN_TYPE                                           ~8
         13      > RETURN                                                       ~8
   15    14*       VERIFY_RETURN_TYPE                                           
         15*     > RETURN                                                       null

End of function __getinstance

End of class BModel.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
156.66 ms | 2094 KiB | 14 Q