3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * SoapClient with protection on fatal error * * @category Smile * @package Smile_Soap * @author Laurent MINGUET <lamin@smile.fr> * @copyright 2014 Smile * */ class Smile_Soap_Client extends SoapClient { /** * construct * * @param string $wsdl wsdl url to use * @param array $options table of options * * @return $this * * @link http://www.php.net/manual/en/soapclient.soapclient.php */ public function __construct($wsdl = null, $options = array()) { $options = $this->_initOptions($options); self::startErrorHandlerForFatal('WSDL'); $res = @parent::__construct($wsdl, $options); self::stopErrorHandlerForFatal(); return $res; } /** * init the options * * @param array $options array of options * * @return array */ protected function _initOptions($options) { $defaultOptions = array( 'soap_version' => SOAP_1_1, 'authentication' => SOAP_AUTHENTICATION_BASIC, 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, 'exceptions' => true, 'timeout' => (int)ini_get('default_socket_timeout'), // in seconds ); $options = array_merge($defaultOptions, $options); ini_set('default_socket_timeout', (int)$options['timeout']); return $options; } /****************************************************************** *********** METHODES AND PROPERTIES FOR ERROR HANDLING *********** ******************************************************************/ /** * default code to use for error handling * @var null|string */ static private $_defaultCode = null; /** * start handling the error to catch fatal errors * * @param string $defaultCode default code to use * * @return void */ static public function startErrorHandlerForFatal($defaultCode) { self::$_defaultCode = $defaultCode; set_error_handler('Smile_Soap_Client::errorHandlerForFatal', E_ALL); } /** * stop handling the error to catch fatal errors * * @return void */ static public function stopErrorHandlerForFatal() { self::$_defaultCode = null; restore_error_handler(); } /** * handling the error to catch fatal errors * * @param int $errno error number * @param string|exception $errstr error message * @param string $errfile file of the error * @param int $errline line of the error * * @return void * @throws SoapFault */ static public function errorHandlerForFatal($errno, $errstr, $errfile = null, $errline = null) { $code = self::$_defaultCode; self::stopErrorHandlerForFatal(); if ($errstr instanceof Exception) { if ($errstr->getCode()) { $code = $errstr->getCode(); } $errstr = $errstr->getMessage(); } elseif (!is_string($errstr)) { $errstr = 'Unknown error'; } throw new SoapFault($code, $errstr.' (error ['.$errno.'])'); } } try { $client = new Smile_Soap_Client(); echo '---===[OK]===---'."\n"; } catch (Exception $e) { echo '---===[ERROR]===---'."\n"; print_r($e); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 6
Branch analysis from position: 6
2 jumps found. (Code = 107) Position 1 = 7, Position 2 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KeX9d
function name:  (null)
number of ops:  12
compiled vars:  !0 = $client, !1 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   DECLARE_CLASS                                            'smile_soap_client', 'soapclient'
  123     1        NEW                                              $2      'Smile_Soap_Client'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
  124     4        ECHO                                                     '---%3D%3D%3D%5BOK%5D%3D%3D%3D---%0A'
          5      > JMP                                                      ->11
  125     6  E > > CATCH                                       last         'Exception'
  126     7    >   ECHO                                                     '---%3D%3D%3D%5BERROR%5D%3D%3D%3D---%0A'
  127     8        INIT_FCALL                                               'print_r'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                                 
  128    11    > > RETURN                                                   1

Class Smile_Soap_Client:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KeX9d
function name:  __construct
number of ops:  20
compiled vars:  !0 = $wsdl, !1 = $options, !2 = $res
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV_INIT                                        !0      null
          1        RECV_INIT                                        !1      <array>
   25     2        INIT_METHOD_CALL                                         '_initOptions'
          3        SEND_VAR_EX                                              !1
          4        DO_FCALL                                      0  $3      
          5        ASSIGN                                                   !1, $3
   27     6        INIT_STATIC_METHOD_CALL                                  'startErrorHandlerForFatal'
          7        SEND_VAL_EX                                              'WSDL'
          8        DO_FCALL                                      0          
   28     9        BEGIN_SILENCE                                    ~6      
         10        INIT_STATIC_METHOD_CALL                                  
         11        SEND_VAR_EX                                              !0
         12        SEND_VAR_EX                                              !1
         13        DO_FCALL                                      0  $7      
         14        END_SILENCE                                              ~6
         15        ASSIGN                                                   !2, $7
   29    16        INIT_STATIC_METHOD_CALL                                  'stopErrorHandlerForFatal'
         17        DO_FCALL                                      0          
   31    18      > RETURN                                                   !2
   32    19*     > RETURN                                                   null

End of function __construct

Function _initoptions:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KeX9d
function name:  _initOptions
number of ops:  27
compiled vars:  !0 = $options, !1 = $defaultOptions
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   RECV                                             !0      
   44     1        FETCH_CONSTANT                                   ~2      'SOAP_1_1'
          2        INIT_ARRAY                                       ~3      ~2, 'soap_version'
   45     3        FETCH_CONSTANT                                   ~4      'SOAP_AUTHENTICATION_BASIC'
          4        ADD_ARRAY_ELEMENT                                ~3      ~4, 'authentication'
   46     5        FETCH_CONSTANT                                   ~5      'SOAP_SINGLE_ELEMENT_ARRAYS'
          6        ADD_ARRAY_ELEMENT                                ~3      ~5, 'features'
   44     7        ADD_ARRAY_ELEMENT                                ~3      <true>, 'exceptions'
   48     8        INIT_FCALL                                               'ini_get'
          9        SEND_VAL                                                 'default_socket_timeout'
         10        DO_ICALL                                         $6      
         11        CAST                                          4  ~7      $6
         12        ADD_ARRAY_ELEMENT                                ~3      ~7, 'timeout'
   43    13        ASSIGN                                                   !1, ~3
   50    14        INIT_FCALL                                               'array_merge'
         15        SEND_VAR                                                 !1
         16        SEND_VAR                                                 !0
         17        DO_ICALL                                         $9      
         18        ASSIGN                                                   !0, $9
   52    19        INIT_FCALL                                               'ini_set'
         20        SEND_VAL                                                 'default_socket_timeout'
         21        FETCH_DIM_R                                      ~11     !0, 'timeout'
         22        CAST                                          4  ~12     ~11
         23        SEND_VAL                                                 ~12
         24        DO_ICALL                                                 
   54    25      > RETURN                                                   !0
   55    26*     > RETURN                                                   null

End of function _initoptions

Function starterrorhandlerforfatal:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KeX9d
function name:  startErrorHandlerForFatal
number of ops:  8
compiled vars:  !0 = $defaultCode
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   75     0  E >   RECV                                             !0      
   77     1        ASSIGN_STATIC_PROP                                       '_defaultCode'
          2        OP_DATA                                                  !0
   78     3        INIT_FCALL                                               'set_error_handler'
          4        SEND_VAL                                                 'Smile_Soap_Client%3A%3AerrorHandlerForFatal'
          5        SEND_VAL                                                 32767
          6        DO_ICALL                                                 
   79     7      > RETURN                                                   null

End of function starterrorhandlerforfatal

Function stoperrorhandlerforfatal:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KeX9d
function name:  stopErrorHandlerForFatal
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   88     0  E >   ASSIGN_STATIC_PROP                                       '_defaultCode'
          1        OP_DATA                                                  null
   89     2        INIT_FCALL                                               'restore_error_handler'
          3        DO_ICALL                                                 
   90     4      > RETURN                                                   null

End of function stoperrorhandlerforfatal

Function errorhandlerforfatal:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 20
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 16
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 16
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 24
Branch analysis from position: 23
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 24
filename:       /in/KeX9d
function name:  errorHandlerForFatal
number of ops:  33
compiled vars:  !0 = $errno, !1 = $errstr, !2 = $errfile, !3 = $errline, !4 = $code
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  103     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      null
          3        RECV_INIT                                        !3      null
  105     4        FETCH_STATIC_PROP_R          unknown             ~5      '_defaultCode'
          5        ASSIGN                                                   !4, ~5
  106     6        INIT_STATIC_METHOD_CALL                                  'stopErrorHandlerForFatal'
          7        DO_FCALL                                      0          
  108     8        INSTANCEOF                                               !1, 'Exception'
          9      > JMPZ                                                     ~8, ->20
  109    10    >   INIT_METHOD_CALL                                         !1, 'getCode'
         11        DO_FCALL                                      0  $9      
         12      > JMPZ                                                     $9, ->16
  110    13    >   INIT_METHOD_CALL                                         !1, 'getCode'
         14        DO_FCALL                                      0  $10     
         15        ASSIGN                                                   !4, $10
  112    16    >   INIT_METHOD_CALL                                         !1, 'getMessage'
         17        DO_FCALL                                      0  $12     
         18        ASSIGN                                                   !1, $12
         19      > JMP                                                      ->24
  113    20    >   TYPE_CHECK                                   64  ~14     !1
         21        BOOL_NOT                                         ~15     ~14
         22      > JMPZ                                                     ~15, ->24
  114    23    >   ASSIGN                                                   !1, 'Unknown+error'
  117    24    >   NEW                                              $17     'SoapFault'
         25        SEND_VAR_EX                                              !4
         26        CONCAT                                           ~18     !1, '+%28error+%5B'
         27        CONCAT                                           ~19     ~18, !0
         28        CONCAT                                           ~20     ~19, '%5D%29'
         29        SEND_VAL_EX                                              ~20
         30        DO_FCALL                                      0          
         31      > THROW                                         0          $17
  118    32*     > RETURN                                                   null

End of function errorhandlerforfatal

End of class Smile_Soap_Client.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.15 ms | 1408 KiB | 25 Q