Inheritance: extends Exception
Exemple #1
0
$global = Object::$global;
$undefined = null;
$Infinity = INF;
$NaN = NAN;
$Object = Object::getGlobalConstructor();
$Function = Func::getGlobalConstructor();
$Array = Arr::getGlobalConstructor();
$Boolean = Bln::getGlobalConstructor();
$Number = Number::getGlobalConstructor();
$String = Str::getGlobalConstructor();
$Date = Date::getGlobalConstructor();
$Error = Error::getGlobalConstructor();
$RangeError = RangeError::getGlobalConstructor();
$ReferenceError = ReferenceError::getGlobalConstructor();
$SyntaxError = SyntaxError::getGlobalConstructor();
$TypeError = TypeError::getGlobalConstructor();
$RegExp = RegExp::getGlobalConstructor();
$Buffer = Buffer::getGlobalConstructor();
call_user_func(function () use(&$escape, &$unescape, &$encodeURI, &$decodeURI, &$encodeURIComponent, &$decodeURIComponent) {
    $ord = function ($ch) {
        $i = ord($ch[0]);
        if ($i <= 0x7f) {
            return $i;
        } else {
            if ($i < 0xc2) {
                return $i;
                //invalid byte sequence
            } else {
                if ($i <= 0xdf) {
                    return ($i & 0x1f) << 6 | ord($ch[1]) & 0x3f;
                } else {
 /**
  * Create a TypeErrorException from a TypeError.
  *
  * @param \TypeError $e
  *
  * @return TypeErrorException
  */
 public static function fromTypeError(\TypeError $e)
 {
     return new self($e->getMessage(), $e->getLine());
 }
Exemple #3
0
 /**
  * Get a ErrorException instance.
  *
  * @param \ParseError|\TypeError|\Throwable $exception
  *
  * @return \ErrorException
  */
 private function getErrorException($exception) : ErrorException
 {
     if ($exception instanceof ParseError) {
         $message = 'Parse error: ' . $exception->getMessage();
         $severity = E_PARSE;
     } elseif ($exception instanceof TypeError) {
         $message = 'Type error: ' . $exception->getMessage();
         $severity = E_RECOVERABLE_ERROR;
     } else {
         $message = $exception->getMessage();
         $severity = E_ERROR;
     }
     return new ErrorException($message, $exception->getCode(), $severity, $exception->getFile(), $exception->getLine());
 }
Exemple #4
0
 public function testGetCode()
 {
     $this->assertSame('TypeError', $this->object->getCode());
 }