3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public static $instance; public static function getInstance() { if (static::$instance === null) { static::$instance = new static(); } } } class B extends A { public static $instance; } echo get_class(A::getInstance()) . PHP_EOL; echo get_class(B::getInstance()) . PHP_EOL; echo get_class(A::getInstance()) . PHP_EOL;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VIeOm
function name:  (null)
number of ops:  16
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   INIT_STATIC_METHOD_CALL                                  'A', 'getInstance'
          1        DO_FCALL                                      0  $0      
          2        GET_CLASS                                        ~1      $0
          3        CONCAT                                           ~2      ~1, '%0A'
          4        ECHO                                                     ~2
   20     5        INIT_STATIC_METHOD_CALL                                  'B', 'getInstance'
          6        DO_FCALL                                      0  $3      
          7        GET_CLASS                                        ~4      $3
          8        CONCAT                                           ~5      ~4, '%0A'
          9        ECHO                                                     ~5
   21    10        INIT_STATIC_METHOD_CALL                                  'A', 'getInstance'
         11        DO_FCALL                                      0  $6      
         12        GET_CLASS                                        ~7      $6
         13        CONCAT                                           ~8      ~7, '%0A'
         14        ECHO                                                     ~8
         15      > RETURN                                                   1

Class A:
Function getinstance:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/VIeOm
function name:  getInstance
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'instance'
          1        TYPE_CHECK                                    2          ~0
          2      > JMPZ                                                     ~1, ->7
    9     3    >   NEW                          static              $3      
          4        DO_FCALL                                      0          
          5        ASSIGN_STATIC_PROP                                       'instance'
          6        OP_DATA                                                  $3
   11     7    > > RETURN                                                   null

End of function getinstance

End of class A.

Class B:
Function getinstance:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/VIeOm
function name:  getInstance
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'instance'
          1        TYPE_CHECK                                    2          ~0
          2      > JMPZ                                                     ~1, ->7
    9     3    >   NEW                          static              $3      
          4        DO_FCALL                                      0          
          5        ASSIGN_STATIC_PROP                                       'instance'
          6        OP_DATA                                                  $3
   11     7    > > RETURN                                                   null

End of function getinstance

End of class B.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.19 ms | 1390 KiB | 13 Q