3v4l.org

run code in 300+ PHP versions simultaneously
<?php $iterator = new ArrayIterator([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/Shrqg
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 >   NEW                                              $2      'ArrayIterator'
          1        NEW                                              $3      'Test'
          2        SEND_VAL_EX                                              10
          3        DO_FCALL                                      0          
          4        INIT_ARRAY                                       ~5      $3
          5        NEW                                              $6      'Test'
          6        SEND_VAL_EX                                              1
          7        DO_FCALL                                      0          
          8        ADD_ARRAY_ELEMENT                                ~5      $6
          9        NEW                                              $8      'Test'
         10        SEND_VAL_EX                                              5
         11        DO_FCALL                                      0          
         12        ADD_ARRAY_ELEMENT                                ~5      $8
         13        SEND_VAL_EX                                              ~5
         14        DO_FCALL                                      0          
         15        ASSIGN                                                   !0, $2
    5    16        INIT_METHOD_CALL                                         !0, 'uasort'
    6    17        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FShrqg%3A6%240'
    8    18        SEND_VAL_EX                                              ~12
         19        DO_FCALL                                      0          
   11    20        NEW                                              $14     'ArrayCollection'
         21        INIT_FCALL                                               'iterator_to_array'
         22        SEND_VAR                                                 !0
         23        DO_ICALL                                         $15     
         24        SEND_VAR_NO_REF_EX                                       $15
         25        DO_FCALL                                      0          
         26        ASSIGN                                                   !1, $14
   13    27        INIT_FCALL                                               'var_dump'
         28        INIT_METHOD_CALL                                         !1, 'getValues'
         29        DO_FCALL                                      0  $18     
         30        SEND_VAR                                                 $18
         31        DO_ICALL                                                 
         32      > EXIT                                                     
   28    33*     > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FShrqg%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/Shrqg
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%2FShrqg%3A6%240

Class Test:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Shrqg
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/Shrqg
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:
171.46 ms | 1400 KiB | 17 Q