3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @package Wargaming.API * @version 1.2 * @author Artur Stępień (artur.stepien@bestproject.pl) * @copyright Copyright (C) 2015 Artur Stępień, All rights reserved. * @license GNU General Public License version 3 or later; see LICENSE.txt */ namespace Wargaming { class API { /** * Application ID from Wargaming Developer Room * @var Integer */ protected $application_id; /** * Language for data retrieved from Wargaming servers (language code). * * @var String */ protected $language; /** * API server URL. This one depends on server you use. * * @var String */ protected $server; /** * CURL connection handle * * @var */ protected $connection = null; /** * Create Wargaming API instance * * @param string $application_id Application ID obtainable from Wargaming websites * @param string $language Language of data (mostly errors). Default: LANGUAGE_ENGLISH * @param string $server Server/Cluster that should be used as source. DefaultL SERVER_EU */ public function __construct($application_id, $language = LANGUAGE_ENGLISH, $server = SERVER_EU) { $this->application_id = $application_id; $this->language = $language; $this->server = $server; } /** * Return data from Wargaming servers. Documentation for all API methods can be found here: https://eu.wargaming.net/developers/api_reference * * @param string $namespace Namespace of data you want to get(for example wgn/servers/info or wot/account/list ) * @param array $options All the options required for this field to work except application_id and language (for example array('fields'=>'server','game'=>'wot')) * @param boolean $assoc If set to true function will return associative array instead of object/array of objects. * @param string $ETag ETag string to validate data (without quotation marks). If in response server will return HTTP 304 Not Modified status method will return boolean TRUE. That means that data did not changed. Documentation: https://eu.wargaming.net/developers/documentation/guide/getting-started/#etag * @param boolean $HTTPHeaders If this parameter is set to TRUE, method will return also HTTP headers sent with response in format: array('headers'=>array(), 'data'=>array()). * * @return mixed */ public function get($namespace, Array $options = array(), $assoc = false, $ETag = null, $HTTPHeaders = false) { // Build query url $url = 'https://'.$this->server.'/'.$namespace.'/?application_id='.$this->application_id.'&language='.$this->language.'&'.http_build_query($options); // Get response $buff = $this->getUrlContents($url, $ETag, $HTTPHeaders); // Wrong response (probably wrong server URL) if( $buff['data'] === false ) { throw new \Exception('Wrong server or namespace.', 404); // Data did not changed on server } else if( $buff['data'] === true ) { // If HTTPHeaders parameter is set, return assocative array containing data and headers if( $HTTPHeaders ) { return $buff; // Return plain data } else { return $buff['data']; } // New data available } else { // Convert response to object or array depending on $assoc param $response = json_decode($buff['data'], $assoc); // User chose object format if( is_object($response) ) { // Servers return correct data if( $response->status=='ok') { // If HTTPHeaders parameter is set, return assocative array containing also headers if( $HTTPHeaders ) { return array('data'=>$response->data, 'headers'=>$buff['headers']); // Return plain data } else { return $response->data; } // Api server return error } elseif( $response->status=='error' ) { // Create exception throw new \Exception( $this->translateError($response->error->message, $namespace), $response->error->code ); // Page not found } else { throw new \Exception('You set wrong server or namespace.', 404); } // User chose array format } elseif ( is_array($response) ) { // Servers return correct data if( $response['status']=='ok') { // If HTTPHeaders parameter is set, return assocative array containing also headers if( $HTTPHeaders ) { return array('data'=>$response['data'], 'headers'=>$buff['headers']); // Return plain data } else { return $response['data']; } // Api server return error } elseif( $response['status']=='error' ) { // Create exception throw new \Exception( $this->translateError($response['error']['message'], $namespace), $response['error']['code'] ); // Page not found } else { throw new \Exception('You set wrong server or namespace.', 404); } // Unsupported response format } else { throw new \Exception('Wrong response format.', 502); } } return false; } /** * Returns data from url provided in $url. This function use same curl handle for each request * * @param String $url Data url to process * @param String $ETag ETag HTTP header value (without quotation marks) to be used for request. * @param boolean $HTTPHeaders If this parameter is set to TRUE, method will return also HTTP headers sent with response in format: array('headers'=>array(), 'data'=>''). * * @return mixed Array if success, FALSE on failure, TRUE if data did not changed (only when ETag is used). */ protected function getUrlContents($url, $ETag = null, $HTTPHeaders = false) { // Connection needs to be created if ( !is_resource($this->connection) ) { // Initialise connection $this->connection = curl_init(); // Make curl return response instead of printing it curl_setopt($this->connection, CURLOPT_RETURNTRANSFER, true); curl_setopt($this->connection, CURLOPT_SSL_VERIFYPEER, false); if( $HTTPHeaders ) { curl_setopt($this->connection, CURLOPT_HEADER, true); } } // User provided ETag so use it if( !is_null($ETag) ) { curl_setopt($this->connection, CURLOPT_HTTPHEADER, array( 'If-None-Match: "'.$ETag.'"', )); } // Set connection URL curl_setopt($this->connection, CURLOPT_URL, $url); // Get response $buffer = curl_exec($this->connection); // Check if curl did not return erro $error = curl_error($this->connection); if( $error!=='' ) { throw new \Exception('(Curl) '.$error, curl_errno($this->connection)); } // Prepare headers if( $HTTPHeaders ) { // Split response headers and response body list($headers, $body) = explode("\r\n\r\n", $buffer, 2); // Process headers $headers = explode("\r\n", $headers); $tmp = array(); foreach($headers AS $header) { $row = explode(': ', $header, 2); if( count($row)==1 ) { $tmp[$row[0]] = ''; } else { $tmp[$row[0]] = $row[1]; } } // Set formatted headers $headers = $tmp; } else { $headers = array(); $body = $buffer; } // Get response status code $status_code = curl_getinfo($this->connection, CURLINFO_HTTP_CODE); // If data did not changed, return TRUE if( $status_code==304 ) { $body = true; } return array('headers'=>$headers, 'data'=>$body); } /** * Returns human readable error message. * * @param string $error The error to translate. * @param string $namespace Namespace passed into get() function. * * @return string */ protected function translateError($error, $namespace = null) { $messages = array( 'SEARCH_NOT_SPECIFIED' => 'Parameter <b>search</b> not specified.', 'NOT_ENOUGH_SEARCH_LENGTH' => '<b>Search</b> parameter is not long enough. Minimum length: 3 characters.', 'ACCOUNT_ID_LIST_LIMIT_EXCEEDED' => 'Limit of passed-in <b>account_id</b> IDs exceeded. Maximum: 100.', 'METHOD_NOT_FOUND' => 'Invalid API method <b>'.$namespace.'</b>.', 'METHOD_DISABLED' => 'Specified method is disabled.', 'APPLICATION_IS_BLOCKED' => 'Application is blocked by the administration.', 'INVALID_APPLICATION_ID' => 'Invalid <b>application_id</b>.', 'INVALID_IP_ADDRESS' => 'Invalid IP-address for the server application.', 'REQUEST_LIMIT_EXCEEDED' => 'Request limit is exceeded.', 'SOURCE_NOT_AVAILABLE' => 'Data source is not available.', 'INVALID_FIELDS' => 'Invalid fields specified in <b>fields</b> parameter.', 'AUTH_CANCEL' => 'Application authorization cancelled by user.', 'AUTH_EXPIRED' => 'User authorization timed out.', 'AUTH_ERROR' => 'Authentication error.', 'MEMBER_ID_LIST_LIMIT_EXCEEDED' => 'Limit of passed-in <b>member_id</b> IDs exceeded. Maximum: 100.', 'CLAN_ID_LIST_LIMIT_EXCEEDED' => 'Limit of passed-in <b>clan_id</b> IDs exceeded. Maximum: 100.', 'INCOMPATIBLE_MODULE_IDS' => 'Specified modules are incompatible in a single configuration.', 'ACCOUNT_ID_NOT_SPECIFIED' => 'Required parameter <b>account_id</b> was not specified.', 'TYPE_NOT_SPECIFIED' => 'Required parameter <b>type</b> was not specified.', 'INVALID_TYPE' => 'Invalid value set in <b>type</b> parameter.', 'RATINGS_NOT_FOUND' => 'No rating details for specified date.', 'RANK_FIELD_NOT_SPECIFIED' => 'Required parameter <b>rank_field</b> not specified.', 'INVALID_RANK_FIELD' => 'Invalid value set in <b>rank_field</b> parameter.', 'INVALID_CLAN_ID' => 'Invalid value set in <b>clan_id</b> parameter. Clan with that ID probably don\'t exist.', 'CLAN_ID_NOT_SPECIFIED' => 'Required parameter <b>clan_id</b> was not specified.', 'INVALID_LIMIT' => 'Invalid value set in <b>limit</b> parameter.', ); if( isset($messages[$error]) ) { return $messages[$error]; } elseif( stripos($error, '_NOT_SPECIFIED') ) { return 'Required field <b>'.strtolower(str_ireplace('_NOT_SPECIFIED', '', $error)).'</b> is not specified.'; } elseif( stripos($error, '_NOT_FOUND') ) { return 'Data for <b>'.strtolower(str_ireplace('_NOT_FOUND', '', $error)).'</b> not found.'; } elseif( stripos($error, '_LIST_LIMIT_EXCEEDED') ) { return 'Limit of passed-in identifiers in the <b>'.strtolower(str_ireplace('_LIST_LIMIT_EXCEEDED', '', $error)).'</b> exceeded.'; } elseif( stripos($error, 'INVALID_') ) { return 'Specified field value <b>'.strtolower(str_ireplace('INVALID_', '', $error)).'</b> is not valid.'; } else { return $error; } } } // Supported language codes (used mostly in Tankpedia queries) CONST LANGUAGE_ENGLISH = 'en'; CONST LANGUAGE_POLISH = 'pl'; CONST LANGUAGE_RUSSIAN = 'ru'; CONST LANGUAGE_DEUTSCH = 'de'; CONST LANGUAGE_FRENCH = 'fr'; CONST LANGUAGE_SPANISH = 'es'; CONST LANGUAGE_CHINESE = 'zh-cn'; CONST LANGUAGE_TURKISH = 'tr'; CONST LANGUAGE_CZECH = 'cs'; CONST LANGUAGE_THAI = 'th'; CONST LANGUAGE_VIETNAMESE = 'vi'; // Supported servers CONST SERVER_EU = 'api.worldoftanks.eu'; CONST SERVER_NA = 'api.worldoftanks.com'; CONST SERVER_RU = 'api.worldoftanks.ru'; CONST SERVER_ASIA = 'api.worldoftanks.asia'; CONST SERVER_KR = 'api.worldoftanks.kr'; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7TKjl
function name:  (null)
number of ops:  17
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  343     0  E >   DECLARE_CONST                                            'Wargaming%5CLANGUAGE_ENGLISH', 'en'
  344     1        DECLARE_CONST                                            'Wargaming%5CLANGUAGE_POLISH', 'pl'
  345     2        DECLARE_CONST                                            'Wargaming%5CLANGUAGE_RUSSIAN', 'ru'
  346     3        DECLARE_CONST                                            'Wargaming%5CLANGUAGE_DEUTSCH', 'de'
  347     4        DECLARE_CONST                                            'Wargaming%5CLANGUAGE_FRENCH', 'fr'
  348     5        DECLARE_CONST                                            'Wargaming%5CLANGUAGE_SPANISH', 'es'
  349     6        DECLARE_CONST                                            'Wargaming%5CLANGUAGE_CHINESE', 'zh-cn'
  350     7        DECLARE_CONST                                            'Wargaming%5CLANGUAGE_TURKISH', 'tr'
  351     8        DECLARE_CONST                                            'Wargaming%5CLANGUAGE_CZECH', 'cs'
  352     9        DECLARE_CONST                                            'Wargaming%5CLANGUAGE_THAI', 'th'
  353    10        DECLARE_CONST                                            'Wargaming%5CLANGUAGE_VIETNAMESE', 'vi'
  356    11        DECLARE_CONST                                            'Wargaming%5CSERVER_EU', 'api.worldoftanks.eu'
  357    12        DECLARE_CONST                                            'Wargaming%5CSERVER_NA', 'api.worldoftanks.com'
  358    13        DECLARE_CONST                                            'Wargaming%5CSERVER_RU', 'api.worldoftanks.ru'
  359    14        DECLARE_CONST                                            'Wargaming%5CSERVER_ASIA', 'api.worldoftanks.asia'
  360    15        DECLARE_CONST                                            'Wargaming%5CSERVER_KR', 'api.worldoftanks.kr'
  362    16      > RETURN                                                   1

Class Wargaming\API:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7TKjl
function name:  __construct
number of ops:  10
compiled vars:  !0 = $application_id, !1 = $language, !2 = $server
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   49     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <const ast>
          2        RECV_INIT                                        !2      <const ast>
   51     3        ASSIGN_OBJ                                               'application_id'
          4        OP_DATA                                                  !0
   52     5        ASSIGN_OBJ                                               'language'
          6        OP_DATA                                                  !1
   53     7        ASSIGN_OBJ                                               'server'
          8        OP_DATA                                                  !2
   55     9      > RETURN                                                   null

End of function __construct

Function get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 36
Branch analysis from position: 30
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 36
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 45
Branch analysis from position: 39
2 jumps found. (Code = 43) Position 1 = 40, Position 2 = 42
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 45
2 jumps found. (Code = 43) Position 1 = 56, Position 2 = 94
Branch analysis from position: 56
2 jumps found. (Code = 43) Position 1 = 59, Position 2 = 69
Branch analysis from position: 59
2 jumps found. (Code = 43) Position 1 = 60, Position 2 = 66
Branch analysis from position: 60
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 66
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 69
2 jumps found. (Code = 43) Position 1 = 72, Position 2 = 88
Branch analysis from position: 72
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 88
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 94
2 jumps found. (Code = 43) Position 1 = 98, Position 2 = 136
Branch analysis from position: 98
2 jumps found. (Code = 43) Position 1 = 101, Position 2 = 111
Branch analysis from position: 101
2 jumps found. (Code = 43) Position 1 = 102, Position 2 = 108
Branch analysis from position: 102
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 108
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 111
2 jumps found. (Code = 43) Position 1 = 114, Position 2 = 130
Branch analysis from position: 114
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 130
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 136
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/7TKjl
function name:  get
number of ops:  143
compiled vars:  !0 = $namespace, !1 = $options, !2 = $assoc, !3 = $ETag, !4 = $HTTPHeaders, !5 = $url, !6 = $buff, !7 = $response
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   68     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <array>
          2        RECV_INIT                                        !2      <false>
          3        RECV_INIT                                        !3      null
          4        RECV_INIT                                        !4      <false>
   71     5        FETCH_OBJ_R                                      ~8      'server'
          6        CONCAT                                           ~9      'https%3A%2F%2F', ~8
          7        CONCAT                                           ~10     ~9, '%2F'
          8        CONCAT                                           ~11     ~10, !0
          9        CONCAT                                           ~12     ~11, '%2F%3Fapplication_id%3D'
         10        FETCH_OBJ_R                                      ~13     'application_id'
         11        CONCAT                                           ~14     ~12, ~13
         12        CONCAT                                           ~15     ~14, '%26language%3D'
         13        FETCH_OBJ_R                                      ~16     'language'
         14        CONCAT                                           ~17     ~15, ~16
         15        CONCAT                                           ~18     ~17, '%26'
         16        INIT_NS_FCALL_BY_NAME                                    'Wargaming%5Chttp_build_query'
         17        SEND_VAR_EX                                              !1
         18        DO_FCALL                                      0  $19     
         19        CONCAT                                           ~20     ~18, $19
         20        ASSIGN                                                   !5, ~20
   74    21        INIT_METHOD_CALL                                         'getUrlContents'
         22        SEND_VAR_EX                                              !5
         23        SEND_VAR_EX                                              !3
         24        SEND_VAR_EX                                              !4
         25        DO_FCALL                                      0  $22     
         26        ASSIGN                                                   !6, $22
   77    27        FETCH_DIM_R                                      ~24     !6, 'data'
         28        TYPE_CHECK                                    4          ~24
         29      > JMPZ                                                     ~25, ->36
   79    30    >   NEW                                              $26     'Exception'
         31        SEND_VAL_EX                                              'Wrong+server+or+namespace.'
         32        SEND_VAL_EX                                              404
         33        DO_FCALL                                      0          
         34      > THROW                                         0          $26
         35*       JMP                                                      ->141
   82    36    >   FETCH_DIM_R                                      ~28     !6, 'data'
         37        TYPE_CHECK                                    8          ~28
         38      > JMPZ                                                     ~29, ->45
   85    39    > > JMPZ                                                     !4, ->42
   87    40    > > RETURN                                                   !6
         41*       JMP                                                      ->44
   92    42    >   FETCH_DIM_R                                      ~30     !6, 'data'
         43      > RETURN                                                   ~30
         44*       JMP                                                      ->141
  100    45    >   INIT_NS_FCALL_BY_NAME                                    'Wargaming%5Cjson_decode'
         46        CHECK_FUNC_ARG                                           
         47        FETCH_DIM_FUNC_ARG                               $31     !6, 'data'
         48        SEND_FUNC_ARG                                            $31
         49        SEND_VAR_EX                                              !2
         50        DO_FCALL                                      0  $32     
         51        ASSIGN                                                   !7, $32
  103    52        INIT_NS_FCALL_BY_NAME                                    'Wargaming%5Cis_object'
         53        SEND_VAR_EX                                              !7
         54        DO_FCALL                                      0  $34     
         55      > JMPZ                                                     $34, ->94
  106    56    >   FETCH_OBJ_R                                      ~35     !7, 'status'
         57        IS_EQUAL                                                 ~35, 'ok'
         58      > JMPZ                                                     ~36, ->69
  109    59    > > JMPZ                                                     !4, ->66
  111    60    >   FETCH_OBJ_R                                      ~37     !7, 'data'
         61        INIT_ARRAY                                       ~38     ~37, 'data'
         62        FETCH_DIM_R                                      ~39     !6, 'headers'
         63        ADD_ARRAY_ELEMENT                                ~38     ~39, 'headers'
         64      > RETURN                                                   ~38
         65*       JMP                                                      ->68
  116    66    >   FETCH_OBJ_R                                      ~40     !7, 'data'
         67      > RETURN                                                   ~40
         68*       JMP                                                      ->93
  121    69    >   FETCH_OBJ_R                                      ~41     !7, 'status'
         70        IS_EQUAL                                                 ~41, 'error'
         71      > JMPZ                                                     ~42, ->88
  124    72    >   NEW                                              $43     'Exception'
         73        INIT_METHOD_CALL                                         'translateError'
         74        CHECK_FUNC_ARG                                           
         75        FETCH_OBJ_FUNC_ARG                               $44     !7, 'error'
         76        FETCH_OBJ_FUNC_ARG                               $45     $44, 'message'
         77        SEND_FUNC_ARG                                            $45
         78        SEND_VAR_EX                                              !0
         79        DO_FCALL                                      0  $46     
         80        SEND_VAR_NO_REF_EX                                       $46
         81        CHECK_FUNC_ARG                                           
         82        FETCH_OBJ_FUNC_ARG                               $47     !7, 'error'
         83        FETCH_OBJ_FUNC_ARG                               $48     $47, 'code'
         84        SEND_FUNC_ARG                                            $48
         85        DO_FCALL                                      0          
         86      > THROW                                         0          $43
         87*       JMP                                                      ->93
  129    88    >   NEW                                              $50     'Exception'
         89        SEND_VAL_EX                                              'You+set+wrong+server+or+namespace.'
         90        SEND_VAL_EX                                              404
         91        DO_FCALL                                      0          
         92      > THROW                                         0          $50
         93*       JMP                                                      ->141
  134    94    >   INIT_NS_FCALL_BY_NAME                                    'Wargaming%5Cis_array'
         95        SEND_VAR_EX                                              !7
         96        DO_FCALL                                      0  $52     
         97      > JMPZ                                                     $52, ->136
  137    98    >   FETCH_DIM_R                                      ~53     !7, 'status'
         99        IS_EQUAL                                                 ~53, 'ok'
        100      > JMPZ                                                     ~54, ->111
  140   101    > > JMPZ                                                     !4, ->108
  142   102    >   FETCH_DIM_R                                      ~55     !7, 'data'
        103        INIT_ARRAY                                       ~56     ~55, 'data'
        104        FETCH_DIM_R                                      ~57     !6, 'headers'
        105        ADD_ARRAY_ELEMENT                                ~56     ~57, 'headers'
        106      > RETURN                                                   ~56
        107*       JMP                                                      ->110
  147   108    >   FETCH_DIM_R                                      ~58     !7, 'data'
        109      > RETURN                                                   ~58
        110*       JMP                                                      ->135
  152   111    >   FETCH_DIM_R                                      ~59     !7, 'status'
        112        IS_EQUAL                                                 ~59, 'error'
        113      > JMPZ                                                     ~60, ->130
  155   114    >   NEW                                              $61     'Exception'
        115        INIT_METHOD_CALL                                         'translateError'
        116        CHECK_FUNC_ARG                                           
        117        FETCH_DIM_FUNC_ARG                               $62     !7, 'error'
        118        FETCH_DIM_FUNC_ARG                               $63     $62, 'message'
        119        SEND_FUNC_ARG                                            $63
        120        SEND_VAR_EX                                              !0
        121        DO_FCALL                                      0  $64     
        122        SEND_VAR_NO_REF_EX                                       $64
        123        CHECK_FUNC_ARG                                           
        124        FETCH_DIM_FUNC_ARG                               $65     !7, 'error'
        125        FETCH_DIM_FUNC_ARG                               $66     $65, 'code'
        126        SEND_FUNC_ARG                                            $66
        127        DO_FCALL                                      0          
        128      > THROW                                         0          $61
        129*       JMP                                                      ->135
  160   130    >   NEW                                              $68     'Exception'
        131        SEND_VAL_EX                                              'You+set+wrong+server+or+namespace.'
        132        SEND_VAL_EX                                              404
        133        DO_FCALL                                      0          
        134      > THROW                                         0          $68
        135*       JMP                                                      ->141
  167   136    >   NEW                                              $70     'Exception'
        137        SEND_VAL_EX                                              'Wrong+response+format.'
        138        SEND_VAL_EX                                              502
        139        DO_FCALL                                      0          
        140      > THROW                                         0          $70
  172   141*       RETURN                                                   <false>
  174   142*     > RETURN                                                   null

End of function get

Function geturlcontents:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 39
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 39
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 44, Position 2 = 55
Branch analysis from position: 44
2 jumps found. (Code = 43) Position 1 = 77, Position 2 = 88
Branch analysis from position: 77
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 88
2 jumps found. (Code = 43) Position 1 = 89, Position 2 = 130
Branch analysis from position: 89
2 jumps found. (Code = 77) Position 1 = 106, Position 2 = 127
Branch analysis from position: 106
2 jumps found. (Code = 78) Position 1 = 107, Position 2 = 127
Branch analysis from position: 107
2 jumps found. (Code = 43) Position 1 = 118, Position 2 = 122
Branch analysis from position: 118
1 jumps found. (Code = 42) Position 1 = 126
Branch analysis from position: 126
1 jumps found. (Code = 42) Position 1 = 106
Branch analysis from position: 106
Branch analysis from position: 122
1 jumps found. (Code = 42) Position 1 = 106
Branch analysis from position: 106
Branch analysis from position: 127
1 jumps found. (Code = 42) Position 1 = 132
Branch analysis from position: 132
2 jumps found. (Code = 43) Position 1 = 142, Position 2 = 143
Branch analysis from position: 142
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 143
Branch analysis from position: 127
Branch analysis from position: 130
2 jumps found. (Code = 43) Position 1 = 142, Position 2 = 143
Branch analysis from position: 142
Branch analysis from position: 143
Branch analysis from position: 55
Branch analysis from position: 39
Branch analysis from position: 39
filename:       /in/7TKjl
function name:  getUrlContents
number of ops:  147
compiled vars:  !0 = $url, !1 = $ETag, !2 = $HTTPHeaders, !3 = $buffer, !4 = $error, !5 = $headers, !6 = $body, !7 = $tmp, !8 = $header, !9 = $row, !10 = $status_code
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  185     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
          2        RECV_INIT                                        !2      <false>
  188     3        INIT_NS_FCALL_BY_NAME                                    'Wargaming%5Cis_resource'
          4        CHECK_FUNC_ARG                                           
          5        FETCH_OBJ_FUNC_ARG                               $11     'connection'
          6        SEND_FUNC_ARG                                            $11
          7        DO_FCALL                                      0  $12     
          8        BOOL_NOT                                         ~13     $12
          9      > JMPZ                                                     ~13, ->39
  191    10    >   INIT_NS_FCALL_BY_NAME                                    'Wargaming%5Ccurl_init'
         11        DO_FCALL                                      0  $15     
         12        ASSIGN_OBJ                                               'connection'
         13        OP_DATA                                                  $15
  194    14        INIT_NS_FCALL_BY_NAME                                    'Wargaming%5Ccurl_setopt'
         15        CHECK_FUNC_ARG                                           
         16        FETCH_OBJ_FUNC_ARG                               $16     'connection'
         17        SEND_FUNC_ARG                                            $16
         18        FETCH_CONSTANT                                   ~17     'Wargaming%5CCURLOPT_RETURNTRANSFER'
         19        SEND_VAL_EX                                              ~17
         20        SEND_VAL_EX                                              <true>
         21        DO_FCALL                                      0          
  195    22        INIT_NS_FCALL_BY_NAME                                    'Wargaming%5Ccurl_setopt'
         23        CHECK_FUNC_ARG                                           
         24        FETCH_OBJ_FUNC_ARG                               $19     'connection'
         25        SEND_FUNC_ARG                                            $19
         26        FETCH_CONSTANT                                   ~20     'Wargaming%5CCURLOPT_SSL_VERIFYPEER'
         27        SEND_VAL_EX                                              ~20
         28        SEND_VAL_EX                                              <false>
         29        DO_FCALL                                      0          
  196    30      > JMPZ                                                     !2, ->39
  197    31    >   INIT_NS_FCALL_BY_NAME                                    'Wargaming%5Ccurl_setopt'
         32        CHECK_FUNC_ARG                                           
         33        FETCH_OBJ_FUNC_ARG                               $22     'connection'
         34        SEND_FUNC_ARG                                            $22
         35        FETCH_CONSTANT                                   ~23     'Wargaming%5CCURLOPT_HEADER'
         36        SEND_VAL_EX                                              ~23
         37        SEND_VAL_EX                                              <true>
         38        DO_FCALL                                      0          
  202    39    >   INIT_NS_FCALL_BY_NAME                                    'Wargaming%5Cis_null'
         40        SEND_VAR_EX                                              !1
         41        DO_FCALL                                      0  $25     
         42        BOOL_NOT                                         ~26     $25
         43      > JMPZ                                                     ~26, ->55
  204    44    >   INIT_NS_FCALL_BY_NAME                                    'Wargaming%5Ccurl_setopt'
         45        CHECK_FUNC_ARG                                           
         46        FETCH_OBJ_FUNC_ARG                               $27     'connection'
         47        SEND_FUNC_ARG                                            $27
         48        FETCH_CONSTANT                                   ~28     'Wargaming%5CCURLOPT_HTTPHEADER'
         49        SEND_VAL_EX                                              ~28
  205    50        CONCAT                                           ~29     'If-None-Match%3A+%22', !1
         51        CONCAT                                           ~30     ~29, '%22'
         52        INIT_ARRAY                                       ~31     ~30
         53        SEND_VAL_EX                                              ~31
         54        DO_FCALL                                      0          
  211    55    >   INIT_NS_FCALL_BY_NAME                                    'Wargaming%5Ccurl_setopt'
         56        CHECK_FUNC_ARG                                           
         57        FETCH_OBJ_FUNC_ARG                               $33     'connection'
         58        SEND_FUNC_ARG                                            $33
         59        FETCH_CONSTANT                                   ~34     'Wargaming%5CCURLOPT_URL'
         60        SEND_VAL_EX                                              ~34
         61        SEND_VAR_EX                                              !0
         62        DO_FCALL                                      0          
  214    63        INIT_NS_FCALL_BY_NAME                                    'Wargaming%5Ccurl_exec'
         64        CHECK_FUNC_ARG                                           
         65        FETCH_OBJ_FUNC_ARG                               $36     'connection'
         66        SEND_FUNC_ARG                                            $36
         67        DO_FCALL                                      0  $37     
         68        ASSIGN                                                   !3, $37
  217    69        INIT_NS_FCALL_BY_NAME                                    'Wargaming%5Ccurl_error'
         70        CHECK_FUNC_ARG                                           
         71        FETCH_OBJ_FUNC_ARG                               $39     'connection'
         72        SEND_FUNC_ARG                                            $39
         73        DO_FCALL                                      0  $40     
         74        ASSIGN                                                   !4, $40
  219    75        IS_NOT_IDENTICAL                                         !4, ''
         76      > JMPZ                                                     ~42, ->88
  221    77    >   NEW                                              $43     'Exception'
         78        CONCAT                                           ~44     '%28Curl%29+', !4
         79        SEND_VAL_EX                                              ~44
         80        INIT_NS_FCALL_BY_NAME                                    'Wargaming%5Ccurl_errno'
         81        CHECK_FUNC_ARG                                           
         82        FETCH_OBJ_FUNC_ARG                               $45     'connection'
         83        SEND_FUNC_ARG                                            $45
         84        DO_FCALL                                      0  $46     
         85        SEND_VAR_NO_REF_EX                                       $46
         86        DO_FCALL                                      0          
         87      > THROW                                         0          $43
  226    88    > > JMPZ                                                     !2, ->130
  229    89    >   INIT_NS_FCALL_BY_NAME                                    'Wargaming%5Cexplode'
         90        SEND_VAL_EX                                              '%0D%0A%0D%0A'
         91        SEND_VAR_EX                                              !3
         92        SEND_VAL_EX                                              2
         93        DO_FCALL                                      0  $48     
         94        FETCH_LIST_R                                     $49     $48, 0
         95        ASSIGN                                                   !5, $49
         96        FETCH_LIST_R                                     $51     $48, 1
         97        ASSIGN                                                   !6, $51
         98        FREE                                                     $48
  232    99        INIT_NS_FCALL_BY_NAME                                    'Wargaming%5Cexplode'
        100        SEND_VAL_EX                                              '%0D%0A'
        101        SEND_VAR_EX                                              !5
        102        DO_FCALL                                      0  $53     
        103        ASSIGN                                                   !5, $53
  234   104        ASSIGN                                                   !7, <array>
  235   105      > FE_RESET_R                                       $56     !5, ->127
        106    > > FE_FETCH_R                                               $56, !8, ->127
  237   107    >   INIT_NS_FCALL_BY_NAME                                    'Wargaming%5Cexplode'
        108        SEND_VAL_EX                                              '%3A+'
        109        SEND_VAR_EX                                              !8
        110        SEND_VAL_EX                                              2
        111        DO_FCALL                                      0  $57     
        112        ASSIGN                                                   !9, $57
  238   113        INIT_NS_FCALL_BY_NAME                                    'Wargaming%5Ccount'
        114        SEND_VAR_EX                                              !9
        115        DO_FCALL                                      0  $59     
        116        IS_EQUAL                                                 $59, 1
        117      > JMPZ                                                     ~60, ->122
  240   118    >   FETCH_DIM_R                                      ~61     !9, 0
        119        ASSIGN_DIM                                               !7, ~61
        120        OP_DATA                                                  ''
        121      > JMP                                                      ->126
  244   122    >   FETCH_DIM_R                                      ~63     !9, 0
        123        FETCH_DIM_R                                      ~65     !9, 1
        124        ASSIGN_DIM                                               !7, ~63
        125        OP_DATA                                                  ~65
  235   126    > > JMP                                                      ->106
        127    >   FE_FREE                                                  $56
  251   128        ASSIGN                                                   !5, !7
        129      > JMP                                                      ->132
  255   130    >   ASSIGN                                                   !5, <array>
  256   131        ASSIGN                                                   !6, !3
  261   132    >   INIT_NS_FCALL_BY_NAME                                    'Wargaming%5Ccurl_getinfo'
        133        CHECK_FUNC_ARG                                           
        134        FETCH_OBJ_FUNC_ARG                               $69     'connection'
        135        SEND_FUNC_ARG                                            $69
        136        FETCH_CONSTANT                                   ~70     'Wargaming%5CCURLINFO_HTTP_CODE'
        137        SEND_VAL_EX                                              ~70
        138        DO_FCALL                                      0  $71     
        139        ASSIGN                                                   !10, $71
  264   140        IS_EQUAL                                                 !10, 304
        141      > JMPZ                                                     ~73, ->143
  266   142    >   ASSIGN                                                   !6, <true>
  270   143    >   INIT_ARRAY                                       ~75     !5, 'headers'
        144        ADD_ARRAY_ELEMENT                                ~75     !6, 'data'
        145      > RETURN                                          

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
284.28 ms | 1420 KiB | 42 Q