3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { protected $_array; protected $_first; public function __construct(array $array) { foreach ($array as $i) is_int($i); $this->_first = current($array); $this->_array = $array; } public function getArray() { return $this->_array; } public function getFirst() { return current($this->_array); } public function getFirstName() { return key($this->_array); } } $array = [1, 2, 3]; $a = new A($array); foreach ($a->getArray() as $i) echo $i . PHP_EOL; echo $a->getFirst(); echo "\n--------\n"; $array = $a->getArray(); foreach ($array as $i) echo $i . PHP_EOL; echo $a->getFirst();
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 12
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 12
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 12
2 jumps found. (Code = 77) Position 1 = 21, Position 2 = 25
Branch analysis from position: 21
2 jumps found. (Code = 78) Position 1 = 22, Position 2 = 25
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
Branch analysis from position: 12
filename:       /in/jH4pM
function name:  (null)
number of ops:  30
compiled vars:  !0 = $array, !1 = $a, !2 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   ASSIGN                                                   !0, <array>
   35     1        NEW                                              $4      'A'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $4
   37     5        INIT_METHOD_CALL                                         !1, 'getArray'
          6        DO_FCALL                                      0  $7      
          7      > FE_RESET_R                                       $8      $7, ->12
          8    > > FE_FETCH_R                                               $8, !2, ->12
   38     9    >   CONCAT                                           ~9      !2, '%0A'
         10        ECHO                                                     ~9
   37    11      > JMP                                                      ->8
         12    >   FE_FREE                                                  $8
   40    13        INIT_METHOD_CALL                                         !1, 'getFirst'
         14        DO_FCALL                                      0  $10     
         15        ECHO                                                     $10
   42    16        ECHO                                                     '%0A--------%0A'
   44    17        INIT_METHOD_CALL                                         !1, 'getArray'
         18        DO_FCALL                                      0  $11     
         19        ASSIGN                                                   !0, $11
   45    20      > FE_RESET_R                                       $13     !0, ->25
         21    > > FE_FETCH_R                                               $13, !2, ->25
   46    22    >   CONCAT                                           ~14     !2, '%0A'
         23        ECHO                                                     ~14
   45    24      > JMP                                                      ->21
         25    >   FE_FREE                                                  $13
   48    26        INIT_METHOD_CALL                                         !1, 'getFirst'
         27        DO_FCALL                                      0  $15     
         28        ECHO                                                     $15
         29      > RETURN                                                   1

Class A:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 6
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
filename:       /in/jH4pM
function name:  __construct
number of ops:  15
compiled vars:  !0 = $array, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
   10     1      > FE_RESET_R                                       $2      !0, ->6
          2    > > FE_FETCH_R                                               $2, !1, ->6
   11     3    >   TYPE_CHECK                                   16  ~3      !1
          4        FREE                                                     ~3
   10     5      > JMP                                                      ->2
          6    >   FE_FREE                                                  $2
   13     7        INIT_FCALL                                               'current'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $5      
         10        ASSIGN_OBJ                                               '_first'
         11        OP_DATA                                                  $5
   14    12        ASSIGN_OBJ                                               '_array'
         13        OP_DATA                                                  !0
   15    14      > RETURN                                                   null

End of function __construct

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

End of function getarray

Function getfirst:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jH4pM
function name:  getFirst
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   INIT_FCALL                                               'current'
          1        FETCH_OBJ_R                                      ~0      '_array'
          2        SEND_VAL                                                 ~0
          3        DO_ICALL                                         $1      
          4      > RETURN                                                   $1
   25     5*     > RETURN                                                   null

End of function getfirst

Function getfirstname:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jH4pM
function name:  getFirstName
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   INIT_FCALL                                               'key'
          1        FETCH_OBJ_R                                      ~0      '_array'
          2        SEND_VAL                                                 ~0
          3        DO_ICALL                                         $1      
          4      > RETURN                                                   $1
   30     5*     > RETURN                                                   null

End of function getfirstname

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.59 ms | 1392 KiB | 17 Q