3v4l.org

run code in 300+ PHP versions simultaneously
<?php global $wp_test_hooks; if(!is_array($wp_test_hooks)) { $wp_test_hooks = []; } if(!function_exists('add_filter')) { function add_filter( $hook_name, $callback, $priority = 10, $accepted_args = 1 ) { global $wp_test_hooks; $wp_test_hooks[$hook_name][] = [ $callback, $priority, $accepted_args, ]; return true; } } if(!function_exists('add_action')) { function add_action( $hook_name, $callback, $priority = 10, $accepted_args = 1 ) { return add_filter( $hook_name, $callback, $priority, $accepted_args ); } } if(!function_exists('apply_filters')){ function apply_filters( $hook_name, ...$values ) { $value = array_shift($values); global $wp_test_hooks; if(array_key_exists($hook_name, $wp_test_hooks)){ foreach($wp_test_hooks[$hook_name] as $parts){ list($callback, $priority, $accepted_args) = $parts; $value = $callback($value, ...$values); } } return $value; } } if(!function_exists('do_action')){ function do_action( $hook_name, ...$arg ) { global $wp_test_hooks; if(array_key_exists($hook_name, $wp_test_hooks)){ foreach($wp_test_hooks[$hook_name] as $parts){ list($callback, $priority, $accepted_args) = $parts; $callback(...$arg); } } } } add_action('name1', static function(){echo 'In the Action';}); add_filter('name2', static function($originalValue){return 'In the Filter';}); do_action('name1', 'test', 'stuff'); echo PHP_EOL; echo apply_filters('name2', 'test', 'stuff');
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 5
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 11
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 17
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 23
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 29
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
Branch analysis from position: 23
Branch analysis from position: 17
Branch analysis from position: 11
Branch analysis from position: 5
filename:       /in/DAVl0
function name:  (null)
number of ops:  52
compiled vars:  !0 = $wp_test_hooks
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   BIND_GLOBAL                                              !0, 'wp_test_hooks'
    5     1        TYPE_CHECK                                  128  ~1      !0
          2        BOOL_NOT                                         ~2      ~1
          3      > JMPZ                                                     ~2, ->5
    6     4    >   ASSIGN                                                   !0, <array>
    9     5    >   INIT_FCALL                                               'function_exists'
          6        SEND_VAL                                                 'add_filter'
          7        DO_ICALL                                         $4      
          8        BOOL_NOT                                         ~5      $4
          9      > JMPZ                                                     ~5, ->11
   10    10    >   DECLARE_FUNCTION                                         'add_filter'
   23    11    >   INIT_FCALL                                               'function_exists'
         12        SEND_VAL                                                 'add_action'
         13        DO_ICALL                                         $6      
         14        BOOL_NOT                                         ~7      $6
         15      > JMPZ                                                     ~7, ->17
   24    16    >   DECLARE_FUNCTION                                         'add_action'
   29    17    >   INIT_FCALL                                               'function_exists'
         18        SEND_VAL                                                 'apply_filters'
         19        DO_ICALL                                         $8      
         20        BOOL_NOT                                         ~9      $8
         21      > JMPZ                                                     ~9, ->23
   30    22    >   DECLARE_FUNCTION                                         'apply_filters'
   44    23    >   INIT_FCALL                                               'function_exists'
         24        SEND_VAL                                                 'do_action'
         25        DO_ICALL                                         $10     
         26        BOOL_NOT                                         ~11     $10
         27      > JMPZ                                                     ~11, ->29
   45    28    >   DECLARE_FUNCTION                                         'do_action'
   56    29    >   INIT_FCALL_BY_NAME                                       'add_action'
         30        SEND_VAL_EX                                              'name1'
         31        DECLARE_LAMBDA_FUNCTION                          ~12     [4]
         32        SEND_VAL_EX                                              ~12
         33        DO_FCALL                                      0          
   57    34        INIT_FCALL_BY_NAME                                       'add_filter'
         35        SEND_VAL_EX                                              'name2'
         36        DECLARE_LAMBDA_FUNCTION                          ~14     [5]
         37        SEND_VAL_EX                                              ~14
         38        DO_FCALL                                      0          
   59    39        INIT_FCALL_BY_NAME                                       'do_action'
         40        SEND_VAL_EX                                              'name1'
         41        SEND_VAL_EX                                              'test'
         42        SEND_VAL_EX                                              'stuff'
         43        DO_FCALL                                      0          
   60    44        ECHO                                                     '%0A'
   61    45        INIT_FCALL_BY_NAME                                       'apply_filters'
         46        SEND_VAL_EX                                              'name2'
         47        SEND_VAL_EX                                              'test'
         48        SEND_VAL_EX                                              'stuff'
         49        DO_FCALL                                      0  $17     
         50        ECHO                                                     $17
         51      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DAVl0
function name:  add_filter
number of ops:  13
compiled vars:  !0 = $hook_name, !1 = $callback, !2 = $priority, !3 = $accepted_args, !4 = $wp_test_hooks
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      10
          3        RECV_INIT                                        !3      1
   11     4        BIND_GLOBAL                                              !4, 'wp_test_hooks'
   14     5        INIT_ARRAY                                       ~7      !1
   15     6        ADD_ARRAY_ELEMENT                                ~7      !2
   16     7        ADD_ARRAY_ELEMENT                                ~7      !3
   13     8        FETCH_DIM_W                                      $5      !4, !0
          9        ASSIGN_DIM                                               $5
   16    10        OP_DATA                                                  ~7
   19    11      > RETURN                                                   <true>
   20    12*     > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DAVl0
function name:  add_action
number of ops:  12
compiled vars:  !0 = $hook_name, !1 = $callback, !2 = $priority, !3 = $accepted_args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      10
          3        RECV_INIT                                        !3      1
   25     4        INIT_FCALL_BY_NAME                                       'add_filter'
          5        SEND_VAR_EX                                              !0
          6        SEND_VAR_EX                                              !1
          7        SEND_VAR_EX                                              !2
          8        SEND_VAR_EX                                              !3
          9        DO_FCALL                                      0  $4      
         10      > RETURN                                                   $4
   26    11*     > RETURN                                                   null

End of Dynamic Function 1

Dynamic Function 2
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 28
Branch analysis from position: 9
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 27
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 27
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
Branch analysis from position: 28
filename:       /in/DAVl0
function name:  apply_filters
number of ops:  30
compiled vars:  !0 = $hook_name, !1 = $values, !2 = $value, !3 = $wp_test_hooks, !4 = $parts, !5 = $callback, !6 = $priority, !7 = $accepted_args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
          1        RECV_VARIADIC                                    !1      
   31     2        INIT_FCALL                                               'array_shift'
          3        SEND_REF                                                 !1
          4        DO_ICALL                                         $8      
          5        ASSIGN                                                   !2, $8
   32     6        BIND_GLOBAL                                              !3, 'wp_test_hooks'
   33     7        ARRAY_KEY_EXISTS                                         !0, !3
          8      > JMPZ                                                     ~10, ->28
   34     9    >   FETCH_DIM_R                                      ~11     !3, !0
         10      > FE_RESET_R                                       $12     ~11, ->27
         11    > > FE_FETCH_R                                               $12, !4, ->27
   35    12    >   QM_ASSIGN                                        ~13     !4
         13        FETCH_LIST_R                                     $14     ~13, 0
         14        ASSIGN                                                   !5, $14
         15        FETCH_LIST_R                                     $16     ~13, 1
         16        ASSIGN                                                   !6, $16
         17        FETCH_LIST_R                                     $18     ~13, 2
         18        ASSIGN                                                   !7, $18
         19        FREE                                                     ~13
   36    20        INIT_DYNAMIC_CALL                                        !5
         21        SEND_VAR_EX                                              !2
         22        SEND_UNPACK                                              !1
         23        CHECK_UNDEF_ARGS                                         
         24        DO_FCALL                                      1  $20     
         25        ASSIGN                                                   !2, $20
   34    26      > JMP                                                      ->11
         27    >   FE_FREE                                                  $12
   40    28    > > RETURN                                                   !2
   41    29*     > RETURN                                                   null

End of Dynamic Function 2

Dynamic Function 3
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 22
Branch analysis from position: 5
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 21
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 21
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
Branch analysis from position: 22
filename:       /in/DAVl0
function name:  do_action
number of ops:  23
compiled vars:  !0 = $hook_name, !1 = $arg, !2 = $wp_test_hooks, !3 = $parts, !4 = $callback, !5 = $priority, !6 = $accepted_args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E >   RECV                                             !0      
          1        RECV_VARIADIC                                    !1      
   46     2        BIND_GLOBAL                                              !2, 'wp_test_hooks'
   47     3        ARRAY_KEY_EXISTS                                         !0, !2
          4      > JMPZ                                                     ~7, ->22
   48     5    >   FETCH_DIM_R                                      ~8      !2, !0
          6      > FE_RESET_R                                       $9      ~8, ->21
          7    > > FE_FETCH_R                                               $9, !3, ->21
   49     8    >   QM_ASSIGN                                        ~10     !3
          9        FETCH_LIST_R                                     $11     ~10, 0
         10        ASSIGN                                                   !4, $11
         11        FETCH_LIST_R                                     $13     ~10, 1
         12        ASSIGN                                                   !5, $13
         13        FETCH_LIST_R                                     $15     ~10, 2
         14        ASSIGN                                                   !6, $15
         15        FREE                                                     ~10
   50    16        INIT_DYNAMIC_CALL                                        !4
         17        SEND_UNPACK                                              !1
         18        CHECK_UNDEF_ARGS                                         
         19        DO_FCALL                                      1          
   48    20      > JMP                                                      ->7
         21    >   FE_FREE                                                  $9
   53    22    > > RETURN                                                   null

End of Dynamic Function 3

Dynamic Function 4
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DAVl0
function name:  {closure}
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   56     0  E >   ECHO                                                     'In+the+Action'
          1      > RETURN                                                   null

End of Dynamic Function 4

Dynamic Function 5
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DAVl0
function name:  {closure}
number of ops:  3
compiled vars:  !0 = $originalValue
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   57     0  E >   RECV                                             !0      
          1      > RETURN                                                   'In+the+Filter'
          2*     > RETURN                                                   null

End of Dynamic Function 5

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.79 ms | 1016 KiB | 15 Q