3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public $a; public $b; public $c; public function __construct($a, $b, $c) { $this->a = $a; $this->b = $b; $this->c = $c; } } $arr = Array( new A('a1235d', 'f', 'M'), new A('a1235d', 'm', 'L'), new A('a1235d', 'm', 'S'), new A('a1234d', 'm', 'L'), new A('a1234d', 'm', 'S'), new A('a1236d', 'm', 'S'), new A('a1236d', 'm', 'M'), new A('a1234d', 'f', 'S'), new A('a1236d', 'f', 'S'), new A('a1236d', 'f', 'M'), new A('a1235d', 'f', 'S'), new A('a1234d', 'm', 'M'), new A('a1235d', 'm', 'M'), new A('a1234d', 'f', 'M'), new A('a1235d', 'f', 'L'), new A('a1236d', 'm', 'L'), new A('a1236d', 'f', 'L'), new A('a1234d', 'f', 'L') ); function sort_by_a($arr) { usort($arr, function($a, $b) { if ($a->a == $b->a) { return 0; } return ($a->a < $b->a) ? -1 : 1; }); return $arr; } function sort_by_b($arr) { usort($arr, function($a, $b) { if ($a->b == $b->b) { return 0; } return ($a->b < $b->b) ? -1 : 1; }); return $arr; } function sort_by_c($arr) { usort($arr, function($a, $b) { if ($a->c == $b->c) { return 0; } return ($a->c < $b->c) ? -1 : 1; }); return $arr; } $arr = sort_by_c($arr); $arr = sort_by_b($arr); $arr = sort_by_a($arr); var_dump($arr);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qZT5Z
function name:  (null)
number of ops:  125
compiled vars:  !0 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   NEW                                              $1      'A'
          1        SEND_VAL_EX                                              'a1235d'
          2        SEND_VAL_EX                                              'f'
          3        SEND_VAL_EX                                              'M'
          4        DO_FCALL                                      0          
          5        INIT_ARRAY                                       ~3      $1
   16     6        NEW                                              $4      'A'
          7        SEND_VAL_EX                                              'a1235d'
          8        SEND_VAL_EX                                              'm'
          9        SEND_VAL_EX                                              'L'
         10        DO_FCALL                                      0          
         11        ADD_ARRAY_ELEMENT                                ~3      $4
   17    12        NEW                                              $6      'A'
         13        SEND_VAL_EX                                              'a1235d'
         14        SEND_VAL_EX                                              'm'
         15        SEND_VAL_EX                                              'S'
         16        DO_FCALL                                      0          
         17        ADD_ARRAY_ELEMENT                                ~3      $6
   18    18        NEW                                              $8      'A'
         19        SEND_VAL_EX                                              'a1234d'
         20        SEND_VAL_EX                                              'm'
         21        SEND_VAL_EX                                              'L'
         22        DO_FCALL                                      0          
         23        ADD_ARRAY_ELEMENT                                ~3      $8
   19    24        NEW                                              $10     'A'
         25        SEND_VAL_EX                                              'a1234d'
         26        SEND_VAL_EX                                              'm'
         27        SEND_VAL_EX                                              'S'
         28        DO_FCALL                                      0          
         29        ADD_ARRAY_ELEMENT                                ~3      $10
   20    30        NEW                                              $12     'A'
         31        SEND_VAL_EX                                              'a1236d'
         32        SEND_VAL_EX                                              'm'
         33        SEND_VAL_EX                                              'S'
         34        DO_FCALL                                      0          
         35        ADD_ARRAY_ELEMENT                                ~3      $12
   21    36        NEW                                              $14     'A'
         37        SEND_VAL_EX                                              'a1236d'
         38        SEND_VAL_EX                                              'm'
         39        SEND_VAL_EX                                              'M'
         40        DO_FCALL                                      0          
         41        ADD_ARRAY_ELEMENT                                ~3      $14
   22    42        NEW                                              $16     'A'
         43        SEND_VAL_EX                                              'a1234d'
         44        SEND_VAL_EX                                              'f'
         45        SEND_VAL_EX                                              'S'
         46        DO_FCALL                                      0          
         47        ADD_ARRAY_ELEMENT                                ~3      $16
   23    48        NEW                                              $18     'A'
         49        SEND_VAL_EX                                              'a1236d'
         50        SEND_VAL_EX                                              'f'
         51        SEND_VAL_EX                                              'S'
         52        DO_FCALL                                      0          
         53        ADD_ARRAY_ELEMENT                                ~3      $18
   24    54        NEW                                              $20     'A'
         55        SEND_VAL_EX                                              'a1236d'
         56        SEND_VAL_EX                                              'f'
         57        SEND_VAL_EX                                              'M'
         58        DO_FCALL                                      0          
         59        ADD_ARRAY_ELEMENT                                ~3      $20
   25    60        NEW                                              $22     'A'
         61        SEND_VAL_EX                                              'a1235d'
         62        SEND_VAL_EX                                              'f'
         63        SEND_VAL_EX                                              'S'
         64        DO_FCALL                                      0          
         65        ADD_ARRAY_ELEMENT                                ~3      $22
   26    66        NEW                                              $24     'A'
         67        SEND_VAL_EX                                              'a1234d'
         68        SEND_VAL_EX                                              'm'
         69        SEND_VAL_EX                                              'M'
         70        DO_FCALL                                      0          
         71        ADD_ARRAY_ELEMENT                                ~3      $24
   27    72        NEW                                              $26     'A'
         73        SEND_VAL_EX                                              'a1235d'
         74        SEND_VAL_EX                                              'm'
         75        SEND_VAL_EX                                              'M'
         76        DO_FCALL                                      0          
         77        ADD_ARRAY_ELEMENT                                ~3      $26
   28    78        NEW                                              $28     'A'
         79        SEND_VAL_EX                                              'a1234d'
         80        SEND_VAL_EX                                              'f'
         81        SEND_VAL_EX                                              'M'
         82        DO_FCALL                                      0          
         83        ADD_ARRAY_ELEMENT                                ~3      $28
   29    84        NEW                                              $30     'A'
         85        SEND_VAL_EX                                              'a1235d'
         86        SEND_VAL_EX                                              'f'
         87        SEND_VAL_EX                                              'L'
         88        DO_FCALL                                      0          
         89        ADD_ARRAY_ELEMENT                                ~3      $30
   30    90        NEW                                              $32     'A'
         91        SEND_VAL_EX                                              'a1236d'
         92        SEND_VAL_EX                                              'm'
         93        SEND_VAL_EX                                              'L'
         94        DO_FCALL                                      0          
         95        ADD_ARRAY_ELEMENT                                ~3      $32
   31    96        NEW                                              $34     'A'
         97        SEND_VAL_EX                                              'a1236d'
         98        SEND_VAL_EX                                              'f'
         99        SEND_VAL_EX                                              'L'
        100        DO_FCALL                                      0          
        101        ADD_ARRAY_ELEMENT                                ~3      $34
   32   102        NEW                                              $36     'A'
        103        SEND_VAL_EX                                              'a1234d'
        104        SEND_VAL_EX                                              'f'
        105        SEND_VAL_EX                                              'L'
        106        DO_FCALL                                      0          
        107        ADD_ARRAY_ELEMENT                                ~3      $36
   14   108        ASSIGN                                                   !0, ~3
   65   109        INIT_FCALL                                               'sort_by_c'
        110        SEND_VAR                                                 !0
        111        DO_FCALL                                      0  $39     
        112        ASSIGN                                                   !0, $39
   66   113        INIT_FCALL                                               'sort_by_b'
        114        SEND_VAR                                                 !0
        115        DO_FCALL                                      0  $41     
        116        ASSIGN                                                   !0, $41
   67   117        INIT_FCALL                                               'sort_by_a'
        118        SEND_VAR                                                 !0
        119        DO_FCALL                                      0  $43     
        120        ASSIGN                                                   !0, $43
   69   121        INIT_FCALL                                               'var_dump'
        122        SEND_VAR                                                 !0
        123        DO_ICALL                                                 
        124      > RETURN                                                   1

Function sort_by_a:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qZT5Z
function name:  sort_by_a
number of ops:  8
compiled vars:  !0 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   RECV                                             !0      
   36     1        INIT_FCALL                                               'usort'
          2        SEND_REF                                                 !0
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FqZT5Z%3A36%240'
   41     4        SEND_VAL                                                 ~1
          5        DO_ICALL                                                 
   42     6      > RETURN                                                   !0
   43     7*     > RETURN                                                   null

End of function sort_by_a

Function %00%7Bclosure%7D%2Fin%2FqZT5Z%3A36%240:
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/qZT5Z
function name:  {closure}
number of ops:  16
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   37     2        FETCH_OBJ_R                                      ~2      !0, 'a'
          3        FETCH_OBJ_R                                      ~3      !1, 'a'
          4        IS_EQUAL                                                 ~2, ~3
          5      > JMPZ                                                     ~4, ->7
   38     6    > > RETURN                                                   0
   40     7    >   FETCH_OBJ_R                                      ~5      !0, 'a'
          8        FETCH_OBJ_R                                      ~6      !1, 'a'
          9        IS_SMALLER                                               ~5, ~6
         10      > JMPZ                                                     ~7, ->13
         11    >   QM_ASSIGN                                        ~8      -1
         12      > JMP                                                      ->14
         13    >   QM_ASSIGN                                        ~8      1
         14    > > RETURN                                                   ~8
   41    15*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FqZT5Z%3A36%240

Function sort_by_b:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qZT5Z
function name:  sort_by_b
number of ops:  8
compiled vars:  !0 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E >   RECV                                             !0      
   46     1        INIT_FCALL                                               'usort'
          2        SEND_REF                                                 !0
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FqZT5Z%3A46%241'
   51     4        SEND_VAL                                                 ~1
          5        DO_ICALL                                                 
   52     6      > RETURN                                                   !0
   53     7*     > RETURN                                                   null

End of function sort_by_b

Function %00%7Bclosure%7D%2Fin%2FqZT5Z%3A46%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/qZT5Z
function name:  {closure}
number of ops:  16
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   46     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   47     2        FETCH_OBJ_R                                      ~2      !0, 'b'
          3        FETCH_OBJ_R                                      ~3      !1, 'b'
          4        IS_EQUAL                                                 ~2, ~3
          5      > JMPZ                                                     ~4, ->7
   48     6    > > RETURN                                                   0
   50     7    >   FETCH_OBJ_R                                      ~5      !0, 'b'
          8        FETCH_OBJ_R                                      ~6      !1, 'b'
          9        IS_SMALLER                                               ~5, ~6
         10      > JMPZ                                                     ~7, ->13
         11    >   QM_ASSIGN                                        ~8      -1
         12      > JMP                                                      ->14
         13    >   QM_ASSIGN                                        ~8      1
         14    > > RETURN                                                   ~8
   51    15*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FqZT5Z%3A46%241

Function sort_by_c:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qZT5Z
function name:  sort_by_c
number of ops:  8
compiled vars:  !0 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   55     0  E >   RECV                                             !0      
   56     1        INIT_FCALL                                               'usort'
          2        SEND_REF                                                 !0
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FqZT5Z%3A56%242'
   61     4        SEND_VAL                                                 ~1
          5        DO_ICALL                                                 
   62     6      > RETURN                                                   !0
   63     7*     > RETURN                                                   null

End of function sort_by_c

Function %00%7Bclosure%7D%2Fin%2FqZT5Z%3A56%242:
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/qZT5Z
function name:  {closure}
number of ops:  16
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   56     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   57     2        FETCH_OBJ_R                                      ~2      !0, 'c'
          3        FETCH_OBJ_R                                      ~3      !1, 'c'
          4        IS_EQUAL                                                 ~2, ~3
          5      > JMPZ                                                     ~4, ->7
   58     6    > > RETURN                                                   0
   60     7    >   FETCH_OBJ_R                                      ~5      !0, 'c'
          8        FETCH_OBJ_R                                      ~6      !1, 'c'
          9        IS_SMALLER                                               ~5, ~6
         10      > JMPZ                                                     ~7, ->13
         11    >   QM_ASSIGN                                        ~8      -1
         12      > JMP                                                      ->14
         13    >   QM_ASSIGN                                        ~8      1
         14    > > RETURN                                                   ~8
   61    15*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FqZT5Z%3A56%242

Class A:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qZT5Z
function name:  __construct
number of ops:  10
compiled vars:  !0 = $a, !1 = $b, !2 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    8     3        ASSIGN_OBJ                                               'a'
          4        OP_DATA                                                  !0
    9     5        ASSIGN_OBJ                                               'b'
          6        OP_DATA                                                  !1
   10     7        ASSIGN_OBJ                                               'c'
          8        OP_DATA                                                  !2
   11     9      > RETURN                                                   null

End of function __construct

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.55 ms | 1423 KiB | 20 Q