3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class Foo { private static $instance = NULL; private function __construct() { } public static function getInstance() { return static::$instance === NULL ? static::$instance = new static() : static::$instance; } } final class Bar extends Foo { } final class Baz extends Foo { } $bar = Bar::getInstance(); echo get_class($bar), "\n"; $baz = Baz::getInstance(); echo get_class($baz), "\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9oc9X
function name:  (null)
number of ops:  13
compiled vars:  !0 = $bar, !1 = $baz
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   INIT_STATIC_METHOD_CALL                                  'Bar', 'getInstance'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
   19     3        GET_CLASS                                        ~4      !0
          4        ECHO                                                     ~4
          5        ECHO                                                     '%0A'
   21     6        INIT_STATIC_METHOD_CALL                                  'Baz', 'getInstance'
          7        DO_FCALL                                      0  $5      
          8        ASSIGN                                                   !1, $5
   22     9        GET_CLASS                                        ~7      !1
         10        ECHO                                                     ~7
         11        ECHO                                                     '%0A'
         12      > RETURN                                                   1

Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9oc9X
function name:  __construct
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E > > 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 = 9
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9oc9X
function name:  getInstance
number of ops:  13
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, ->9
          3    >   NEW                          static              $3      
          4        DO_FCALL                                      0          
          5        ASSIGN_STATIC_PROP                               ~2      'instance'
          6        OP_DATA                                                  $3
          7        QM_ASSIGN                                        ~5      ~2
          8      > JMP                                                      ->11
          9    >   FETCH_STATIC_PROP_R          unknown             ~6      'instance'
         10        QM_ASSIGN                                        ~5      ~6
         11    > > RETURN                                                   ~5
    9    12*     > RETURN                                                   null

End of function getinstance

End of class Foo.

Class Bar:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9oc9X
function name:  __construct
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E > > 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 = 9
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9oc9X
function name:  getInstance
number of ops:  13
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, ->9
          3    >   NEW                          static              $3      
          4        DO_FCALL                                      0          
          5        ASSIGN_STATIC_PROP                               ~2      'instance'
          6        OP_DATA                                                  $3
          7        QM_ASSIGN                                        ~5      ~2
          8      > JMP                                                      ->11
          9    >   FETCH_STATIC_PROP_R          unknown             ~6      'instance'
         10        QM_ASSIGN                                        ~5      ~6
         11    > > RETURN                                                   ~5
    9    12*     > RETURN                                                   null

End of function getinstance

End of class Bar.

Class Baz:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9oc9X
function name:  __construct
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E > > 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 = 9
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9oc9X
function name:  getInstance
number of ops:  13
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, ->9
          3    >   NEW                          static              $3      
          4        DO_FCALL                                      0          
          5        ASSIGN_STATIC_PROP                               ~2      'instance'
          6        OP_DATA                                                  $3
          7        QM_ASSIGN                                        ~5      ~2
          8      > JMP                                                      ->11
          9    >   FETCH_STATIC_PROP_R          unknown             ~6      'instance'
         10        QM_ASSIGN                                        ~5      ~6
         11    > > RETURN                                                   ~5
    9    12*     > RETURN                                                   null

End of function getinstance

End of class Baz.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.75 ms | 1399 KiB | 13 Q