3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Wagon { private $name; public function setName($name){ $this->name = $name; } public function getName(){ return $this->name; } } class Train { public function __construct(array $wagons) { $this->wagons = (function (Wagon $wagons) { return $wagons->getName(); })($wagons); } } $vagon = new Wagon(); $vagon->setName('vagon 1'); var_dump(new Train([$vagon]));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/h9X1j
function name:  (null)
number of ops:  14
compiled vars:  !0 = $vagon
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   NEW                                              $1      'Wagon'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   27     3        INIT_METHOD_CALL                                         !0, 'setName'
          4        SEND_VAL_EX                                              'vagon+1'
          5        DO_FCALL                                      0          
   29     6        INIT_FCALL                                               'var_dump'
          7        NEW                                              $5      'Train'
          8        INIT_ARRAY                                       ~6      !0
          9        SEND_VAL_EX                                              ~6
         10        DO_FCALL                                      0          
         11        SEND_VAR                                                 $5
         12        DO_ICALL                                                 
         13      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2Fh9X1j%3A19%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/h9X1j
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $wagons
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
   20     1        INIT_METHOD_CALL                                         !0, 'getName'
          2        DO_FCALL                                      0  $1      
          3      > RETURN                                                   $1
   21     4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fh9X1j%3A19%240

Class Wagon:
Function setname:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/h9X1j
function name:  setName
number of ops:  4
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        ASSIGN_OBJ                                               'name'
          2        OP_DATA                                                  !0
    8     3      > RETURN                                                   null

End of function setname

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

End of function getname

End of class Wagon.

Class Train:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/h9X1j
function name:  __construct
number of ops:  8
compiled vars:  !0 = $wagons
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   19     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fh9X1j%3A19%240'
   21     2        INIT_DYNAMIC_CALL                                        ~2
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $3      
   19     5        ASSIGN_OBJ                                               'wagons'
   21     6        OP_DATA                                                  $3
   22     7      > RETURN                                                   null

End of function __construct

End of class Train.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.6 ms | 1400 KiB | 15 Q