3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ExtendedSPLHeap extends \SPLHeap { protected function compare($a, $b) { if ($a->latitude == $b->latitude) { return 0; } return ($a->latitude < $b->latitude) ? -1 : 1; } } $citiesHeap = new \SplMaxHeap(); $city = new \StdClass; $city->name = "Birmingham"; $city->latitude = 52.4800; $city->longitude = -1.9100; $citiesHeap->insert($city); $city = new \StdClass; $city->name = "Bristol"; $city->latitude = 51.4600; $city->longitude = -2.6000; $citiesHeap->insert($city); echo 'There are ', $citiesHeap->count(), ' cities in the heap', PHP_EOL; echo 'FROM NORTH TO SOUTH', PHP_EOL; $citiesHeap->top(); while ($citiesHeap->valid()) { $city = $citiesHeap->current(); echo sprintf( "%-20s %+3.4f %+3.4f" . PHP_EOL, $city->name, $city->latitude, $city->longitude ); $citiesHeap->next(); } echo $citiesHeap->rewind(); echo 'There are ', $citiesHeap->count(), ' cities in the heap', PHP_EOL;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 53
Branch analysis from position: 53
2 jumps found. (Code = 44) Position 1 = 56, Position 2 = 38
Branch analysis from position: 56
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
2 jumps found. (Code = 44) Position 1 = 56, Position 2 = 38
Branch analysis from position: 56
Branch analysis from position: 38
filename:       /in/J4mnl
function name:  (null)
number of ops:  66
compiled vars:  !0 = $citiesHeap, !1 = $city
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   NEW                                              $2      'SplMaxHeap'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   18     3        NEW                                              $5      'StdClass'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $5
   19     6        ASSIGN_OBJ                                               !1, 'name'
          7        OP_DATA                                                  'Birmingham'
   20     8        ASSIGN_OBJ                                               !1, 'latitude'
          9        OP_DATA                                                  52.48
   21    10        ASSIGN_OBJ                                               !1, 'longitude'
         11        OP_DATA                                                  -1.91
   23    12        INIT_METHOD_CALL                                         !0, 'insert'
         13        SEND_VAR_EX                                              !1
         14        DO_FCALL                                      0          
   25    15        NEW                                              $12     'StdClass'
         16        DO_FCALL                                      0          
         17        ASSIGN                                                   !1, $12
   26    18        ASSIGN_OBJ                                               !1, 'name'
         19        OP_DATA                                                  'Bristol'
   27    20        ASSIGN_OBJ                                               !1, 'latitude'
         21        OP_DATA                                                  51.46
   28    22        ASSIGN_OBJ                                               !1, 'longitude'
         23        OP_DATA                                                  -2.6
   30    24        INIT_METHOD_CALL                                         !0, 'insert'
         25        SEND_VAR_EX                                              !1
         26        DO_FCALL                                      0          
   32    27        ECHO                                                     'There+are+'
         28        INIT_METHOD_CALL                                         !0, 'count'
         29        DO_FCALL                                      0  $19     
         30        ECHO                                                     $19
         31        ECHO                                                     '+cities+in+the+heap'
         32        ECHO                                                     '%0A'
   34    33        ECHO                                                     'FROM+NORTH+TO+SOUTH'
         34        ECHO                                                     '%0A'
   35    35        INIT_METHOD_CALL                                         !0, 'top'
         36        DO_FCALL                                      0          
   36    37      > JMP                                                      ->53
   37    38    >   INIT_METHOD_CALL                                         !0, 'current'
         39        DO_FCALL                                      0  $21     
         40        ASSIGN                                                   !1, $21
   39    41        INIT_FCALL                                               'sprintf'
   40    42        SEND_VAL                                                 '%25-20s+%25%2B3.4f++%25%2B3.4f%0A'
   41    43        FETCH_OBJ_R                                      ~23     !1, 'name'
         44        SEND_VAL                                                 ~23
   42    45        FETCH_OBJ_R                                      ~24     !1, 'latitude'
         46        SEND_VAL                                                 ~24
   43    47        FETCH_OBJ_R                                      ~25     !1, 'longitude'
         48        SEND_VAL                                                 ~25
         49        DO_ICALL                                         $26     
         50        ECHO                                                     $26
   46    51        INIT_METHOD_CALL                                         !0, 'next'
         52        DO_FCALL                                      0          
   36    53    >   INIT_METHOD_CALL                                         !0, 'valid'
         54        DO_FCALL                                      0  $28     
         55      > JMPNZ                                                    $28, ->38
   49    56    >   INIT_METHOD_CALL                                         !0, 'rewind'
         57        DO_FCALL                                      0  $29     
         58        ECHO                                                     $29
   50    59        ECHO                                                     'There+are+'
         60        INIT_METHOD_CALL                                         !0, 'count'
         61        DO_FCALL                                      0  $30     
         62        ECHO                                                     $30
         63        ECHO                                                     '+cities+in+the+heap'
         64        ECHO                                                     '%0A'
         65      > RETURN                                                   1

Class ExtendedSPLHeap:
Function compare:
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/J4mnl
function name:  compare
number of ops:  16
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    6     2        FETCH_OBJ_R                                      ~2      !0, 'latitude'
          3        FETCH_OBJ_R                                      ~3      !1, 'latitude'
          4        IS_EQUAL                                                 ~2, ~3
          5      > JMPZ                                                     ~4, ->7
    7     6    > > RETURN                                                   0
    9     7    >   FETCH_OBJ_R                                      ~5      !0, 'latitude'
          8        FETCH_OBJ_R                                      ~6      !1, 'latitude'
          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
   10    15*     > RETURN                                                   null

End of function compare

End of class ExtendedSPLHeap.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.08 ms | 1404 KiB | 15 Q