3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait Singleton { protected static $instance; final public static function getInstance() { static $instance; if (!isset(static::$instance)) { static::$instance = new static; } return static::$instance; } } abstract class Abudabia { use Singleton; } class a1 extends Abudabia { public function set() { return 'allah ahbar'; } } class a2 extends Abudabia { public function get() { return 'algazira'; } } $a = a1::getInstance(); $b = a2::getInstance(); var_dump($a, $a->set(),$b);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HhX61
function name:  (null)
number of ops:  17
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                                            'a1', 'abudabia'
   28     2        DECLARE_CLASS                                            'a2', 'abudabia'
   36     3        INIT_STATIC_METHOD_CALL                                  'a1', 'getInstance'
          4        DO_FCALL                                      0  $2      
          5        ASSIGN                                                   !0, $2
   37     6        INIT_STATIC_METHOD_CALL                                  'a2', 'getInstance'
          7        DO_FCALL                                      0  $4      
          8        ASSIGN                                                   !1, $4
   38     9        INIT_FCALL                                               'var_dump'
         10        SEND_VAR                                                 !0
         11        INIT_METHOD_CALL                                         !0, 'set'
         12        DO_FCALL                                      0  $6      
         13        SEND_VAR                                                 $6
         14        SEND_VAR                                                 !1
         15        DO_ICALL                                                 
         16      > RETURN                                                   1

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

End of function getinstance

End of class Singleton.

Class Abudabia: [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/HhX61
function name:  set
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E > > RETURN                                                   'allah+ahbar'
   25     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/HhX61
function name:  get
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E > > RETURN                                                   'algazira'
   33     1*     > RETURN                                                   null

End of function get

End of class a2.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.6 ms | 1392 KiB | 15 Q