3v4l.org

run code in 300+ PHP versions simultaneously
<?php class RouteCollection implements \IteratorAggregate { /** * @var Route[] */ public $routes = array(); /** * Gets the current RouteCollection as an Iterator that includes all routes. * * It implements \IteratorAggregate. * * @see all() * * @return \ArrayIterator An \ArrayIterator object for iterating over routes */ public function getIterator() { return new \ArrayIterator($this->routes); } } $c = new RouteCollection(); $o = new stdClass; $o->prio = 3; $c->routes[] = $o; $o = new stdClass; $o->prio = 2; $c->routes[] = $o; $c->getIterator()->uasort(function($a, $b) { if ($a->prio == $b->prio ) { return 0; } return $a->prio > $b->prio ? 1 : -1; } ); var_dump($c->routes);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/B5BNe
function name:  (null)
number of ops:  31
compiled vars:  !0 = $c, !1 = $o
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'routecollection'
   25     1        NEW                                              $2      'RouteCollection'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
   27     4        NEW                                              $5      'stdClass'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $5
   28     7        ASSIGN_OBJ                                               !1, 'prio'
          8        OP_DATA                                                  3
   29     9        FETCH_OBJ_W                                      $9      !0, 'routes'
         10        ASSIGN_DIM                                               $9
         11        OP_DATA                                                  !1
   31    12        NEW                                              $11     'stdClass'
         13        DO_FCALL                                      0          
         14        ASSIGN                                                   !1, $11
   32    15        ASSIGN_OBJ                                               !1, 'prio'
         16        OP_DATA                                                  2
   33    17        FETCH_OBJ_W                                      $15     !0, 'routes'
         18        ASSIGN_DIM                                               $15
         19        OP_DATA                                                  !1
   35    20        INIT_METHOD_CALL                                         !0, 'getIterator'
         21        DO_FCALL                                      0  $17     
         22        INIT_METHOD_CALL                                         $17, 'uasort'
         23        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FB5BNe%3A35%241'
   38    24        SEND_VAL_EX                                              ~18
         25        DO_FCALL                                      0          
   41    26        INIT_FCALL                                               'var_dump'
         27        FETCH_OBJ_R                                      ~20     !0, 'routes'
         28        SEND_VAL                                                 ~20
         29        DO_ICALL                                                 
         30      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FB5BNe%3A35%241:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 7
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/B5BNe
function name:  {closure}
number of ops:  16
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   36     2        FETCH_OBJ_R                                      ~2      !0, 'prio'
          3        FETCH_OBJ_R                                      ~3      !1, 'prio'
          4        IS_EQUAL                                                 ~2, ~3
          5      > JMPZ                                                     ~4, ->7
          6    > > RETURN                                                   0
   38     7    >   FETCH_OBJ_R                                      ~5      !0, 'prio'
          8        FETCH_OBJ_R                                      ~6      !1, 'prio'
          9        IS_SMALLER                                               ~6, ~5
         10      > JMPZ                                                     ~7, ->13
         11    >   QM_ASSIGN                                        ~8      1
         12      > JMP                                                      ->14
         13    >   QM_ASSIGN                                        ~8      -1
         14    > > RETURN                                                   ~8
         15*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FB5BNe%3A35%241

Class RouteCollection:
Function getiterator:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/B5BNe
function name:  getIterator
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   NEW                                              $0      'ArrayIterator'
          1        CHECK_FUNC_ARG                                           
          2        FETCH_OBJ_FUNC_ARG                               $1      'routes'
          3        SEND_FUNC_ARG                                            $1
          4        DO_FCALL                                      0          
          5      > RETURN                                                   $0
   22     6*     > RETURN                                                   null

End of function getiterator

End of class RouteCollection.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.47 ms | 1400 KiB | 15 Q