3v4l.org

run code in 300+ PHP versions simultaneously
<?php function object_diff($source, $target) { if (!is_object($source) || !is_object($target) || !($source instanceof $target)) { return null; } $sourceProperties = []; $targetProperties = []; $sourceReflection = new ReflectionObject($source); $targetReflection = new ReflectionObject($target); foreach ($sourceReflection->getProperties() as $sourceProperty) { $sourceProperty->setAccessible(true); $sourceProperties[$sourceProperty->getName()] = $sourceProperty->getValue($source); } foreach ($targetReflection->getProperties() as $targetProperty) { $targetProperty->setAccessible(true); $targetProperties[$targetProperty->getName()] = $targetProperty->getValue($target); } return array_diff($sourceProperties, $targetProperties); } class Foo { private $a, $b, $c; public function __construct($a, $b, $c) { $this->a = $a; $this->b = $b; $this->c = $c; } } $foo1 = new Foo('1', '2', '3'); $foo2 = new Foo('1', '3', '4'); var_dump(object_diff($foo1, $foo2));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ArEJc
function name:  (null)
number of ops:  20
compiled vars:  !0 = $foo1, !1 = $foo2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   NEW                                              $2      'Foo'
          1        SEND_VAL_EX                                              '1'
          2        SEND_VAL_EX                                              '2'
          3        SEND_VAL_EX                                              '3'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $2
   41     6        NEW                                              $5      'Foo'
          7        SEND_VAL_EX                                              '1'
          8        SEND_VAL_EX                                              '3'
          9        SEND_VAL_EX                                              '4'
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !1, $5
   44    12        INIT_FCALL                                               'var_dump'
         13        INIT_FCALL                                               'object_diff'
         14        SEND_VAR                                                 !0
         15        SEND_VAR                                                 !1
         16        DO_FCALL                                      0  $8      
         17        SEND_VAR                                                 $8
         18        DO_ICALL                                                 
         19      > RETURN                                                   1

Function object_diff:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
2 jumps found. (Code = 47) Position 1 = 9, Position 2 = 13
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 15
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
2 jumps found. (Code = 77) Position 1 = 28, Position 2 = 40
Branch analysis from position: 28
2 jumps found. (Code = 78) Position 1 = 29, Position 2 = 40
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
Branch analysis from position: 40
2 jumps found. (Code = 77) Position 1 = 44, Position 2 = 56
Branch analysis from position: 44
2 jumps found. (Code = 78) Position 1 = 45, Position 2 = 56
Branch analysis from position: 45
1 jumps found. (Code = 42) Position 1 = 44
Branch analysis from position: 44
Branch analysis from position: 56
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 56
Branch analysis from position: 40
Branch analysis from position: 13
Branch analysis from position: 8
filename:       /in/ArEJc
function name:  object_diff
number of ops:  63
compiled vars:  !0 = $source, !1 = $target, !2 = $sourceProperties, !3 = $targetProperties, !4 = $sourceReflection, !5 = $targetReflection, !6 = $sourceProperty, !7 = $targetProperty
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        TYPE_CHECK                                  256  ~8      !0
          3        BOOL_NOT                                         ~9      ~8
          4      > JMPNZ_EX                                         ~9      ~9, ->8
          5    >   TYPE_CHECK                                  256  ~10     !1
          6        BOOL_NOT                                         ~11     ~10
          7        BOOL                                             ~9      ~11
          8    > > JMPNZ_EX                                         ~9      ~9, ->13
          9    >   FETCH_CLASS                                   0  $12     !1
         10        INSTANCEOF                                       ~13     !0, $12
         11        BOOL_NOT                                         ~14     ~13
         12        BOOL                                             ~9      ~14
         13    > > JMPZ                                                     ~9, ->15
    7    14    > > RETURN                                                   null
    9    15    >   ASSIGN                                                   !2, <array>
   10    16        ASSIGN                                                   !3, <array>
   11    17        NEW                                              $17     'ReflectionObject'
         18        SEND_VAR_EX                                              !0
         19        DO_FCALL                                      0          
         20        ASSIGN                                                   !4, $17
   12    21        NEW                                              $20     'ReflectionObject'
         22        SEND_VAR_EX                                              !1
         23        DO_FCALL                                      0          
         24        ASSIGN                                                   !5, $20
   13    25        INIT_METHOD_CALL                                         !4, 'getProperties'
         26        DO_FCALL                                      0  $23     
         27      > FE_RESET_R                                       $24     $23, ->40
         28    > > FE_FETCH_R                                               $24, !6, ->40
   15    29    >   INIT_METHOD_CALL                                         !6, 'setAccessible'
         30        SEND_VAL_EX                                              <true>
         31        DO_FCALL                                      0          
   16    32        INIT_METHOD_CALL                                         !6, 'getName'
         33        DO_FCALL                                      0  $26     
         34        INIT_METHOD_CALL                                         !6, 'getValue'
         35        SEND_VAR_EX                                              !0
         36        DO_FCALL                                      0  $28     
         37        ASSIGN_DIM                                               !2, $26
         38        OP_DATA                                                  $28
   13    39      > JMP                                                      ->28
         40    >   FE_FREE                                                  $24
   18    41        INIT_METHOD_CALL                                         !5, 'getProperties'
         42        DO_FCALL                                      0  $29     
         43      > FE_RESET_R                                       $30     $29, ->56
         44    > > FE_FETCH_R                                               $30, !7, ->56
   20    45    >   INIT_METHOD_CALL                                         !7, 'setAccessible'
         46        SEND_VAL_EX                                              <true>
         47        DO_FCALL                                      0          
   21    48        INIT_METHOD_CALL                                         !7, 'getName'
         49        DO_FCALL                                      0  $32     
         50        INIT_METHOD_CALL                                         !7, 'getValue'
         51        SEND_VAR_EX                                              !1
         52        DO_FCALL                                      0  $34     
         53        ASSIGN_DIM                                               !3, $32
         54        OP_DATA                                                  $34
   18    55      > JMP                                                      ->44
         56    >   FE_FREE                                                  $30
   23    57        INIT_FCALL                                               'array_diff'
         58        SEND_VAR                                                 !2
         59        SEND_VAR                                                 !3
         60        DO_ICALL                                         $35     
         61      > RETURN                                                   $35
   24    62*     > RETURN                                                   null

End of function object_diff

Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ArEJc
function name:  __construct
number of ops:  10
compiled vars:  !0 = $a, !1 = $b, !2 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   33     3        ASSIGN_OBJ                                               'a'
          4        OP_DATA                                                  !0
   34     5        ASSIGN_OBJ                                               'b'
          6        OP_DATA                                                  !1
   35     7        ASSIGN_OBJ                                               'c'
          8        OP_DATA                                                  !2
   36     9      > RETURN                                                   null

End of function __construct

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.42 ms | 1398 KiB | 18 Q