3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Master { /** @var static $instance - singleton each class into its own! */ protected static $instance; /** * @return static */ final public static function getInstance() { if(static::$instance === null) { static::$instance = new static(); } return static::$instance; } protected function __construct() { echo "construct".__CLASS__." as ".static::class . " via " . self::class.PHP_EOL; } } class Slave extends Master { /** @var static $instance - singleton each class into its own! */ protected static $instance; protected function __construct() { echo "construct".__CLASS__." as ".static::class . " via " . self::class.PHP_EOL; } } class AnotherSlave extends Slave { /** @var static $instance - singleton each class into its own! */ protected static $instance; protected function __construct() { echo "construct".__CLASS__." as ".static::class . " via " . self::class.PHP_EOL; } } class FailedSlave extends Slave { // protected static $instance; protected function __construct() { echo "construct".__CLASS__." as ".static::class . " via " . self::class.PHP_EOL; } } $master = Master::getInstance(); $master = Master::getInstance(); $master = Master::getInstance(); $slave = Slave::getInstance(); $slave = Slave::getInstance(); $slave = Slave::getInstance(); $anotherSlave = AnotherSlave::getInstance(); $anotherSlave = AnotherSlave::getInstance(); $anotherSlave = AnotherSlave::getInstance(); $failedSlave = FailedSlave::getInstance(); $failedSlave = FailedSlave::getInstance(); $failedSlave = FailedSlave::getInstance();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qEVBi
function name:  (null)
number of ops:  37
compiled vars:  !0 = $master, !1 = $slave, !2 = $anotherSlave, !3 = $failedSlave
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   50     0  E >   INIT_STATIC_METHOD_CALL                                  'Master', 'getInstance'
          1        DO_FCALL                                      0  $4      
          2        ASSIGN                                                   !0, $4
   51     3        INIT_STATIC_METHOD_CALL                                  'Master', 'getInstance'
          4        DO_FCALL                                      0  $6      
          5        ASSIGN                                                   !0, $6
   52     6        INIT_STATIC_METHOD_CALL                                  'Master', 'getInstance'
          7        DO_FCALL                                      0  $8      
          8        ASSIGN                                                   !0, $8
   54     9        INIT_STATIC_METHOD_CALL                                  'Slave', 'getInstance'
         10        DO_FCALL                                      0  $10     
         11        ASSIGN                                                   !1, $10
   55    12        INIT_STATIC_METHOD_CALL                                  'Slave', 'getInstance'
         13        DO_FCALL                                      0  $12     
         14        ASSIGN                                                   !1, $12
   56    15        INIT_STATIC_METHOD_CALL                                  'Slave', 'getInstance'
         16        DO_FCALL                                      0  $14     
         17        ASSIGN                                                   !1, $14
   58    18        INIT_STATIC_METHOD_CALL                                  'AnotherSlave', 'getInstance'
         19        DO_FCALL                                      0  $16     
         20        ASSIGN                                                   !2, $16
   59    21        INIT_STATIC_METHOD_CALL                                  'AnotherSlave', 'getInstance'
         22        DO_FCALL                                      0  $18     
         23        ASSIGN                                                   !2, $18
   60    24        INIT_STATIC_METHOD_CALL                                  'AnotherSlave', 'getInstance'
         25        DO_FCALL                                      0  $20     
         26        ASSIGN                                                   !2, $20
   62    27        INIT_STATIC_METHOD_CALL                                  'FailedSlave', 'getInstance'
         28        DO_FCALL                                      0  $22     
         29        ASSIGN                                                   !3, $22
   63    30        INIT_STATIC_METHOD_CALL                                  'FailedSlave', 'getInstance'
         31        DO_FCALL                                      0  $24     
         32        ASSIGN                                                   !3, $24
   64    33        INIT_STATIC_METHOD_CALL                                  'FailedSlave', 'getInstance'
         34        DO_FCALL                                      0  $26     
         35        ASSIGN                                                   !3, $26
         36      > RETURN                                                   1

Class Master:
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/qEVBi
function name:  getInstance
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'instance'
          1        TYPE_CHECK                                    2          ~0
          2      > JMPZ                                                     ~1, ->7
   13     3    >   NEW                          static              $3      
          4        DO_FCALL                                      0          
          5        ASSIGN_STATIC_PROP                                       'instance'
          6        OP_DATA                                                  $3
   15     7    >   FETCH_STATIC_PROP_R          unknown             ~5      'instance'
          8      > RETURN                                                   ~5
   16     9*     > RETURN                                                   null

End of function getinstance

Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qEVBi
function name:  __construct
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   FETCH_CLASS_NAME                                 ~0      
          1        CONCAT                                           ~1      'constructMaster+as+', ~0
          2        CONCAT                                           ~2      ~1, '+via+'
          3        CONCAT                                           ~3      ~2, 'Master'
          4        CONCAT                                           ~4      ~3, '%0A'
          5        ECHO                                                     ~4
   21     6      > RETURN                                                   null

End of function __construct

End of class Master.

Class Slave:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qEVBi
function name:  __construct
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   FETCH_CLASS_NAME                                 ~0      
          1        CONCAT                                           ~1      'constructSlave+as+', ~0
          2        CONCAT                                           ~2      ~1, '+via+'
          3        CONCAT                                           ~3      ~2, 'Slave'
          4        CONCAT                                           ~4      ~3, '%0A'
          5        ECHO                                                     ~4
   30     6      > 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 = 7
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/qEVBi
function name:  getInstance
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'instance'
          1        TYPE_CHECK                                    2          ~0
          2      > JMPZ                                                     ~1, ->7
   13     3    >   NEW                          static              $3      
          4        DO_FCALL                                      0          
          5        ASSIGN_STATIC_PROP                                       'instance'
          6        OP_DATA                                                  $3
   15     7    >   FETCH_STATIC_PROP_R          unknown             ~5      'instance'
          8      > RETURN                                                   ~5
   16     9*     > RETURN                                                   null

End of function getinstance

End of class Slave.

Class AnotherSlave:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qEVBi
function name:  __construct
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   FETCH_CLASS_NAME                                 ~0      
          1        CONCAT                                           ~1      'constructAnotherSlave+as+', ~0
          2        CONCAT                                           ~2      ~1, '+via+'
          3        CONCAT                                           ~3      ~2, 'AnotherSlave'
          4        CONCAT                                           ~4      ~3, '%0A'
          5        ECHO                                                     ~4
   39     6      > 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 = 7
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/qEVBi
function name:  getInstance
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'instance'
          1        TYPE_CHECK                                    2          ~0
          2      > JMPZ                                                     ~1, ->7
   13     3    >   NEW                          static              $3      
          4        DO_FCALL                                      0          
          5        ASSIGN_STATIC_PROP                                       'instance'
          6        OP_DATA                                                  $3
   15     7    >   FETCH_STATIC_PROP_R          unknown             ~5      'instance'
          8      > RETURN                                                   ~5
   16     9*     > RETURN                                                   null

End of function getinstance

End of class AnotherSlave.

Class FailedSlave:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qEVBi
function name:  __construct
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E >   FETCH_CLASS_NAME                                 ~0      
          1        CONCAT                                           ~1      'constructFailedSlave+as+', ~0
          2        CONCAT                                           ~2      ~1, '+via+'
          3        CONCAT                                           ~3      ~2, 'FailedSlave'
          4        CONCAT                                           ~4      ~3, '%0A'
          5        ECHO                                                     ~4
   46     6      > 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 = 7
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/qEVBi
function name:  getInstance
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'instance'
          1        TYPE_CHECK                                    2          ~0
          2      > JMPZ                                                     ~1, ->7
   13     3    >   NEW                          static              $3      
          4        DO_FCALL                                      0          
          5        ASSIGN_STATIC_PROP                                       'instance'
          6        OP_DATA                                                  $3
   15     7    >   FETCH_STATIC_PROP_R          unknown             ~5      'instance'
          8      > RETURN                                                   ~5
   16     9*     > RETURN                                                   null

End of function getinstance

End of class FailedSlave.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.23 ms | 1015 KiB | 13 Q