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 \ExtendedSPLHeap(); $citiesHeap = new \SPLHeap(); $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 '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 = 56
Branch analysis from position: 56
2 jumps found. (Code = 44) Position 1 = 59, Position 2 = 41
Branch analysis from position: 59
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
2 jumps found. (Code = 44) Position 1 = 59, Position 2 = 41
Branch analysis from position: 59
Branch analysis from position: 41
filename:       /in/ZOR8E
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      'ExtendedSPLHeap'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   16     3        NEW                                              $5      'SPLHeap'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $5
   19     6        NEW                                              $8      'StdClass'
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !1, $8
   20     9        ASSIGN_OBJ                                               !1, 'name'
         10        OP_DATA                                                  'Birmingham'
   21    11        ASSIGN_OBJ                                               !1, 'latitude'
         12        OP_DATA                                                  52.48
   22    13        ASSIGN_OBJ                                               !1, 'longitude'
         14        OP_DATA                                                  -1.91
   24    15        INIT_METHOD_CALL                                         !0, 'insert'
         16        SEND_VAR_EX                                              !1
         17        DO_FCALL                                      0          
   26    18        NEW                                              $15     'StdClass'
         19        DO_FCALL                                      0          
         20        ASSIGN                                                   !1, $15
   27    21        ASSIGN_OBJ                                               !1, 'name'
         22        OP_DATA                                                  'Bristol'
   28    23        ASSIGN_OBJ                                               !1, 'latitude'
         24        OP_DATA                                                  51.46
   29    25        ASSIGN_OBJ                                               !1, 'longitude'
         26        OP_DATA                                                  -2.6
   31    27        INIT_METHOD_CALL                                         !0, 'insert'
         28        SEND_VAR_EX                                              !1
         29        DO_FCALL                                      0          
   33    30        ECHO                                                     'There+are+'
         31        INIT_METHOD_CALL                                         !0, 'count'
         32        DO_FCALL                                      0  $22     
         33        ECHO                                                     $22
         34        ECHO                                                     '+cities+in+the+heap'
         35        ECHO                                                     '%0A'
   35    36        ECHO                                                     'FROM+NORTH+TO+SOUTH'
         37        ECHO                                                     '%0A'
   36    38        INIT_METHOD_CALL                                         !0, 'top'
         39        DO_FCALL                                      0          
   37    40      > JMP                                                      ->56
   38    41    >   INIT_METHOD_CALL                                         !0, 'current'
         42        DO_FCALL                                      0  $24     
         43        ASSIGN                                                   !1, $24
   40    44        INIT_FCALL                                               'sprintf'
   41    45        SEND_VAL                                                 '%25-20s+%25%2B3.4f++%25%2B3.4f%0A'
   42    46        FETCH_OBJ_R                                      ~26     !1, 'name'
         47        SEND_VAL                                                 ~26
   43    48        FETCH_OBJ_R                                      ~27     !1, 'latitude'
         49        SEND_VAL                                                 ~27
   44    50        FETCH_OBJ_R                                      ~28     !1, 'longitude'
         51        SEND_VAL                                                 ~28
         52        DO_ICALL                                         $29     
         53        ECHO                                                     $29
   47    54        INIT_METHOD_CALL                                         !0, 'next'
         55        DO_FCALL                                      0          
   37    56    >   INIT_METHOD_CALL                                         !0, 'valid'
         57        DO_FCALL                                      0  $31     
         58      > JMPNZ                                                    $31, ->41
   50    59    >   ECHO                                                     'There+are+'
         60        INIT_METHOD_CALL                                         !0, 'count'
         61        DO_FCALL                                      0  $32     
         62        ECHO                                                     $32
         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/ZOR8E
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.14 ms | 1396 KiB | 15 Q