3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait Singleton { final public static function getInstance() { static $instance; if (!isset(static::$instance)) { static $instance; static::$instance = new static; } return static::$instance; } } abstract class Abudabia { use Singleton; } abstract class Mozambik { use Singleton; } class a1 extends Abudabia { public function set() { return 'allah ahbar'; } } class a2 extends Mozambik { public function get() { return 'algazira'; } } $a = a1::getInstance(); $b = a2::getInstance(); var_dump($a->set(),$b->get());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JRjPi
function name:  (null)
number of ops:  19
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   DECLARE_CLASS                                            'abudabia'
   20     1        DECLARE_CLASS                                            'mozambik'
   24     2        DECLARE_CLASS                                            'a1', 'abudabia'
   32     3        DECLARE_CLASS                                            'a2', 'mozambik'
   40     4        INIT_STATIC_METHOD_CALL                                  'a1', 'getInstance'
          5        DO_FCALL                                      0  $2      
          6        ASSIGN                                                   !0, $2
   41     7        INIT_STATIC_METHOD_CALL                                  'a2', 'getInstance'
          8        DO_FCALL                                      0  $4      
          9        ASSIGN                                                   !1, $4
   42    10        INIT_FCALL                                               'var_dump'
         11        INIT_METHOD_CALL                                         !0, 'set'
         12        DO_FCALL                                      0  $6      
         13        SEND_VAR                                                 $6
         14        INIT_METHOD_CALL                                         !1, 'get'
         15        DO_FCALL                                      0  $7      
         16        SEND_VAR                                                 $7
         17        DO_ICALL                                                 
         18      > RETURN                                                   1

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

End of function getinstance

End of class Singleton.

Class Abudabia: [no user functions]
Class Mozambik: [no user functions]
Class a1:
Function set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JRjPi
function name:  set
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E > > RETURN                                                   'allah+ahbar'
   29     1*     > RETURN                                                   null

End of function set

End of class a1.

Class a2:
Function get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JRjPi
function name:  get
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E > > RETURN                                                   'algazira'
   37     1*     > RETURN                                                   null

End of function get

End of class a2.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.97 ms | 1400 KiB | 15 Q