3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Carro implements IteratorAggregate { private Peca $motor; private Peca $pneus; private Peca $amortecedor; public function __construct( Peca $motor, Peca $pneus, Peca $amortecedor ) { $this->motor = $motor; $this->pneus = $pneus; $this->amortecedor = $amortecedor; } public function __get($atributo) { return $this->$atributo; } public function __set($atributo, $valor) { $this->$atributo = $valor; } public function getIterator() { return new \ArrayIterator([ $this->motor, $this->pneus, $this->amortecedor, ]); } } class Peca { private string $marca; private string $modelo; private float $preco; public function __construct( ?string $marca, string $modelo, float $preco ) { $this->marca = $marca; $this->modelo = $modelo; $this->preco = $preco; } public function __get($atributo) { return $this->$atributo ; } public function __set($atributo, $valor) { $this->$atributo = $valor; } } $carro = new Carro( new Peca('Teste', "1.8", 15000.00), new Peca("Pirelli", "P7", 500.00), new Peca("Cofap", "ar", 1000.00) ); foreach($carro as $peca){ $peca->marca = "VW"; } var_dump($carro);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 23, Position 2 = 27
Branch analysis from position: 23
2 jumps found. (Code = 78) Position 1 = 24, Position 2 = 27
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/4HmUZ
function name:  (null)
number of ops:  32
compiled vars:  !0 = $carro, !1 = $peca
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'carro'
   67     1        NEW                                              $2      'Carro'
   68     2        NEW                                              $3      'Peca'
          3        SEND_VAL_EX                                              'Teste'
          4        SEND_VAL_EX                                              '1.8'
          5        SEND_VAL_EX                                              15000
          6        DO_FCALL                                      0          
          7        SEND_VAR_NO_REF_EX                                       $3
   69     8        NEW                                              $5      'Peca'
          9        SEND_VAL_EX                                              'Pirelli'
         10        SEND_VAL_EX                                              'P7'
         11        SEND_VAL_EX                                              500
         12        DO_FCALL                                      0          
         13        SEND_VAR_NO_REF_EX                                       $5
   70    14        NEW                                              $7      'Peca'
         15        SEND_VAL_EX                                              'Cofap'
         16        SEND_VAL_EX                                              'ar'
         17        SEND_VAL_EX                                              1000
         18        DO_FCALL                                      0          
         19        SEND_VAR_NO_REF_EX                                       $7
   67    20        DO_FCALL                                      0          
         21        ASSIGN                                                   !0, $2
   73    22      > FE_RESET_R                                       $11     !0, ->27
         23    > > FE_FETCH_R                                               $11, !1, ->27
   74    24    >   ASSIGN_OBJ                                               !1, 'marca'
         25        OP_DATA                                                  'VW'
   73    26      > JMP                                                      ->23
         27    >   FE_FREE                                                  $11
   77    28        INIT_FCALL                                               'var_dump'
         29        SEND_VAR                                                 !0
         30        DO_ICALL                                                 
         31      > RETURN                                                   1

Class Carro:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4HmUZ
function name:  __construct
number of ops:  10
compiled vars:  !0 = $motor, !1 = $pneus, !2 = $amortecedor
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   14     3        ASSIGN_OBJ                                               'motor'
          4        OP_DATA                                                  !0
   15     5        ASSIGN_OBJ                                               'pneus'
          6        OP_DATA                                                  !1
   16     7        ASSIGN_OBJ                                               'amortecedor'
          8        OP_DATA                                                  !2
   17     9      > RETURN                                                   null

End of function __construct

Function __get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4HmUZ
function name:  __get
number of ops:  4
compiled vars:  !0 = $atributo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
   21     1        FETCH_OBJ_R                                      ~1      !0
          2      > RETURN                                                   ~1
   22     3*     > RETURN                                                   null

End of function __get

Function __set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4HmUZ
function name:  __set
number of ops:  5
compiled vars:  !0 = $atributo, !1 = $valor
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   26     2        ASSIGN_OBJ                                               !0
          3        OP_DATA                                                  !1
   27     4      > RETURN                                                   null

End of function __set

Function getiterator:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4HmUZ
function name:  getIterator
number of ops:  11
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   NEW                                              $0      'ArrayIterator'
   32     1        FETCH_OBJ_R                                      ~1      'motor'
          2        INIT_ARRAY                                       ~2      ~1
   33     3        FETCH_OBJ_R                                      ~3      'pneus'
          4        ADD_ARRAY_ELEMENT                                ~2      ~3
   34     5        FETCH_OBJ_R                                      ~4      'amortecedor'
          6        ADD_ARRAY_ELEMENT                                ~2      ~4
          7        SEND_VAL_EX                                              ~2
   31     8        DO_FCALL                                      0          
   34     9      > RETURN                                                   $0
   36    10*     > RETURN                                                   null

End of function getiterator

End of class Carro.

Class Peca:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4HmUZ
function name:  __construct
number of ops:  10
compiled vars:  !0 = $marca, !1 = $modelo, !2 = $preco
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   50     3        ASSIGN_OBJ                                               'marca'
          4        OP_DATA                                                  !0
   51     5        ASSIGN_OBJ                                               'modelo'
          6        OP_DATA                                                  !1
   52     7        ASSIGN_OBJ                                               'preco'
          8        OP_DATA                                                  !2
   53     9      > RETURN                                                   null

End of function __construct

Function __get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4HmUZ
function name:  __get
number of ops:  4
compiled vars:  !0 = $atributo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   55     0  E >   RECV                                             !0      
   57     1        FETCH_OBJ_R                                      ~1      !0
          2      > RETURN                                                   ~1
   58     3*     > RETURN                                                   null

End of function __get

Function __set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4HmUZ
function name:  __set
number of ops:  5
compiled vars:  !0 = $atributo, !1 = $valor
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   60     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   62     2        ASSIGN_OBJ                                               !0
          3        OP_DATA                                                  !1
   63     4      > RETURN                                                   null

End of function __set

End of class Peca.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
136.54 ms | 1007 KiB | 14 Q