3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test() { $orderedids=array(7, 9, 5, 3); $tags=array( new Tag(3), new Tag(7), new Tag(5), new Tag(9) ); $flipped=array_flip($orderedids); $sorter=new stdClass(); $sorter->flipped=$flipped; $sorter->sfunct=function($tag1, $tag2) { if ($this->flipped[$tag1->id]<$this->flipped[$tag2->id]) return -1; else if ($this->flipped[$tag1->id]==$this->flipped[$tag2->id]) return 0; else return 1; }; return usort($tags, $sorter->sfunct); } class Tag { public $id; function __construct($id) { $this->id=$id; } } $rtags=test(); foreach ($rtags as $tag) echo $tag->id." ";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 9
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/1S33Y
function name:  (null)
number of ops:  11
compiled vars:  !0 = $rtags, !1 = $tag
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   INIT_FCALL                                               'test'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
   36     3      > FE_RESET_R                                       $4      !0, ->9
          4    > > FE_FETCH_R                                               $4, !1, ->9
          5    >   FETCH_OBJ_R                                      ~5      !1, 'id'
          6        CONCAT                                           ~6      ~5, '+'
          7        ECHO                                                     ~6
          8      > JMP                                                      ->4
          9    >   FE_FREE                                                  $4
         10      > RETURN                                                   1

Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1S33Y
function name:  test
number of ops:  37
compiled vars:  !0 = $orderedids, !1 = $tags, !2 = $flipped, !3 = $sorter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, <array>
    7     1        NEW                                              $5      'Tag'
          2        SEND_VAL_EX                                              3
          3        DO_FCALL                                      0          
          4        INIT_ARRAY                                       ~7      $5
    8     5        NEW                                              $8      'Tag'
          6        SEND_VAL_EX                                              7
          7        DO_FCALL                                      0          
          8        ADD_ARRAY_ELEMENT                                ~7      $8
    9     9        NEW                                              $10     'Tag'
         10        SEND_VAL_EX                                              5
         11        DO_FCALL                                      0          
         12        ADD_ARRAY_ELEMENT                                ~7      $10
   10    13        NEW                                              $12     'Tag'
         14        SEND_VAL_EX                                              9
         15        DO_FCALL                                      0          
         16        ADD_ARRAY_ELEMENT                                ~7      $12
    6    17        ASSIGN                                                   !1, ~7
   13    18        INIT_FCALL                                               'array_flip'
         19        SEND_VAR                                                 !0
         20        DO_ICALL                                         $15     
         21        ASSIGN                                                   !2, $15
   15    22        NEW                                              $17     'stdClass'
         23        DO_FCALL                                      0          
         24        ASSIGN                                                   !3, $17
   16    25        ASSIGN_OBJ                                               !3, 'flipped'
         26        OP_DATA                                                  !2
   17    27        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F1S33Y%3A17%240'
         28        ASSIGN_OBJ                                               !3, 'sfunct'
   21    29        OP_DATA                                                  ~22
   23    30        INIT_FCALL                                               'usort'
         31        SEND_REF                                                 !1
         32        FETCH_OBJ_R                                      ~23     !3, 'sfunct'
         33        SEND_VAL                                                 ~23
         34        DO_ICALL                                         $24     
         35      > RETURN                                                   $24
   24    36*     > RETURN                                                   null

End of function test

Function %00%7Bclosure%7D%2Fin%2F1S33Y%3A17%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 14
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 26
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1S33Y
function name:  {closure}
number of ops:  28
compiled vars:  !0 = $tag1, !1 = $tag2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   18     2        FETCH_THIS                                       $2      
          3        FETCH_OBJ_R                                      ~4      !0, 'id'
          4        FETCH_OBJ_R                                      ~3      $2, 'flipped'
          5        FETCH_DIM_R                                      ~5      ~3, ~4
          6        FETCH_THIS                                       $6      
          7        FETCH_OBJ_R                                      ~8      !1, 'id'
          8        FETCH_OBJ_R                                      ~7      $6, 'flipped'
          9        FETCH_DIM_R                                      ~9      ~7, ~8
         10        IS_SMALLER                                               ~5, ~9
         11      > JMPZ                                                     ~10, ->14
         12    > > RETURN                                                   -1
         13*       JMP                                                      ->27
   19    14    >   FETCH_THIS                                       $11     
         15        FETCH_OBJ_R                                      ~13     !0, 'id'
         16        FETCH_OBJ_R                                      ~12     $11, 'flipped'
         17        FETCH_DIM_R                                      ~14     ~12, ~13
         18        FETCH_THIS                                       $15     
         19        FETCH_OBJ_R                                      ~17     !1, 'id'
         20        FETCH_OBJ_R                                      ~16     $15, 'flipped'
         21        FETCH_DIM_R                                      ~18     ~16, ~17
         22        IS_EQUAL                                                 ~14, ~18
         23      > JMPZ                                                     ~19, ->26
         24    > > RETURN                                                   0
         25*       JMP                                                      ->27
   20    26    > > RETURN                                                   1
   21    27*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F1S33Y%3A17%240

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

End of function __construct

End of class Tag.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.1 ms | 1407 KiB | 18 Q