3v4l.org

run code in 300+ PHP versions simultaneously
<?php $iterator = array_to_iterator([new Test(10), new Test(1), new Test(5)]); $iterator->uasort( function ($first, $second) { return $first->getSortOrder() < $second->getSortOrder() ? -1 : 1; } ); $collection = new ArrayCollection(iterator_to_array($iterator)); var_dump($collection->getValues()); die; class Test { private $orderNr; function __construct($orderNr) { $this->orderNr = $orderNr; } public function getSortOrder() { return $this->orderNr; } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/8NV65
function name:  (null)
number of ops:  34
compiled vars:  !0 = $iterator, !1 = $collection
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL_BY_NAME                                       'array_to_iterator'
          1        NEW                                              $2      'Test'
          2        SEND_VAL_EX                                              10
          3        DO_FCALL                                      0          
          4        INIT_ARRAY                                       ~4      $2
          5        NEW                                              $5      'Test'
          6        SEND_VAL_EX                                              1
          7        DO_FCALL                                      0          
          8        ADD_ARRAY_ELEMENT                                ~4      $5
          9        NEW                                              $7      'Test'
         10        SEND_VAL_EX                                              5
         11        DO_FCALL                                      0          
         12        ADD_ARRAY_ELEMENT                                ~4      $7
         13        SEND_VAL_EX                                              ~4
         14        DO_FCALL                                      0  $9      
         15        ASSIGN                                                   !0, $9
    5    16        INIT_METHOD_CALL                                         !0, 'uasort'
    6    17        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F8NV65%3A6%240'
    8    18        SEND_VAL_EX                                              ~11
         19        DO_FCALL                                      0          
   11    20        NEW                                              $13     'ArrayCollection'
         21        INIT_FCALL                                               'iterator_to_array'
         22        SEND_VAR                                                 !0
         23        DO_ICALL                                         $14     
         24        SEND_VAR_NO_REF_EX                                       $14
         25        DO_FCALL                                      0          
         26        ASSIGN                                                   !1, $13
   13    27        INIT_FCALL                                               'var_dump'
         28        INIT_METHOD_CALL                                         !1, 'getValues'
         29        DO_FCALL                                      0  $17     
         30        SEND_VAR                                                 $17
         31        DO_ICALL                                                 
         32      > EXIT                                                     
   28    33*     > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F8NV65%3A6%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8NV65
function name:  {closure}
number of ops:  13
compiled vars:  !0 = $first, !1 = $second
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    7     2        INIT_METHOD_CALL                                         !0, 'getSortOrder'
          3        DO_FCALL                                      0  $2      
          4        INIT_METHOD_CALL                                         !1, 'getSortOrder'
          5        DO_FCALL                                      0  $3      
          6        IS_SMALLER                                               $2, $3
          7      > JMPZ                                                     ~4, ->10
          8    >   QM_ASSIGN                                        ~5      -1
          9      > JMP                                                      ->11
         10    >   QM_ASSIGN                                        ~5      1
         11    > > RETURN                                                   ~5
    8    12*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F8NV65%3A6%240

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

End of function __construct

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

End of function getsortorder

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.63 ms | 1400 KiB | 17 Q