3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @package at.exceptable * @author Adrian <adrian@enspi.red> * @copyright 2014 - 2016 * @license GPL-3.0 (only) * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License, version 3. * The right to apply the terms of later versions of the GPL is RESERVED. * * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along with this program. * If not, see <http://www.gnu.org/licenses/gpl-3.0.txt>. */ declare(strict_types = 1); namespace at\exceptable; use ErrorException, Throwable; class Handler { /** @type _Handler[] list of registered error handlers. */ private $_errorHandlers = []; /** @type _Handler[] list of registered exception handlers. */ private $_exceptionHandlers = []; /** @type _Handler[] list of registered shutdown handlers. */ private $_shutdownHandlers = []; /** @type bool is this Handler currently registered (active)? */ private $_registered = false; /** @type int error types which should be thrown as ErrorExceptions. */ private $_throw = 0; /** * registers this handler to invoke a callback, and then restores the previous handler(s). * * @param callable $callback the callback to execute * @param mixed …$arguments arguments to pass to the callback * @return mixed the value returned from the callback */ public function during(callable $callback, ...$arguments) { $this->register(); $value = $callback(...$arguments); $this->unregister(); return $value; } /** * adds an error handler. * @see <http://php.net/set_error_handler> $error_handler * * @param callable $handler the error handler to add * @param int $severity the error severity to trigger this handler * (one of the E_* constants, or omit for "any severity") * @return Handler $this */ public function onError(callable $handler, int $severity=null) : Handler { $this->_errorHandlers[] = new _Handler($handler, _Handler::TYPE_ERROR, $severity); return $this; } /** * adds an exception handler. * @see <http://php.net/set_exception_handler> $exception_handler * * @param callable $handler the exception handler to add * @param int $severity the exception severity to trigger this handler * (one of Exceptable::ERROR|WARNING|NOTICE, or omit for "any severity") * @return Handler $this */ public function onException(callable $handler, int $severity=null) : Handler { $this->_exceptionHandlers[] = new _Handler($handler, _Handler::TYPE_EXCEPTION, $severity); return $this; } /** * adds a shutdown handler. * @see <http:/php.net/register_shutdown_handler> $callback * * @param callable $handler the shutdown handler to add * @param mixed $arguments optional agrs to pass to shutdown handler when invoked * @return Handler $this */ public function onShutdown(callable $handler, ...$arguments) : Handler { $this->_shutdownHandlers[] = (new _Handler($handler, _Handler::TYPE_SHUTDOWN)) ->defaultArguments($arguments); return $this; } /** * registers this Handler's error, exception, and shutdown handlers. * * @return Handler $this */ public function register() : Handler { set_error_handler(function(...$args) { return $this->_error(...$args); }); set_exception_handler(function(...$args) { return $this->_exception(...$args); }); register_shutdown_function(function(...$args) { return $this->_shutdown(...$args); }); $this->_registered = true; return $this; } /** * specifies the ErrorException class for this handler to use. * @todo keep this? * * @param string $fqcn fully qualified ErrorException classname * @return Handler $this */ public function setErrorExceptionClass(string $fqcn) : Handler { throw new ExceptableException('not yet implemented'); } /** * sets error types which should be thrown as ErrorExceptions. * * @param int $severity the error types to be thrown * (defaults to Errors and Warnings; use 0 to stop throwing) * @return Handler $this */ public function throw(int $severity=E_ERROR|E_WARNING) : Handler { $this->_throw = $severity; return $this; } /** * un-registers this Handler. * * @return Handler $this */ public function unregister() : Handler { restore_error_handler(); restore_exception_handler(); // shutdown functions can't be unregistered; just have to flag them so they're non-ops :( $this->_registered = false; return $this; } /** * handles php errors. * * @param int $s error severity * @param string $m error message * @param string $f error file * @param int $l error line * @param array $c error context * @throws ErrorException if error severity matches $_throw setting * @return bool true if error handled; false if php's error handler should continue */ protected function _error(int $s, string $m, string $f, int $l, array $c) : bool { if (! $this->_registered) { return false; } if (($s & $this->_throw) === $s) { throw new ErrorException($m, 0, $s, $f, $l); } foreach ($this->_errorHandlers as $handler) { if ($handler->handles(_Handler::TYPE_ERROR, $s) && $handler->handle($s, $m, $f, $l, $c)) { return true; } } return false; } /** * handles uncaught exceptions. * * @param Throwable $e the exception * @throws ExceptableException if no registered handler handles the exception */ protected function _exception(Throwable $e) { if (! $this->_registered) { return; } $severity = method_exists($e, 'getSeverity') ? $e->getSeverity() : Exceptable::ERROR; foreach ($this->_exceptionHandlers as $handler) { if ($handler->handles(_Handler::TYPE_EXCEPTION, $severity) && $handler->handle($e)) { return; } } throw new ExceptableException(ExceptableException::UNCAUGHT_EXCEPTION, $e); } /** * handles shutdown sequence. * * @throws ErrorException if shutdown is due to a fatal error */ protected function _shutdown() { if (! $this->_registered) { return; } $e = error_get_last(); if ($e && $e['type'] === E_ERROR) { throw new ErrorException($e['message'], 0, $e['type'], $e['file'], $e['line']); } foreach ($this->_shutdownHandlers as $handler) { $handler(); } } } /** @internal utility class for wrapping callables as error/exception/shutdown handlers. */ class _Handler { const TYPE_ERROR = 1; const TYPE_EXCEPTION = 2; const TYPE_SHUTDOWN = 3; const ANY_SEVERITY = -1; protected $_arguments = []; protected $_handler; protected $_type; protected $_severity; public function __construct(callable $handler, int $type, int $severity=null) { $this->_handler = $handler; $this->_type = $type; $this->_severity = $severity ?? self::ANY_SEVERITY; } /** @internal invokes the callback with given arguments. */ public function handle(...$arguments) : bool { try { return ($this->_handler)(...($arguments + $this->_arguments)); } catch (Throwable $e) { throw new ExceptableException( ExceptableException::INVALID_HANDLER, ['type' => $this->_type()], $e ); } } /** @internal checks whether this handler is registered for the given severity. */ public function handles(int $type, int $severity) : bool { return $type === $this->_type && ($this->_severity === self::ANY_SEVERITY || ($severity && $this->_severity) === $severity); } /** @internal specifies default arguments to pass to handler. */ public function defaultArguments(array $arguments) { $this->_arguments = $arguments; return $this; } /** @internal gets a string representation of the handler type. */ protected function _type() : string { switch ($this->_type) { case self::TYPE_ERROR : return 'error'; case self::TYPE_EXCEPTION : return 'exception'; case self::TYPE_SHUTDOWN : return 'shutdown'; default : return (string) $this->_type; } } } interface Exceptable extends \Throwable { /** * exception severity levels. * * @type int ERROR error * @type int WARNING warning * @type int NOTICE notice */ const ERROR = E_ERROR; const WARNING = E_WARNING; const NOTICE = E_NOTICE; /** * default info for unknown/generic exception cases. * * @type int DEFAULT_CODE * @type int DEFAULT_MESSAGE * @type int DEFAULT_SEVERITY */ const DEFAULT_CODE = 0; const DEFAULT_MESSAGE = 'unknown error.'; const DEFAULT_SEVERITY = self::ERROR; /** * gets information about a code known to the implementing class. * * @param int $code the exception code to look up * @throws UnderflowException if the code is not known to the implementation * @return array a map of info about the code, * including (at a minimum) its "code", "severity", and "message". */ public static function get_info(int $code) : array; /** * checks whether the implementation has info about the given code. * * @param int $code the code to check * @return bool true if the code is known; false otherwise */ public static function has_info(int $code) : bool; /** * @param string $0 exception message * if omitted, a message must be set based on the exception code * @param int $1 exception code * if omitted, a default code must be set * @param Throwable $2 previous exception * @param array $3 additional exception context * @throws ExceptableException if argument(s) are invalid */ public function __construct(...$args); /** * adds contextual info to this exception. * * @param array $context map of info to add * @return $this */ public function addContext(array $context) : Exceptable; /** * gets contextual info about this exception. * * @return array map of contextual info about this exception */ public function getContext() : array; /** * traverses the chain of previous exception(s) and gets the root exception. * * @return Throwable the root exception */ public function getRoot() : \Throwable; /** * gets exception severity. * * @return int the exception severity */ public function getSeverity() : int; /** * checks the exception severity. * * @return bool true if exception severity is "Error"; false otherwise */ public function isError() : bool; /** * checks the exception severity. * * @return bool true if exception severity is "Warning"; false otherwise */ public function isWarning() : bool; /** * checks the exception severity. * * @return bool true if exception severity is "Notice"; false otherwise */ public function isNotice() : bool; /** * adds contextual info to this exception. * * @param int $severity one of Exceptable::ERROR|WARNING|NOTICE * @throws ExceptableException if severity is invalid * @return $this */ public function setSeverity(int $severity) : Exceptable; } class ExceptableException extends Exception { /** * @type int NO_SUCH_CODE invalid exception code. * @type int INVALID_CONSTRUCT_ARGS invalid/out-of-order constructor arguments. * @type int INVALID_SEVERITY invalid severity level. * @type int UNCAUGHT_EXCEPTION uncaught/unhandled exception during runtime. * @type int INVALID_HANDLER invalid handler (e.g., wrong signature, or throws). */ const NO_SUCH_CODE = 1; const INVALID_CONSTRUCT_ARGS = (1<<1); const INVALID_SEVERITY = (1<<2); const UNCAUGHT_EXCEPTION = (1<<3); const INVALID_HANDLER = (1<<4); /** @see Exceptable::INFO */ const INFO = [ self::NO_SUCH_CODE => [ 'message' => 'no such code', 'severity' => Exceptable::WARNING, 'tr_message' => "no exception code '{code}' is known" ], self::INVALID_CONSTRUCT_ARGS => [ 'message' => 'constructor arguments are invalid and/or out of order', 'severity' => Exceptable::ERROR, 'tr_message' => "constructor arguments are invalid and/or out of order: {args}" ], self::INVALID_SEVERITY => [ 'message' => 'invalid severity', 'severity' => Exceptable::WARNING, 'tr_message' => 'severity must be one of Exceptable::ERROR|WARNING|NOTICE; {severity} provided' ], self::UNCAUGHT_EXCEPTION => [ 'message' => 'uncaught exception', 'severity' => Exceptable::ERROR, 'tr_message' => 'no registered handler caught exception: {__rootMessage__}' ], self::INVALID_HANDLER => [ 'message' => 'invalid handler', 'severity' => Exceptable::ERROR, 'tr_message' => 'invalid handler [{type}]: {__rootMessage__}' ] ]; } $handler = new Handler(); $handler->onError(function($s, $m, $f, $l, $c) { error_log($m); }) ->register(); trigger_error('foo!', E_USER_NOTICE);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/u8c1o
function name:  (null)
number of ops:  17
compiled vars:  !0 = $handler
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  279     0  E >   DECLARE_CLASS                                            'at%5Cexceptable%5Cexceptable'
  392     1        DECLARE_CLASS                                            'at%5Cexceptable%5Cexceptableexception', 'at%5Cexceptable%5Cexception'
  438     2        NEW                                              $1      'at%5Cexceptable%5CHandler'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $1
  439     5        INIT_METHOD_CALL                                         !0, 'onError'
          6        DECLARE_LAMBDA_FUNCTION                                  '%00at%5Cexceptable%5C%7Bclosure%7D%2Fin%2Fu8c1o%3A439%245'
          7        SEND_VAL_EX                                              ~4
          8        DO_FCALL                                      0  $5      
  440     9        INIT_METHOD_CALL                                         $5, 'register'
         10        DO_FCALL                                      0          
  442    11        INIT_NS_FCALL_BY_NAME                                    'at%5Cexceptable%5Ctrigger_error'
         12        SEND_VAL_EX                                              'foo%21'
         13        FETCH_CONSTANT                                   ~7      'at%5Cexceptable%5CE_USER_NOTICE'
         14        SEND_VAL_EX                                              ~7
         15        DO_FCALL                                      0          
         16      > RETURN                                                   1

Function %00at%5Cexceptable%5C%7Bclosure%7D%2Fin%2Fu8c1o%3A105%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/u8c1o
function name:  at\exceptable\{closure}
number of ops:  8
compiled vars:  !0 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  105     0  E >   RECV_VARIADIC                                    !0      
          1        FETCH_THIS                                       $1      
          2        INIT_METHOD_CALL                                         $1, '_error'
          3        SEND_UNPACK                                              !0
          4        CHECK_UNDEF_ARGS                                         
          5        DO_FCALL                                      1  $2      
          6      > RETURN                                                   $2
          7*     > RETURN                                                   null

End of function %00at%5Cexceptable%5C%7Bclosure%7D%2Fin%2Fu8c1o%3A105%240

Function %00at%5Cexceptable%5C%7Bclosure%7D%2Fin%2Fu8c1o%3A106%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/u8c1o
function name:  at\exceptable\{closure}
number of ops:  8
compiled vars:  !0 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  106     0  E >   RECV_VARIADIC                                    !0      
          1        FETCH_THIS                                       $1      
          2        INIT_METHOD_CALL                                         $1, '_exception'
          3        SEND_UNPACK                                              !0
          4        CHECK_UNDEF_ARGS                                         
          5        DO_FCALL                                      1  $2      
          6      > RETURN                                                   $2
          7*     > RETURN                                                   null

End of function %00at%5Cexceptable%5C%7Bclosure%7D%2Fin%2Fu8c1o%3A106%241

Function %00at%5Cexceptable%5C%7Bclosure%7D%2Fin%2Fu8c1o%3A107%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/u8c1o
function name:  at\exceptable\{closure}
number of ops:  8
compiled vars:  !0 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  107     0  E >   RECV_VARIADIC                                    !0      
          1        FETCH_THIS                                       $1      
          2        INIT_METHOD_CALL                                         $1, '_shutdown'
          3        SEND_UNPACK                                              !0
          4        CHECK_UNDEF_ARGS                                         
          5        DO_FCALL                                      1  $2      
          6      > RETURN                                                   $2
          7*     > RETURN                                                   null

End of function %00at%5Cexceptable%5C%7Bclosure%7D%2Fin%2Fu8c1o%3A107%242

Function %00at%5Cexceptable%5C%7Bclosure%7D%2Fin%2Fu8c1o%3A439%245:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/u8c1o
function name:  at\exceptable\{closure}
number of ops:  9
compiled vars:  !0 = $s, !1 = $m, !2 = $f, !3 = $l, !4 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  439     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
          4        RECV                                             !4      
          5        INIT_NS_FCALL_BY_NAME                                    'at%5Cexceptable%5Cerror_log'
          6        SEND_VAR_EX                                              !1
          7        DO_FCALL                                      0          
          8      > RETURN                                                   null

End of function %00at%5Cexceptable%5C%7Bclosure%7D%2Fin%2Fu8c1o%3A439%245

Class at\exceptable\Handler:
Function during:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/u8c1o
function name:  during
number of ops:  13
compiled vars:  !0 = $callback, !1 = $arguments, !2 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   50     0  E >   RECV                                             !0      
          1        RECV_VARIADIC                                    !1      
   51     2        INIT_METHOD_CALL                                         'register'
          3        DO_FCALL                                      0          
   52     4        INIT_DYNAMIC_CALL                                        !0
          5        SEND_UNPACK                                              !1
          6        CHECK_UNDEF_ARGS                                         
          7        DO_FCALL                                      1  $4      
          8        ASSIGN                                                   !2, $4
   53     9        INIT_METHOD_CALL                                         'unregister'
         10        DO_FCALL                                      0          
   54    11      > RETURN                                                   !2
   55    12*     > RETURN                                                   null

End of function during

Function onerror:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/u8c1o
function name:  onError
number of ops:  16
compiled vars:  !0 = $handler, !1 = $severity
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   66     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
   67     2        NEW                                              $4      'at%5Cexceptable%5C_Handler'
          3        SEND_VAR_EX                                              !0
          4        FETCH_CLASS_CONSTANT                             ~5      'at%5Cexceptable%5C_Handler', 'TYPE_ERROR'
          5        SEND_VAL_EX                                              ~5
          6        SEND_VAR_EX                                              !1
          7        DO_FCALL                                      0          
          8        FETCH_OBJ_W                                      $2      '_errorHandlers'
          9        ASSIGN_DIM                                               $2
         10        OP_DATA                                                  $4
   68    11        FETCH_THIS                                       ~7      
         12        VERIFY_RETURN_TYPE                                       ~7
         13      > RETURN                                                   ~7
   69    14*       VERIFY_RETURN_TYPE                                       
         15*     > RETURN                                                   null

End of function onerror

Function onexception:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/u8c1o
function name:  onException
number of ops:  16
compiled vars:  !0 = $handler, !1 = $severity
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   80     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
   81     2        NEW                                              $4      'at%5Cexceptable%5C_Handler'
          3        SEND_VAR_EX                                              !0
          4        FETCH_CLASS_CONSTANT                             ~5      'at%5Cexceptable%5C_Handler', 'TYPE_EXCEPTION'
          5        SEND_VAL_EX                                              ~5
          6        SEND_VAR_EX                                              !1
          7        DO_FCALL                                      0          
          8        FETCH_OBJ_W                                      $2      '_exceptionHandlers'
          9        ASSIGN_DIM                                               $2
         10        OP_DATA                                                  $4
   82    11        FETCH_THIS                                       ~7      
         12        VERIFY_RETURN_TYPE                                       ~7
         13      > RETURN                                                   ~7
   83    14*       VERIFY_RETURN_TYPE                                       
         15*     > RETURN                                                   null

End of function onexception

Function onshutdown:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/u8c1o
function name:  onShutdown
number of ops:  18
compiled vars:  !0 = $handler, !1 = $arguments
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   93     0  E >   RECV                                             !0      
          1        RECV_VARIADIC                                    !1      
   94     2        NEW                                              $4      'at%5Cexceptable%5C_Handler'
          3        SEND_VAR_EX                                              !0
          4        FETCH_CLASS_CONSTANT                             ~5      'at%5Cexceptable%5C_Handler', 'TYPE_SHUTDOWN'
          5        SEND_VAL_EX                                              ~5
          6        DO_FCALL                                      0          
   95     7        INIT_METHOD_CALL                                         $4, 'defaultArguments'
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0  $7      
   94    10        FETCH_OBJ_W                                      $2      '_shutdownHandlers'
         11        ASSIGN_DIM                                               $2
   95    12        OP_DATA                                                  $7
   96    13        FETCH_THIS                                       ~8      
         14        VERIFY_RETURN_TYPE                                       ~8
         15      > RETURN                                                   ~8
   97    16*       VERIFY_RETURN_TYPE                                       
         17*     > RETURN                                                   null

End of function onshutdown

Function register:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/u8c1o
function name:  register
number of ops:  19
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  105     0  E >   INIT_NS_FCALL_BY_NAME                                    'at%5Cexceptable%5Cset_error_handler'
          1        DECLARE_LAMBDA_FUNCTION                                  '%00at%5Cexceptable%5C%7Bclosure%7D%2Fin%2Fu8c1o%3A105%240'
          2        SEND_VAL_EX                                              ~0
          3        DO_FCALL                                      0          
  106     4        INIT_NS_FCALL_BY_NAME                                    'at%5Cexceptable%5Cset_exception_handler'
          5        DECLARE_LAMBDA_FUNCTION                                  '%00at%5Cexceptable%5C%7Bclosure%7D%2Fin%2Fu8c1o%3A106%241'
          6        SEND_VAL_EX                                              ~2
          7        DO_FCALL                                      0          
  107     8        INIT_NS_FCALL_BY_NAME                                    'at%5Cexceptable%5Cregister_shutdown_function'
          9        DECLARE_LAMBDA_FUNCTION                                  '%00at%5Cexceptable%5C%7Bclosure%7D%2Fin%2Fu8c1o%3A107%242'
         10        SEND_VAL_EX                                              ~4
         11        DO_FCALL                                      0          
  108    12        ASSIGN_OBJ                                               '_registered'
         13        OP_DATA                                                  <true>
  109    14        FETCH_THIS                                       ~7      
         15        VERIFY_RETURN_TYPE                                       ~7
         16      > RETURN                                                   ~7
  110    17*       VERIFY_RETURN_TYPE                                       
         18*     > RETURN                                                   null

End of function register

Function seterrorexceptionclass:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/u8c1o
function name:  setErrorExceptionClass
number of ops:  7
compiled vars:  !0 = $fqcn
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  119     0  E >   RECV                                             !0      
  120     1        NEW                                              $1      'at%5Cexceptable%5CExceptableException'
          2        SEND_VAL_EX                                              'not+yet+implemented'
          3        DO_FCALL                                      0          
          4      > THROW                                         0          $1
  121     5*       VERIFY_RETURN_TYPE                                       
          6*     > RETURN                                                   null

End of function seterrorexceptionclass

Function throw:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/u8c1o
function name:  throw
number of ops:  8
compiled vars:  !0 = $severity
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  130     0  E >   RECV_INIT                                        !0      <const ast>
  131     1        ASSIGN_OBJ                                               '_throw'
          2        OP_DATA                                                  !0
  132     3        FETCH_THIS                                       ~2      
          4        VERIFY_RETURN_TYPE                                       ~2
          5      > RETURN                                                   ~2
  133     6*       VERIFY_RETURN_TYPE                                       
          7*     > RETURN                                                   null

End of function throw

Function unregister:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/u8c1o
function name:  unregister
number of ops:  11
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  141     0  E >   INIT_NS_FCALL_BY_NAME                                    'at%5Cexceptable%5Crestore_error_handler'
          1        DO_FCALL                                      0          
  142     2        INIT_NS_FCALL_BY_NAME                                    'at%5Cexceptable%5Crestore_exception_handler'
          3        DO_FCALL                                      0          
  144     4        ASSIGN_OBJ                                               '_registered'
          5        OP_DATA                                                  <false>
  145     6        FETCH_THIS                                       ~3      
          7        VERIFY_RETURN_TYPE                                       ~3
          8      > RETURN                                                   ~3
  146     9*       VERIFY_RETURN_TYPE                                       
         10*     > RETURN                                                   null

End of function unregister

Function _error:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 9
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 21
Branch analysis from position: 13
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 21
2 jumps found. (Code = 77) Position 1 = 23, Position 2 = 42
Branch analysis from position: 23
2 jumps found. (Code = 78) Position 1 = 24, Position 2 = 42
Branch analysis from position: 24
2 jumps found. (Code = 46) Position 1 = 30, Position 2 = 38
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 41
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 38
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
filename:       /in/u8c1o
function name:  _error
number of ops:  46
compiled vars:  !0 = $s, !1 = $m, !2 = $f, !3 = $l, !4 = $c, !5 = $handler
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  159     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
          4        RECV                                             !4      
  160     5        FETCH_OBJ_R                                      ~6      '_registered'
          6        BOOL_NOT                                         ~7      ~6
          7      > JMPZ                                                     ~7, ->9
  161     8    > > RETURN                                                   <false>
  164     9    >   FETCH_OBJ_R                                      ~8      '_throw'
         10        BW_AND                                           ~9      !0, ~8
         11        IS_IDENTICAL                                             !0, ~9
         12      > JMPZ                                                     ~10, ->21
  165    13    >   NEW                                              $11     'ErrorException'
         14        SEND_VAR_EX                                              !1
         15        SEND_VAL_EX                                              0
         16        SEND_VAR_EX                                              !0
         17        SEND_VAR_EX                                              !2
         18        SEND_VAR_EX                                              !3
         19        DO_FCALL                                      0          
         20      > THROW                                         0          $11
  168    21    >   FETCH_OBJ_R                                      ~13     '_errorHandlers'
         22      > FE_RESET_R                                       $14     ~13, ->42
         23    > > FE_FETCH_R                                               $14, !5, ->42
  169    24    >   INIT_METHOD_CALL                                         !5, 'handles'
         25        FETCH_CLASS_CONSTANT                             ~15     'at%5Cexceptable%5C_Handler', 'TYPE_ERROR'
         26        SEND_VAL_EX                                              ~15
         27        SEND_VAR_EX                                              !0
         28        DO_FCALL                                      0  $16     
         29      > JMPZ_EX                                          ~17     $16, ->38
         30    >   INIT_METHOD_CALL                                         !5, 'handle'
         31        SEND_VAR_EX                                              !0
         32        SEND_VAR_EX                                              !1
         33        SEND_VAR_EX                                              !2
         34        SEND_VAR_EX                                              !3
         35        SEND_VAR_EX                                              !4
         36        DO_FCALL                                      0  $18     
         37        BOOL                                             ~17     $18
         38    > > JMPZ                                                     ~17, ->41
  170    39    >   FE_FREE                                                  $14
         40      > RETURN                                                   <true>
  168    41    > > JMP                                                      ->23
         42    >   FE_FREE                                                  $14
  173    43      > RETURN                                                   <false>
  174    44*       VERIFY_RETURN_TYPE                                       
         45*     > RETURN                                                   null

End of function _error

Function _exception:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 5
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 14
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 34
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 34
Branch analysis from position: 20
2 jumps found. (Code = 46) Position 1 = 26, Position 2 = 30
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 33
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 30
Branch analysis from position: 34
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 34
Branch analysis from position: 14
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 34
Branch analysis from position: 19
Branch analysis from position: 34
filename:       /in/u8c1o
function name:  _exception
number of ops:  42
compiled vars:  !0 = $e, !1 = $severity, !2 = $handler
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  182     0  E >   RECV                                             !0      
  183     1        FETCH_OBJ_R                                      ~3      '_registered'
          2        BOOL_NOT                                         ~4      ~3
          3      > JMPZ                                                     ~4, ->5
  184     4    > > RETURN                                                   null
  187     5    >   INIT_NS_FCALL_BY_NAME                                    'at%5Cexceptable%5Cmethod_exists'
          6        SEND_VAR_EX                                              !0
          7        SEND_VAL_EX                                              'getSeverity'
          8        DO_FCALL                                      0  $5      
          9      > JMPZ                                                     $5, ->14
         10    >   INIT_METHOD_CALL                                         !0, 'getSeverity'
         11        DO_FCALL                                      0  $6      
         12        QM_ASSIGN                                        ~7      $6
         13      > JMP                                                      ->16
         14    >   FETCH_CLASS_CONSTANT                             ~8      'at%5Cexceptable%5CExceptable', 'ERROR'
         15        QM_ASSIGN                                        ~7      ~8
         16    >   ASSIGN                                                   !1, ~7
  188    17        FETCH_OBJ_R                                      ~10     '_exceptionHandlers'
         18      > FE_RESET_R                                       $11     ~10, ->34
         19    > > FE_FETCH_R                                               $11, !2, ->34
  189    20    >   INIT_METHOD_CALL                                         !2, 'handles'
         21        FETCH_CLASS_CONSTANT                             ~12     'at%5Cexceptable%5C_Handler', 'TYPE_EXCEPTION'
         22        SEND_VAL_EX                                              ~12
         23        SEND_VAR_EX                                              !1
         24        DO_FCALL                                      0  $13     
         25      > JMPZ_EX                                          ~14     $13, ->30
         26    >   INIT_METHOD_CALL                                         !2, 'handle'
         27        SEND_VAR_EX                                              !0
         28        DO_FCALL                                      0  $15     
         29        BOOL                                             ~14     $15
         30    > > JMPZ                                                     ~14, ->33
  190    31    >   FE_FREE                                                  $11
         32      > RETURN                                                   null
  188    33    > > JMP                                                      ->19
         34    >   FE_FREE                                                  $11
  194    35        NEW                                              $16     'at%5Cexceptable%5CExceptableException'
         36        FETCH_CLASS_CONSTANT                             ~17     'at%5Cexceptable%5CExceptableException', 'UNCAUGHT_EXCEPTION'
         37        SEND_VAL_EX                                              ~17
         38        SEND_VAR_EX                                              !0
         39        DO_FCALL                                      0          
         40      > THROW                                         0          $16
  195    41*     > RETURN                                                   null

End of function _exception

Function _shutdown:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 4
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 46) Position 1 = 8, Position 2 = 12
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 29
Branch analysis from position: 13
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 29
2 jumps found. (Code = 77) Position 1 = 31, Position 2 = 35
Branch analysis from position: 31
2 jumps found. (Code = 78) Position 1 = 32, Position 2 = 35
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
Branch analysis from position: 12
filename:       /in/u8c1o
function name:  _shutdown
number of ops:  37
compiled vars:  !0 = $e, !1 = $handler
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  203     0  E >   FETCH_OBJ_R                                      ~2      '_registered'
          1        BOOL_NOT                                         ~3      ~2
          2      > JMPZ                                                     ~3, ->4
  204     3    > > RETURN                                                   null
  207     4    >   INIT_NS_FCALL_BY_NAME                                    'at%5Cexceptable%5Cerror_get_last'
          5        DO_FCALL                                      0  $4      
          6        ASSIGN                                                   !0, $4
  208     7      > JMPZ_EX                                          ~6      !0, ->12
          8    >   FETCH_DIM_R                                      ~7      !0, 'type'
          9        FETCH_CONSTANT                                   ~8      'at%5Cexceptable%5CE_ERROR'
         10        IS_IDENTICAL                                     ~9      ~7, ~8
         11        BOOL                                             ~6      ~9
         12    > > JMPZ                                                     ~6, ->29
  209    13    >   NEW                                              $10     'ErrorException'
         14        CHECK_FUNC_ARG                                           
         15        FETCH_DIM_FUNC_ARG                               $11     !0, 'message'
         16        SEND_FUNC_ARG                                            $11
         17        SEND_VAL_EX                                              0
         18        CHECK_FUNC_ARG                                           
         19        FETCH_DIM_FUNC_ARG                               $12     !0, 'type'
         20        SEND_FUNC_ARG                                            $12
   

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
288.2 ms | 1428 KiB | 32 Q