3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Queue { private $arr = []; public function enqueue(&$e) { \array_unshift($this->arr, [&$e]); } public function &dequeue() { $x =& \array_pop($this->arr)[0]; return $x; } public function is_empty() { return empty($this->arr); } } $q = new Queue(); $a = [42, 124, 35]; $q->enqueue($a); $a[] = 1337; $b = $q->dequeue(); $b[] = 12345; var_dump($a); var_dump($b);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4XKSb
function name:  (null)
number of ops:  21
compiled vars:  !0 = $q, !1 = $a, !2 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   NEW                                              $3      'Queue'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   29     3        ASSIGN                                                   !1, <array>
   30     4        INIT_METHOD_CALL                                         !0, 'enqueue'
          5        SEND_VAR_EX                                              !1
          6        DO_FCALL                                      0          
   32     7        ASSIGN_DIM                                               !1
          8        OP_DATA                                                  1337
   33     9        INIT_METHOD_CALL                                         !0, 'dequeue'
         10        DO_FCALL                                      0  $9      
         11        ASSIGN                                                   !2, $9
   35    12        ASSIGN_DIM                                               !2
         13        OP_DATA                                                  12345
   37    14        INIT_FCALL                                               'var_dump'
         15        SEND_VAR                                                 !1
         16        DO_ICALL                                                 
   38    17        INIT_FCALL                                               'var_dump'
         18        SEND_VAR                                                 !2
         19        DO_ICALL                                                 
         20      > RETURN                                                   1

Class Queue:
Function enqueue:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4XKSb
function name:  enqueue
number of ops:  8
compiled vars:  !0 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
   10     1        INIT_FCALL                                               'array_unshift'
          2        FETCH_OBJ_W                                      $1      'arr'
          3        SEND_REF                                                 $1
          4        INIT_ARRAY                                       ~2      !0
          5        SEND_VAL                                                 ~2
          6        DO_ICALL                                                 
   11     7      > RETURN                                                   null

End of function enqueue

Function dequeue:
Finding entry points
Branch analysis from position: 0
Return found
filename:       /in/4XKSb
function name:  dequeue
number of ops:  9
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   INIT_FCALL                                               'array_pop'
          1        FETCH_OBJ_W                                      $1      'arr'
          2        SEND_REF                                                 $1
          3        DO_ICALL                                         $2      
          4        SEPARATE                                         $2      $2
          5        FETCH_DIM_W                                      $3      $2, 0
          6        ASSIGN_REF                                               !0, $3
   16     7      > RETURN_BY_REF                                            !0
   17     8*     > RETURN_BY_REF                                            null

End of function dequeue

Function is_empty:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4XKSb
function name:  is_empty
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   ISSET_ISEMPTY_PROP_OBJ                           ~0      'arr'
          1      > RETURN                                                   ~0
   22     2*     > RETURN                                                   null

End of function is_empty

End of class Queue.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.3 ms | 1405 KiB | 19 Q