3v4l.org

run code in 300+ PHP versions simultaneously
<?php use Guzzle\Http\Client; use Guzzle\Http\Exception\BadResponseException; require __DIR__ . '/../helper/main.php'; $app->get('/get', function () use ($app) { $url = $app->request()->params('url'); if(filter_var($url, FILTER_VALIDATE_URL) === false){ $app->halt(422, 'Url is not valid'); } $m = new Mongo(); $db = $m->selectDB('rss'); $collection = new MongoCollection($db, 'rss'); $results = $collection->find(array('url' => $url))->sort(array('date' => -1))->limit(1); $result = array_values(iterator_to_array($results)); if(isset($result[0])){ $rss = $result[0]; $date = new DateTime(date('Y-m-d H:i:s', $rss['date']->sec)); $now = new DateTime(); $now->sub(new DateInterval('PT10M')); if($now < $date){ header('Content-Type: application/json'); $rss = preparerss($rss); echo json_encode($rss); exit; } } $client = new Client(); $link = 'https://feeddetect.p.mashape.com/page/findrss/?url=' . urlencode($url); $headers = array('X-Mashape-Key' => 'MlSBGJGKZHmshugjADdPSknL2LkIp1RofQLjsnRtNgJVazPAT4'); $request = $client->get($link, $headers); try { $response = $client->send($request); } catch (BadResponseException $e) { $error = 'The following exceptions were encountered: '. $e->getMessage(); $app->halt(500, $error); } $rss = $response->json(); $rss['date'] = new MongoDate(); $db->rss->insert($rss); header('Content-Type: application/json'); $rss = prepareRss($rss); echo json_encode($rss); exit; });
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EdnLX
function name:  (null)
number of ops:  8
compiled vars:  !0 = $app
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   INCLUDE_OR_EVAL                                          '%2Fin%2F..%2Fhelper%2Fmain.php', REQUIRE
    8     1        INIT_METHOD_CALL                                         !0, 'get'
          2        SEND_VAL_EX                                              '%2Fget'
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FEdnLX%3A8%240'
          4        BIND_LEXICAL                                             ~2, !0
   52     5        SEND_VAL_EX                                              ~2
          6        DO_FCALL                                      0          
          7      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FEdnLX%3A8%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 17
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 49, Position 2 = 84
Branch analysis from position: 49
2 jumps found. (Code = 43) Position 1 = 72, Position 2 = 84
Branch analysis from position: 72
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 84
1 jumps found. (Code = 42) Position 1 = 112
Branch analysis from position: 112
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 84
Branch analysis from position: 17
Found catch point at position: 103
Branch analysis from position: 103
2 jumps found. (Code = 107) Position 1 = 104, Position 2 = -2
Branch analysis from position: 104
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/EdnLX
function name:  {closure}
number of ops:  136
compiled vars:  !0 = $app, !1 = $url, !2 = $m, !3 = $db, !4 = $collection, !5 = $results, !6 = $result, !7 = $rss, !8 = $date, !9 = $now, !10 = $client, !11 = $link, !12 = $headers, !13 = $request, !14 = $response, !15 = $e, !16 = $error
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   BIND_STATIC                                              !0
    9     1        INIT_METHOD_CALL                                         !0, 'request'
          2        DO_FCALL                                      0  $17     
          3        INIT_METHOD_CALL                                         $17, 'params'
          4        SEND_VAL_EX                                              'url'
          5        DO_FCALL                                      0  $18     
          6        ASSIGN                                                   !1, $18
   10     7        INIT_FCALL                                               'filter_var'
          8        SEND_VAR                                                 !1
          9        SEND_VAL                                                 273
         10        DO_ICALL                                         $20     
         11        TYPE_CHECK                                    4          $20
         12      > JMPZ                                                     ~21, ->17
   11    13    >   INIT_METHOD_CALL                                         !0, 'halt'
         14        SEND_VAL_EX                                              422
         15        SEND_VAL_EX                                              'Url+is+not+valid'
         16        DO_FCALL                                      0          
   13    17    >   NEW                                              $23     'Mongo'
         18        DO_FCALL                                      0          
         19        ASSIGN                                                   !2, $23
   14    20        INIT_METHOD_CALL                                         !2, 'selectDB'
         21        SEND_VAL_EX                                              'rss'
         22        DO_FCALL                                      0  $26     
         23        ASSIGN                                                   !3, $26
   15    24        NEW                                              $28     'MongoCollection'
         25        SEND_VAR_EX                                              !3
         26        SEND_VAL_EX                                              'rss'
         27        DO_FCALL                                      0          
         28        ASSIGN                                                   !4, $28
   16    29        INIT_METHOD_CALL                                         !4, 'find'
         30        INIT_ARRAY                                       ~31     !1, 'url'
         31        SEND_VAL_EX                                              ~31
         32        DO_FCALL                                      0  $32     
         33        INIT_METHOD_CALL                                         $32, 'sort'
         34        SEND_VAL_EX                                              <array>
         35        DO_FCALL                                      0  $33     
         36        INIT_METHOD_CALL                                         $33, 'limit'
         37        SEND_VAL_EX                                              1
         38        DO_FCALL                                      0  $34     
         39        ASSIGN                                                   !5, $34
   17    40        INIT_FCALL                                               'array_values'
         41        INIT_FCALL                                               'iterator_to_array'
         42        SEND_VAR                                                 !5
         43        DO_ICALL                                         $36     
         44        SEND_VAR                                                 $36
         45        DO_ICALL                                         $37     
         46        ASSIGN                                                   !6, $37
   18    47        ISSET_ISEMPTY_DIM_OBJ                         0          !6, 0
         48      > JMPZ                                                     ~39, ->84
   19    49    >   FETCH_DIM_R                                      ~40     !6, 0
         50        ASSIGN                                                   !7, ~40
   20    51        NEW                                              $42     'DateTime'
         52        INIT_FCALL                                               'date'
         53        SEND_VAL                                                 'Y-m-d+H%3Ai%3As'
         54        FETCH_DIM_R                                      ~43     !7, 'date'
         55        FETCH_OBJ_R                                      ~44     ~43, 'sec'
         56        SEND_VAL                                                 ~44
         57        DO_ICALL                                         $45     
         58        SEND_VAR_NO_REF_EX                                       $45
         59        DO_FCALL                                      0          
         60        ASSIGN                                                   !8, $42
   21    61        NEW                                              $48     'DateTime'
         62        DO_FCALL                                      0          
         63        ASSIGN                                                   !9, $48
   22    64        INIT_METHOD_CALL                                         !9, 'sub'
         65        NEW                                              $51     'DateInterval'
         66        SEND_VAL_EX                                              'PT10M'
         67        DO_FCALL                                      0          
         68        SEND_VAR_NO_REF_EX                                       $51
         69        DO_FCALL                                      0          
   23    70        IS_SMALLER                                               !9, !8
         71      > JMPZ                                                     ~54, ->84
   24    72    >   INIT_FCALL                                               'header'
         73        SEND_VAL                                                 'Content-Type%3A+application%2Fjson'
         74        DO_ICALL                                                 
   25    75        INIT_FCALL_BY_NAME                                       'preparerss'
         76        SEND_VAR_EX                                              !7
         77        DO_FCALL                                      0  $56     
         78        ASSIGN                                                   !7, $56
   26    79        INIT_FCALL                                               'json_encode'
         80        SEND_VAR                                                 !7
         81        DO_ICALL                                         $58     
         82        ECHO                                                     $58
   27    83      > EXIT                                                     
   31    84    >   NEW                                              $59     'Guzzle%5CHttp%5CClient'
         85        DO_FCALL                                      0          
         86        ASSIGN                                                   !10, $59
   32    87        INIT_FCALL                                               'urlencode'
         88        SEND_VAR                                                 !1
         89        DO_ICALL                                         $62     
         90        CONCAT                                           ~63     'https%3A%2F%2Ffeeddetect.p.mashape.com%2Fpage%2Ffindrss%2F%3Furl%3D', $62
         91        ASSIGN                                                   !11, ~63
   33    92        ASSIGN                                                   !12, <array>
   35    93        INIT_METHOD_CALL                                         !10, 'get'
         94        SEND_VAR_EX                                              !11
         95        SEND_VAR_EX                                              !12
         96        DO_FCALL                                      0  $66     
         97        ASSIGN                                                   !13, $66
   37    98        INIT_METHOD_CALL                                         !10, 'send'
         99        SEND_VAR_EX                                              !13
        100        DO_FCALL                                      0  $68     
        101        ASSIGN                                                   !14, $68
        102      > JMP                                                      ->112
   38   103  E > > CATCH                                       last         'Guzzle%5CHttp%5CException%5CBadResponseException'
   39   104    >   INIT_METHOD_CALL                                         !15, 'getMessage'
        105        DO_FCALL                                      0  $70     
        106        CONCAT                                           ~71     'The+following+exceptions+were+encountered%3A+', $70
        107        ASSIGN                                                   !16, ~71
   40   108        INIT_METHOD_CALL                                         !0, 'halt'
        109        SEND_VAL_EX                                              500
        110        SEND_VAR_EX                                              !16
        111        DO_FCALL                                      0          
   43   112    >   INIT_METHOD_CALL                                         !14, 'json'
        113        DO_FCALL                                      0  $74     
        114        ASSIGN                                                   !7, $74
   44   115        NEW                                              $77     'MongoDate'
        116        DO_FCALL                                      0          
        117        ASSIGN_DIM                                               !7, 'date'
        118        OP_DATA                                                  $77
   46   119        FETCH_OBJ_R                                      ~79     !3, 'rss'
        120        INIT_METHOD_CALL                                         ~79, 'insert'
        121        SEND_VAR_EX                                              !7
        122        DO_FCALL                                      0          
   48   123        INIT_FCALL                                               'header'
        124        SEND_VAL                                                 'Content-Type%3A+application%2Fjson'
        125        DO_ICALL                                                 
   49   126        INIT_FCALL_BY_NAME                                       'prepareRss'
        127        SEND_VAR_EX                                              !7
        128        DO_FCALL                                      0  $82     
        129        ASSIGN                                                   !7, $82
   50   130        INIT_FCALL                                               'json_encode'
        131        SEND_VAR                                                 !7
        132        DO_ICALL                                         $84     
        133        ECHO                                                     $84
   51   134      > EXIT                                                     
   52   135*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FEdnLX%3A8%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.95 ms | 1412 KiB | 28 Q