3v4l.org

run code in 300+ PHP versions simultaneously
<?php class WP_Widget { public function __construct( $id_base, $name, $widget_options = array(), $control_options = array() ) {} } class WP_Widget_Text extends WP_Widget { public function __construct() { $widget_ops = array( 'classname' => 'widget_text', 'description' => 'Arbitrary text.', 'customize_selective_refresh' => true, 'show_instance_in_rest' => true, ); $control_ops = array( 'width' => 400, 'height' => 350, ); parent::__construct( 'text', 'Text', $widget_ops, $control_ops ); } } class Text_Widget extends WP_Widget { // Notice it does not have a constructor, which is doing it wrong. } class WP_Widget_Factory { public $widgets = array(); public function register( $widget ) { if ( $widget instanceof WP_Widget ) { $this->widgets[ spl_object_hash( $widget ) ] = $widget; } else { $this->widgets[ $widget ] = new $widget(); } } } $factory = new WP_Widget_Factory(); $factory->register( 'Text_Widget' );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uPrIn
function name:  (null)
number of ops:  7
compiled vars:  !0 = $factory
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   NEW                                              $1      'WP_Widget_Factory'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   40     3        INIT_METHOD_CALL                                         !0, 'register'
          4        SEND_VAL_EX                                              'Text_Widget'
          5        DO_FCALL                                      0          
          6      > RETURN                                                   1

Class WP_Widget:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uPrIn
function name:  __construct
number of ops:  5
compiled vars:  !0 = $id_base, !1 = $name, !2 = $widget_options, !3 = $control_options
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      <array>
          3        RECV_INIT                                        !3      <array>
          4      > RETURN                                                   null

End of function __construct

End of class WP_Widget.

Class WP_Widget_Text:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uPrIn
function name:  __construct
number of ops:  9
compiled vars:  !0 = $widget_ops, !1 = $control_ops
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   ASSIGN                                                   !0, <array>
   15     1        ASSIGN                                                   !1, <array>
   19     2        INIT_STATIC_METHOD_CALL                                  
          3        SEND_VAL_EX                                              'text'
          4        SEND_VAL_EX                                              'Text'
          5        SEND_VAR_EX                                              !0
          6        SEND_VAR_EX                                              !1
          7        DO_FCALL                                      0          
   20     8      > RETURN                                                   null

End of function __construct

End of class WP_Widget_Text.

Class Text_Widget:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uPrIn
function name:  __construct
number of ops:  5
compiled vars:  !0 = $id_base, !1 = $name, !2 = $widget_options, !3 = $control_options
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      <array>
          3        RECV_INIT                                        !3      <array>
          4      > RETURN                                                   null

End of function __construct

End of class Text_Widget.

Class WP_Widget_Factory:
Function register:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 10
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uPrIn
function name:  register
number of ops:  17
compiled vars:  !0 = $widget
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
   31     1        INSTANCEOF                                               !0, 'WP_Widget'
          2      > JMPZ                                                     ~1, ->10
   32     3    >   INIT_FCALL                                               'spl_object_hash'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $3      
          6        FETCH_OBJ_W                                      $2      'widgets'
          7        ASSIGN_DIM                                               $2, $3
          8        OP_DATA                                                  !0
   31     9      > JMP                                                      ->16
   34    10    >   FETCH_CLASS                                   0  $7      !0
         11        NEW                                              $8      $7
         12        DO_FCALL                                      0          
         13        FETCH_OBJ_W                                      $5      'widgets'
         14        ASSIGN_DIM                                               $5, !0
         15        OP_DATA                                                  $8
   36    16    > > RETURN                                                   null

End of function register

End of class WP_Widget_Factory.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.59 ms | 1441 KiB | 14 Q