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 $instances = []; public static function __getInstance(): self { if (!isset(static::$instances[static::class])) { static::$instances[static::class] = new static(); } return static::$instances[static::class]; } } class AModel extends BaseModel { } class BModel extends BaseModel { } 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/qG0qJ
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                                                     
   29     7        INIT_STATIC_METHOD_CALL                                      'AModel', '__getInstance'
          8        DO_FCALL                                          0  $2      
          9        GET_CLASS                                            ~3      $2
         10        ECHO                                                         ~3
         11        ECHO                                                         '%0A'
   30    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 = 5, Position 2 = 11
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/qG0qJ
function name:  __getInstance
number of ops:  18
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   13     0  E >   FETCH_CLASS_NAME                                     ~1      
          1        FETCH_STATIC_PROP_IS                                 ~0      'instances'
          2        ISSET_ISEMPTY_DIM_OBJ                             0  ~2      ~0, ~1
          3        BOOL_NOT                                             ~3      ~2
          4      > JMPZ                                                         ~3, ->11
   14     5    >   FETCH_CLASS_NAME                                     ~5      
          6        NEW                              static              $7      
          7        DO_FCALL                                          0          
          8        FETCH_STATIC_PROP_W              unknown             $4      'instances'
          9        ASSIGN_DIM                                                   $4, ~5
         10        OP_DATA                                                      $7
   17    11    >   FETCH_CLASS_NAME                                     ~10     
         12        FETCH_STATIC_PROP_R              unknown             ~9      'instances'
         13        FETCH_DIM_R                                          ~11     ~9, ~10
         14        VERIFY_RETURN_TYPE                                           ~11
         15      > RETURN                                                       ~11
   18    16*       VERIFY_RETURN_TYPE                                           
         17*     > 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 = 5, Position 2 = 11
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/qG0qJ
function name:  __getInstance
number of ops:  18
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   13     0  E >   FETCH_CLASS_NAME                                     ~1      
          1        FETCH_STATIC_PROP_IS                                 ~0      'instances'
          2        ISSET_ISEMPTY_DIM_OBJ                             0  ~2      ~0, ~1
          3        BOOL_NOT                                             ~3      ~2
          4      > JMPZ                                                         ~3, ->11
   14     5    >   FETCH_CLASS_NAME                                     ~5      
          6        NEW                              static              $7      
          7        DO_FCALL                                          0          
          8        FETCH_STATIC_PROP_W              unknown             $4      'instances'
          9        ASSIGN_DIM                                                   $4, ~5
         10        OP_DATA                                                      $7
   17    11    >   FETCH_CLASS_NAME                                     ~10     
         12        FETCH_STATIC_PROP_R              unknown             ~9      'instances'
         13        FETCH_DIM_R                                          ~11     ~9, ~10
         14        VERIFY_RETURN_TYPE                                           ~11
         15      > RETURN                                                       ~11
   18    16*       VERIFY_RETURN_TYPE                                           
         17*     > 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 = 5, Position 2 = 11
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/qG0qJ
function name:  __getInstance
number of ops:  18
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   13     0  E >   FETCH_CLASS_NAME                                     ~1      
          1        FETCH_STATIC_PROP_IS                                 ~0      'instances'
          2        ISSET_ISEMPTY_DIM_OBJ                             0  ~2      ~0, ~1
          3        BOOL_NOT                                             ~3      ~2
          4      > JMPZ                                                         ~3, ->11
   14     5    >   FETCH_CLASS_NAME                                     ~5      
          6        NEW                              static              $7      
          7        DO_FCALL                                          0          
          8        FETCH_STATIC_PROP_W              unknown             $4      'instances'
          9        ASSIGN_DIM                                                   $4, ~5
         10        OP_DATA                                                      $7
   17    11    >   FETCH_CLASS_NAME                                     ~10     
         12        FETCH_STATIC_PROP_R              unknown             ~9      'instances'
         13        FETCH_DIM_R                                          ~11     ~9, ~10
         14        VERIFY_RETURN_TYPE                                           ~11
         15      > RETURN                                                       ~11
   18    16*       VERIFY_RETURN_TYPE                                           
         17*     > RETURN                                                       null

End of function __getinstance

End of class BModel.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
159.74 ms | 2086 KiB | 15 Q