3v4l.org

run code in 300+ PHP versions simultaneously
<?php define( 'APPLY_PATCH', false ); define( 'VERBOSE', true ); class Dummy { public $pub = 0; protected $prot = 1; private $priv = 2; } $dummy = new Dummy(); $dummy_to_arr = (array) $dummy; // Doing this adds NUL bytes to private and protected property keys. $dummy_arr_to_obj = (object) $dummy_to_arr; // Now there's NUL bytes in the property names. $object_vars = APPLY_PATCH ? wp_get_object_vars( $dummy_arr_to_obj ) : get_object_vars( $dummy_arr_to_obj ); if ( VERBOSE ) { echo '$dummy: ', PHP_EOL, var_export( $dummy, true ), PHP_EOL, PHP_EOL; echo '$dummy_to_arr: ', PHP_EOL, var_export( $dummy_to_arr, true ), PHP_EOL, PHP_EOL; echo '$dummy_arr_to_obj: ', PHP_EOL, var_export( $dummy_arr_to_obj, true ), PHP_EOL, PHP_EOL; echo '$object_vars: ', PHP_EOL, var_export( $object_vars, true ), PHP_EOL, PHP_EOL; } foreach ( $object_vars as $property_name => $property_value ) { $dummy_arr_to_obj->$property_name = '1'; } // The new function in PR 3607. function wp_get_object_vars( $obj ) { return array_filter( get_object_vars( $obj ), function ( $key ) { return ord( $key ) !== 0; }, ARRAY_FILTER_USE_KEY ); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 22
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 65
Branch analysis from position: 29
2 jumps found. (Code = 77) Position 1 = 66, Position 2 = 71
Branch analysis from position: 66
2 jumps found. (Code = 78) Position 1 = 67, Position 2 = 71
Branch analysis from position: 67
1 jumps found. (Code = 42) Position 1 = 66
Branch analysis from position: 66
Branch analysis from position: 71
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 71
Branch analysis from position: 65
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 65
Branch analysis from position: 29
Branch analysis from position: 65
filename:       /in/ScIk3
function name:  (null)
number of ops:  73
compiled vars:  !0 = $dummy, !1 = $dummy_to_arr, !2 = $dummy_arr_to_obj, !3 = $object_vars, !4 = $property_value, !5 = $property_name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'define'
          1        SEND_VAL                                                 'APPLY_PATCH'
          2        SEND_VAL                                                 <false>
          3        DO_ICALL                                                 
    4     4        INIT_FCALL                                               'define'
          5        SEND_VAL                                                 'VERBOSE'
          6        SEND_VAL                                                 <true>
          7        DO_ICALL                                                 
   12     8        NEW                                              $8      'Dummy'
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !0, $8
   13    11        CAST                                          7  ~11     !0
         12        ASSIGN                                                   !1, ~11
   14    13        CAST                                          8  ~13     !1
         14        ASSIGN                                                   !2, ~13
   15    15        FETCH_CONSTANT                                   ~15     'APPLY_PATCH'
         16      > JMPZ                                                     ~15, ->22
         17    >   INIT_FCALL_BY_NAME                                       'wp_get_object_vars'
         18        SEND_VAR_EX                                              !2
         19        DO_FCALL                                      0  $16     
         20        QM_ASSIGN                                        ~17     $16
         21      > JMP                                                      ->26
         22    >   INIT_FCALL                                               'get_object_vars'
         23        SEND_VAR                                                 !2
         24        DO_ICALL                                         $18     
         25        QM_ASSIGN                                        ~17     $18
         26    >   ASSIGN                                                   !3, ~17
   17    27        FETCH_CONSTANT                                   ~20     'VERBOSE'
         28      > JMPZ                                                     ~20, ->65
   18    29    >   ECHO                                                     '%24dummy%3A+'
         30        ECHO                                                     '%0A'
         31        INIT_FCALL                                               'var_export'
         32        SEND_VAR                                                 !0
         33        SEND_VAL                                                 <true>
         34        DO_ICALL                                         $21     
         35        ECHO                                                     $21
         36        ECHO                                                     '%0A'
         37        ECHO                                                     '%0A'
   19    38        ECHO                                                     '%24dummy_to_arr%3A+'
         39        ECHO                                                     '%0A'
         40        INIT_FCALL                                               'var_export'
         41        SEND_VAR                                                 !1
         42        SEND_VAL                                                 <true>
         43        DO_ICALL                                         $22     
         44        ECHO                                                     $22
         45        ECHO                                                     '%0A'
         46        ECHO                                                     '%0A'
   20    47        ECHO                                                     '%24dummy_arr_to_obj%3A+'
         48        ECHO                                                     '%0A'
         49        INIT_FCALL                                               'var_export'
         50        SEND_VAR                                                 !2
         51        SEND_VAL                                                 <true>
         52        DO_ICALL                                         $23     
         53        ECHO                                                     $23
         54        ECHO                                                     '%0A'
         55        ECHO                                                     '%0A'
   21    56        ECHO                                                     '%24object_vars%3A+'
         57        ECHO                                                     '%0A'
         58        INIT_FCALL                                               'var_export'
         59        SEND_VAR                                                 !3
         60        SEND_VAL                                                 <true>
         61        DO_ICALL                                         $24     
         62        ECHO                                                     $24
         63        ECHO                                                     '%0A'
         64        ECHO                                                     '%0A'
   24    65    > > FE_RESET_R                                       $25     !3, ->71
         66    > > FE_FETCH_R                                       ~26     $25, !4, ->71
         67    >   ASSIGN                                                   !5, ~26
   25    68        ASSIGN_OBJ                                               !2, !5
         69        OP_DATA                                                  '1'
   24    70      > JMP                                                      ->66
         71    >   FE_FREE                                                  $25
   37    72      > RETURN                                                   1

Function wp_get_object_vars:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ScIk3
function name:  wp_get_object_vars
number of ops:  12
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
   30     1        INIT_FCALL                                               'array_filter'
   31     2        INIT_FCALL                                               'get_object_vars'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $1      
          5        SEND_VAR                                                 $1
   32     6        DECLARE_LAMBDA_FUNCTION                          ~2      [0]
   34     7        SEND_VAL                                                 ~2
   35     8        SEND_VAL                                                 2
   30     9        DO_ICALL                                         $3      
   35    10      > RETURN                                                   $3
   37    11*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ScIk3
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   RECV                                             !0      
   33     1        INIT_FCALL                                               'ord'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $1      
          4        IS_NOT_IDENTICAL                                 ~2      $1, 0
          5      > RETURN                                                   ~2
   34     6*     > RETURN                                                   null

End of Dynamic Function 0

End of function wp_get_object_vars

Class Dummy: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.62 ms | 1472 KiB | 18 Q