3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { protected $bar; } class FooHydrator extends Foo { public function gen() { return function (array $row) { var_dump($this); foreach ($row as $k => $v) { $this->{$k} = $v; } }; } } $row = array( 'bar' => 1 ); $o = new Foo; $hydrator = new FooHydrator; $hydrator = $hydrator->gen(); $hydrator = $hydrator->bindTo($o, 'Foo'); $hydrator($row); var_dump($o);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EU8i9
function name:  (null)
number of ops:  22
compiled vars:  !0 = $row, !1 = $o, !2 = $hydrator
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   ASSIGN                                                   !0, <array>
   23     1        NEW                                              $4      'Foo'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $4
   24     4        NEW                                              $7      'FooHydrator'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !2, $7
   25     7        INIT_METHOD_CALL                                         !2, 'gen'
          8        DO_FCALL                                      0  $10     
          9        ASSIGN                                                   !2, $10
   26    10        INIT_METHOD_CALL                                         !2, 'bindTo'
         11        SEND_VAR_EX                                              !1
         12        SEND_VAL_EX                                              'Foo'
         13        DO_FCALL                                      0  $12     
         14        ASSIGN                                                   !2, $12
   27    15        INIT_DYNAMIC_CALL                                        !2
         16        SEND_VAR_EX                                              !0
         17        DO_FCALL                                      0          
   29    18        INIT_FCALL                                               'var_dump'
         19        SEND_VAR                                                 !1
         20        DO_ICALL                                                 
         21      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FEU8i9%3A9%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 12
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 12
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/EU8i9
function name:  {closure}
number of ops:  14
compiled vars:  !0 = $row, !1 = $v, !2 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   10     1        INIT_FCALL                                               'var_dump'
          2        FETCH_THIS                                       ~3      
          3        SEND_VAL                                                 ~3
          4        DO_ICALL                                                 
   11     5      > FE_RESET_R                                       $5      !0, ->12
          6    > > FE_FETCH_R                                       ~6      $5, !1, ->12
          7    >   ASSIGN                                                   !2, ~6
   12     8        FETCH_THIS                                       $8      
          9        ASSIGN_OBJ                                               $8, !2
         10        OP_DATA                                                  !1
   11    11      > JMP                                                      ->6
         12    >   FE_FREE                                                  $5
   14    13      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FEU8i9%3A9%240

Class Foo: [no user functions]
Class FooHydrator:
Function gen:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EU8i9
function name:  gen
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FEU8i9%3A9%240'
   14     1      > RETURN                                                   ~0
   15     2*     > RETURN                                                   null

End of function gen

End of class FooHydrator.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.57 ms | 1400 KiB | 15 Q