3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ListResult extends ArrayObject { protected $response; public function __construct($response) { parent::__construct($response['list']); $this->response = $response; // typically you'd want to keep the original response } } $response = [ 'list' => ['a', 'b'] ]; $result = new ListResult($response); foreach($result as $k => $v){ echo "$k=>$v\n"; } echo "\n\n0=>{$result[0]}";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 14
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 14
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/PvFLQ
function name:  (null)
number of ops:  20
compiled vars:  !0 = $response, !1 = $result, !2 = $v, !3 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   ASSIGN                                                   !0, <array>
   18     1        NEW                                              $5      'ListResult'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $5
   20     5      > FE_RESET_R                                       $8      !1, ->14
          6    > > FE_FETCH_R                                       ~9      $8, !2, ->14
          7    >   ASSIGN                                                   !3, ~9
   21     8        ROPE_INIT                                     4  ~12     !3
          9        ROPE_ADD                                      1  ~12     ~12, '%3D%3E'
         10        ROPE_ADD                                      2  ~12     ~12, !2
         11        ROPE_END                                      3  ~11     ~12, '%0A'
         12        ECHO                                                     ~11
   20    13      > JMP                                                      ->6
         14    >   FE_FREE                                                  $8
   24    15        NOP                                                      
         16        FETCH_DIM_R                                      ~14     !1, 0
         17        FAST_CONCAT                                      ~15     '%0A%0A0%3D%3E', ~14
         18        ECHO                                                     ~15
         19      > RETURN                                                   1

Class ListResult:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PvFLQ
function name:  __construct
number of ops:  9
compiled vars:  !0 = $response
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    8     1        INIT_STATIC_METHOD_CALL                                  
          2        CHECK_FUNC_ARG                                           
          3        FETCH_DIM_FUNC_ARG                               $1      !0, 'list'
          4        SEND_FUNC_ARG                                            $1
          5        DO_FCALL                                      0          
   10     6        ASSIGN_OBJ                                               'response'
          7        OP_DATA                                                  !0
   11     8      > RETURN                                                   null

End of function __construct

End of class ListResult.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.56 ms | 1424 KiB | 13 Q