3v4l.org

run code in 300+ PHP versions simultaneously
<?php class User { private $id; private $username; } class MySqlUserMapper { public function fetchByUsername($username) { $row = array( 'id' => '1', 'username' => $username, ); return $this->hydrate(new User, $row); } private function hydrate(User $user, array $row) { static $hydrator; if (!$hydrator) { $hydrator = function (array $row) { var_dump($this); foreach ($row as $k => $v) { $this->{$k} = $v; } }; } $hydrator = $hydrator->bindTo($user, $user); $hydrator($row); } } $mapper = new MySqlUserMapper(); var_dump($mapper->fetchByUsername('mabe'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LOrpT
function name:  (null)
number of ops:  10
compiled vars:  !0 = $mapper
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   NEW                                              $1      'MySqlUserMapper'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   35     3        INIT_FCALL                                               'var_dump'
          4        INIT_METHOD_CALL                                         !0, 'fetchByUsername'
          5        SEND_VAL_EX                                              'mabe'
          6        DO_FCALL                                      0  $4      
          7        SEND_VAR                                                 $4
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FLOrpT%3A21%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/LOrpT
function name:  {closure}
number of ops:  14
compiled vars:  !0 = $row, !1 = $v, !2 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
   22     1        INIT_FCALL                                               'var_dump'
          2        FETCH_THIS                                       ~3      
          3        SEND_VAL                                                 ~3
          4        DO_ICALL                                                 
   23     5      > FE_RESET_R                                       $5      !0, ->12
          6    > > FE_FETCH_R                                       ~6      $5, !1, ->12
          7    >   ASSIGN                                                   !2, ~6
   24     8        FETCH_THIS                                       $8      
          9        ASSIGN_OBJ                                               $8, !2
         10        OP_DATA                                                  !1
   23    11      > JMP                                                      ->6
         12    >   FE_FREE                                                  $5
   26    13      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FLOrpT%3A21%240

Class User: [no user functions]
Class MySqlUserMapper:
Function fetchbyusername:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LOrpT
function name:  fetchByUsername
number of ops:  12
compiled vars:  !0 = $username, !1 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   11     1        INIT_ARRAY                                       ~2      '1', 'id'
   12     2        ADD_ARRAY_ELEMENT                                ~2      !0, 'username'
   10     3        ASSIGN                                                   !1, ~2
   14     4        INIT_METHOD_CALL                                         'hydrate'
          5        NEW                                              $4      'User'
          6        DO_FCALL                                      0          
          7        SEND_VAR_NO_REF_EX                                       $4
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0  $6      
         10      > RETURN                                                   $6
   15    11*     > RETURN                                                   null

End of function fetchbyusername

Function hydrate:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/LOrpT
function name:  hydrate
number of ops:  16
compiled vars:  !0 = $user, !1 = $row, !2 = $hydrator
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   18     2        BIND_STATIC                                              !2
   20     3        BOOL_NOT                                         ~3      !2
          4      > JMPZ                                                     ~3, ->7
   21     5    >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FLOrpT%3A21%240'
          6        ASSIGN                                                   !2, ~4
   29     7    >   INIT_METHOD_CALL                                         !2, 'bindTo'
          8        SEND_VAR_EX                                              !0
          9        SEND_VAR_EX                                              !0
         10        DO_FCALL                                      0  $6      
         11        ASSIGN                                                   !2, $6
   30    12        INIT_DYNAMIC_CALL                                        !2
         13        SEND_VAR_EX                                              !1
         14        DO_FCALL                                      0          
   31    15      > RETURN                                                   null

End of function hydrate

End of class MySqlUserMapper.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.38 ms | 1392 KiB | 15 Q