3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Domain { protected $foo; protected $bar; protected $baz; public function setFoo($foo) { $this->foo = $foo; return $this; } public function getFoo() { return $this->foo; } public function setBar($bar) { $this->bar = $bar; return $this; } public function getBar() { return $this->bar; } public function setBaz($baz) { $this->baz = $baz; return $this; } public function getBaz() { return $this->baz; } } class Dto { public $foo; public $baz; } $domainObject = new Domain(); $domainObject ->setFoo('foo') ->setBar('bar') ->setBaz('baz') ; $dtoFiller = function($domainObject, $dto) { $fetcher = function($object) { $getter = function() { return get_object_vars($this); }; return $getter->bindTo($object, $object); }; $transmitter = function(\Closure $fetcher, $dto) { foreach ($fetcher() as $property => $value) { if (property_exists($dto, $property)) { $dto->$property = $value; } } return $dto; }; return $transmitter($fetcher($domainObject), $dto); }; var_dump($dtoFiller($domainObject, new Dto()));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uqemp
function name:  (null)
number of ops:  24
compiled vars:  !0 = $domainObject, !1 = $dtoFiller
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   48     0  E >   NEW                                              $2      'Domain'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   50     3        INIT_METHOD_CALL                                         !0, 'setFoo'
          4        SEND_VAL_EX                                              'foo'
          5        DO_FCALL                                      0  $5      
   51     6        INIT_METHOD_CALL                                         $5, 'setBar'
          7        SEND_VAL_EX                                              'bar'
          8        DO_FCALL                                      0  $6      
   52     9        INIT_METHOD_CALL                                         $6, 'setBaz'
         10        SEND_VAL_EX                                              'baz'
         11        DO_FCALL                                      0          
   55    12        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fuqemp%3A55%240'
         13        ASSIGN                                                   !1, ~8
   78    14        INIT_FCALL                                               'var_dump'
         15        INIT_DYNAMIC_CALL                                        !1
         16        SEND_VAR_EX                                              !0
         17        NEW                                              $10     'Dto'
         18        DO_FCALL                                      0          
         19        SEND_VAR_NO_REF_EX                                       $10
         20        DO_FCALL                                      0  $12     
         21        SEND_VAR                                                 $12
         22        DO_ICALL                                                 
         23      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2Fuqemp%3A55%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uqemp
function name:  {closure}
number of ops:  15
compiled vars:  !0 = $domainObject, !1 = $dto, !2 = $fetcher, !3 = $transmitter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   55     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   57     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fuqemp%3A57%241'
          3        ASSIGN                                                   !2, ~4
   65     4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fuqemp%3A65%243'
          5        ASSIGN                                                   !3, ~6
   75     6        INIT_DYNAMIC_CALL                                        !3
          7        INIT_DYNAMIC_CALL                                        !2
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0  $8      
         10        SEND_VAR_NO_REF_EX                                       $8
         11        SEND_VAR_EX                                              !1
         12        DO_FCALL                                      0  $9      
         13      > RETURN                                                   $9
   76    14*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fuqemp%3A55%240

Function %00%7Bclosure%7D%2Fin%2Fuqemp%3A57%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uqemp
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $object, !1 = $getter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   57     0  E >   RECV                                             !0      
   58     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fuqemp%3A58%242'
          2        ASSIGN                                                   !1, ~2
   62     3        INIT_METHOD_CALL                                         !1, 'bindTo'
          4        SEND_VAR_EX                                              !0
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0  $4      
          7      > RETURN                                                   $4
   63     8*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fuqemp%3A57%241

Function %00%7Bclosure%7D%2Fin%2Fuqemp%3A58%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uqemp
function name:  {closure}
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   59     0  E >   INIT_FCALL                                               'get_object_vars'
          1        FETCH_THIS                                       ~0      
          2        SEND_VAL                                                 ~0
          3        DO_ICALL                                         $1      
          4      > RETURN                                                   $1
   60     5*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fuqemp%3A58%242

Function %00%7Bclosure%7D%2Fin%2Fuqemp%3A65%243:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 15
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 15
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 14
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 14
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/uqemp
function name:  {closure}
number of ops:  18
compiled vars:  !0 = $fetcher, !1 = $dto, !2 = $value, !3 = $property
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   65     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   66     2        INIT_DYNAMIC_CALL                                        !0
          3        DO_FCALL                                      0  $4      
          4      > FE_RESET_R                                       $5      $4, ->15
          5    > > FE_FETCH_R                                       ~6      $5, !2, ->15
          6    >   ASSIGN                                                   !3, ~6
   67     7        INIT_FCALL                                               'property_exists'
          8        SEND_VAR                                                 !1
          9        SEND_VAR                                                 !3
         10        DO_ICALL                                         $8      
         11      > JMPZ                                                     $8, ->14
   68    12    >   ASSIGN_OBJ                                               !1, !3
         13        OP_DATA                                                  !2
   66    14    > > JMP                                                      ->5
         15    >   FE_FREE                                                  $5
   72    16      > RETURN                                                   !1
   73    17*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fuqemp%3A65%243

Class Domain:
Function setfoo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uqemp
function name:  setFoo
number of ops:  6
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   11     1        ASSIGN_OBJ                                               'foo'
          2        OP_DATA                                                  !0
   13     3        FETCH_THIS                                       ~2      
          4      > RETURN                                                   ~2
   14     5*     > RETURN                                                   null

End of function setfoo

Function getfoo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uqemp
function name:  getFoo
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   FETCH_OBJ_R                                      ~0      'foo'
          1      > RETURN                                                   ~0
   18     2*     > RETURN                                                   null

End of function getfoo

Function setbar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uqemp
function name:  setBar
number of ops:  6
compiled vars:  !0 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   22     1        ASSIGN_OBJ                                               'bar'
          2        OP_DATA                                                  !0
   24     3        FETCH_THIS                                       ~2      
          4      > RETURN                                                   ~2
   25     5*     > RETURN                                                   null

End of function setbar

Function getbar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uqemp
function name:  getBar
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   FETCH_OBJ_R                                      ~0      'bar'
          1      > RETURN                                                   ~0
   30     2*     > RETURN                                                   null

End of function getbar

Function setbaz:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uqemp
function name:  setBaz
number of ops:  6
compiled vars:  !0 = $baz
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   RECV                                             !0      
   33     1        ASSIGN_OBJ                                               'baz'
          2        OP_DATA                                                  !0
   35     3        FETCH_THIS                                       ~2      
          4      > RETURN                                                   ~2
   36     5*     > RETURN                                                   null

End of function setbaz

Function getbaz:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uqemp
function name:  getBaz
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   FETCH_OBJ_R                                      ~0      'baz'
          1      > RETURN                                                   ~0
   40     2*     > RETURN                                                   null

End of function getbaz

End of class Domain.

Class Dto: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.52 ms | 1408 KiB | 19 Q