3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Foo { public $bar; public $baz; public $taz; } // please note that this API has a signature of `object $object` - any object allowed. function unsetProperties($object) { // we ignore inheritance and private properties for simplicity return array_diff( array_map( function (\ReflectionProperty $p) : string { return $p->getName(); }, (new ReflectionClass($object))->getProperties() ), array_keys((array) $object) ); } var_dump(unsetProperties(new Foo)); $foo = new Foo; unset($foo->baz); var_dump(unsetProperties($foo));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Tj0GH
function name:  (null)
number of ops:  19
compiled vars:  !0 = $foo
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   24     0  E >   INIT_FCALL                                                   'var_dump'
          1        INIT_FCALL                                                   'unsetproperties'
          2        NEW                                                  $1      'Foo'
          3        DO_FCALL                                          0          
          4        SEND_VAR                                                     $1
          5        DO_FCALL                                          0  $3      
          6        SEND_VAR                                                     $3
          7        DO_ICALL                                                     
   26     8        NEW                                                  $5      'Foo'
          9        DO_FCALL                                          0          
         10        ASSIGN                                                       !0, $5
   28    11        UNSET_OBJ                                                    !0, 'baz'
   30    12        INIT_FCALL                                                   'var_dump'
         13        INIT_FCALL                                                   'unsetproperties'
         14        SEND_VAR                                                     !0
         15        DO_FCALL                                          0  $8      
         16        SEND_VAR                                                     $8
         17        DO_ICALL                                                     
         18      > RETURN                                                       1

Function unsetproperties:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Tj0GH
function name:  unsetProperties
number of ops:  21
compiled vars:  !0 = $object
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   RECV                                                 !0      
   13     1        INIT_FCALL                                                   'array_diff'
   14     2        INIT_FCALL                                                   'array_map'
   15     3        DECLARE_LAMBDA_FUNCTION                              ~1      [0]
   17     4        SEND_VAL                                                     ~1
   18     5        NEW                                                  $2      'ReflectionClass'
          6        SEND_VAR_EX                                                  !0
          7        DO_FCALL                                          0          
          8        INIT_METHOD_CALL                                             $2, 'getProperties'
          9        DO_FCALL                                          0  $4      
         10        SEND_VAR                                                     $4
   14    11        DO_ICALL                                             $5      
   18    12        SEND_VAR                                                     $5
   20    13        INIT_FCALL                                                   'array_keys'
         14        CAST                                              7  ~6      !0
         15        SEND_VAL                                                     ~6
         16        DO_ICALL                                             $7      
         17        SEND_VAR                                                     $7
   13    18        DO_ICALL                                             $8      
   20    19      > RETURN                                                       $8
   22    20*     > 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/Tj0GH
function name:  {closure:unsetProperties():15}
number of ops:  7
compiled vars:  !0 = $p
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   15     0  E >   RECV                                                 !0      
   16     1        INIT_METHOD_CALL                                             !0, 'getName'
          2        DO_FCALL                                          0  $1      
          3        VERIFY_RETURN_TYPE                                           $1
          4      > RETURN                                                       $1
   17     5*       VERIFY_RETURN_TYPE                                           
          6*     > RETURN                                                       null

End of Dynamic Function 0

End of function unsetproperties

Class Foo: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
161.18 ms | 2191 KiB | 19 Q