当前位置: 首页>>代码示例>>PHP>>正文


PHP ErrorHandler::unstackErrors方法代码示例

本文整理汇总了PHP中ErrorHandler::unstackErrors方法的典型用法代码示例。如果您正苦于以下问题:PHP ErrorHandler::unstackErrors方法的具体用法?PHP ErrorHandler::unstackErrors怎么用?PHP ErrorHandler::unstackErrors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ErrorHandler的用法示例。


在下文中一共展示了ErrorHandler::unstackErrors方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loadClass

 /**
  * Loads the given class or interface.
  *
  * @param string $class The name of the class
  *
  * @return bool|null True, if loaded
  *
  * @throws \RuntimeException
  */
 public function loadClass($class)
 {
     ErrorHandler::stackErrors();
     try {
         if ($this->isFinder) {
             if ($file = $this->classLoader[0]->findFile($class)) {
                 require_once $file;
             }
         } else {
             call_user_func($this->classLoader, $class);
             $file = false;
         }
     } catch (\Exception $e) {
         ErrorHandler::unstackErrors();
         throw $e;
     }
     ErrorHandler::unstackErrors();
     $exists = class_exists($class, false) || interface_exists($class, false) || function_exists('trait_exists') && trait_exists($class, false);
     if ('\\' === $class[0]) {
         $class = substr($class, 1);
     }
     if ($exists) {
         $refl = new \ReflectionClass($class);
         $name = $refl->getName();
         if ($name !== $class && 0 === strcasecmp($name, $class)) {
             throw new \RuntimeException(sprintf('Case mismatch between loaded and declared class names: %s vs %s', $class, $name));
         }
         if (in_array(strtolower($refl->getShortName()), self::$php7Reserved)) {
             @trigger_error(sprintf('%s uses a reserved class name (%s) that will break on PHP 7 and higher', $name, $refl->getShortName()), E_USER_DEPRECATED);
         } elseif (preg_match('#\\n \\* @deprecated (.*?)\\r?\\n \\*(?: @|/$)#s', $refl->getDocComment(), $notice)) {
             self::$deprecated[$name] = preg_replace('#\\s*\\r?\\n \\* +#', ' ', $notice[1]);
         } else {
             if (2 > ($len = 1 + (strpos($name, '\\', 1 + strpos($name, '\\')) ?: strpos($name, '_')))) {
                 $len = 0;
                 $ns = '';
             } else {
                 switch ($ns = substr($name, 0, $len)) {
                     case 'Symfony\\Bridge\\':
                     case 'Symfony\\Bundle\\':
                     case 'Symfony\\Component\\':
                         $ns = 'Symfony\\';
                         $len = strlen($ns);
                         break;
                 }
             }
             $parent = get_parent_class($class);
             if (!$parent || strncmp($ns, $parent, $len)) {
                 if ($parent && isset(self::$deprecated[$parent]) && strncmp($ns, $parent, $len)) {
                     @trigger_error(sprintf('The %s class extends %s that is deprecated %s', $name, $parent, self::$deprecated[$parent]), E_USER_DEPRECATED);
                 }
                 foreach (class_implements($class) as $interface) {
                     if (isset(self::$deprecated[$interface]) && strncmp($ns, $interface, $len) && !is_subclass_of($parent, $interface)) {
                         @trigger_error(sprintf('The %s %s %s that is deprecated %s', $name, interface_exists($class) ? 'interface extends' : 'class implements', $interface, self::$deprecated[$interface]), E_USER_DEPRECATED);
                     }
                 }
             }
         }
     }
     if ($file) {
         if (!$exists) {
             if (false !== strpos($class, '/')) {
                 throw new \RuntimeException(sprintf('Trying to autoload a class with an invalid name "%s". Be careful that the namespace separator is "\\" in PHP, not "/".', $class));
             }
             throw new \RuntimeException(sprintf('The autoloader expected class "%s" to be defined in file "%s". The file was found but the class was not in it, the class name or namespace probably has a typo.', $class, $file));
         }
         if (self::$caseCheck) {
             $real = explode('\\', $class . strrchr($file, '.'));
             $tail = explode(DIRECTORY_SEPARATOR, str_replace('/', DIRECTORY_SEPARATOR, $file));
             $i = count($tail) - 1;
             $j = count($real) - 1;
             while (isset($tail[$i], $real[$j]) && $tail[$i] === $real[$j]) {
                 --$i;
                 --$j;
             }
             array_splice($tail, 0, $i + 1);
         }
         if (self::$caseCheck && $tail) {
             $tail = DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $tail);
             $tailLen = strlen($tail);
             $real = $refl->getFileName();
             if (2 === self::$caseCheck) {
                 // realpath() on MacOSX doesn't normalize the case of characters
                 $i = 1 + strrpos($real, '/');
                 $file = substr($real, $i);
                 $real = substr($real, 0, $i);
                 if (isset(self::$darwinCache[$real])) {
                     $kDir = $real;
                 } else {
                     $kDir = strtolower($real);
                     if (isset(self::$darwinCache[$kDir])) {
                         $real = self::$darwinCache[$kDir][0];
//.........这里部分代码省略.........
开发者ID:phantsang,项目名称:8csfOIjOaJSlDG2Y3x992O,代码行数:101,代码来源:DebugClassLoader.php

示例2: loadClass

 /**
  * Loads the given class or interface.
  *
  * @param string $class The name of the class
  *
  * @return bool|null True, if loaded
  *
  * @throws \RuntimeException
  */
 public function loadClass($class)
 {
     ErrorHandler::stackErrors();
     try {
         if ($this->isFinder) {
             if ($file = $this->classLoader[0]->findFile($class)) {
                 require $file;
             }
         } else {
             call_user_func($this->classLoader, $class);
             $file = false;
         }
     } catch (\Exception $e) {
         ErrorHandler::unstackErrors();
         throw $e;
     }
     ErrorHandler::unstackErrors();
     $exists = class_exists($class, false) || interface_exists($class, false) || trait_exists($class, false);
     if ('\\' === $class[0]) {
         $class = substr($class, 1);
     }
     if ($exists) {
         $refl = new \ReflectionClass($class);
         $name = $refl->getName();
         if ($name !== $class && 0 === strcasecmp($name, $class)) {
             throw new \RuntimeException(sprintf('Case mismatch between loaded and declared class names: %s vs %s', $class, $name));
         }
         if (preg_match('#\\n \\* @deprecated (.*?)\\r?\\n \\*(?: @|/$)#s', $refl->getDocComment(), $notice)) {
             self::$deprecated[$name] = preg_replace('#\\s*\\r?\\n \\* +#', ' ', $notice[1]);
         } else {
             if (2 > ($len = 1 + (strpos($name, '\\', 1 + strpos($name, '\\')) ?: strpos($name, '_')))) {
                 $len = 0;
                 $ns = '';
             } else {
                 switch ($ns = substr($name, 0, $len)) {
                     case 'Symfony\\Bridge\\':
                     case 'Symfony\\Bundle\\':
                     case 'Symfony\\Component\\':
                         $ns = 'Symfony\\';
                         $len = strlen($ns);
                         break;
                 }
             }
             $parent = $refl->getParentClass();
             if (!$parent || strncmp($ns, $parent, $len)) {
                 if ($parent && isset(self::$deprecated[$parent->name]) && strncmp($ns, $parent->name, $len)) {
                     trigger_error(sprintf('The %s class extends %s that is deprecated %s', $name, $parent->name, self::$deprecated[$parent->name]), E_USER_DEPRECATED);
                 }
                 foreach ($refl->getInterfaceNames() as $interface) {
                     if (isset(self::$deprecated[$interface]) && strncmp($ns, $interface, $len) && !($parent && $parent->implementsInterface($interface))) {
                         trigger_error(sprintf('The %s %s %s that is deprecated %s', $name, $refl->isInterface() ? 'interface extends' : 'class implements', $interface, self::$deprecated[$interface]), E_USER_DEPRECATED);
                     }
                 }
             }
         }
     }
     if ($file) {
         if (!$exists) {
             if (false !== strpos($class, '/')) {
                 throw new \RuntimeException(sprintf('Trying to autoload a class with an invalid name "%s". Be careful that the namespace separator is "\\" in PHP, not "/".', $class));
             }
             throw new \RuntimeException(sprintf('The autoloader expected class "%s" to be defined in file "%s". The file was found but the class was not in it, the class name or namespace probably has a typo.', $class, $file));
         }
         if (self::$caseCheck && preg_match('#([/\\\\][a-zA-Z_\\x7F-\\xFF][a-zA-Z0-9_\\x7F-\\xFF]*)+\\.(php|hh)$#D', $file, $tail)) {
             $tail = $tail[0];
             $real = $refl->getFilename();
             if (2 === self::$caseCheck) {
                 // realpath() on MacOSX doesn't normalize the case of characters
                 $cwd = getcwd();
                 $basename = strrpos($real, '/');
                 chdir(substr($real, 0, $basename));
                 $basename = substr($real, $basename + 1);
                 // glob() patterns are case-sensitive even if the underlying fs is not
                 if (!in_array($basename, glob($basename . '*', GLOB_NOSORT), true)) {
                     $real = getcwd() . '/';
                     $h = opendir('.');
                     while (false !== ($f = readdir($h))) {
                         if (0 === strcasecmp($f, $basename)) {
                             $real .= $f;
                             break;
                         }
                     }
                     closedir($h);
                 }
                 chdir($cwd);
             }
             if (0 === substr_compare($real, $tail, -strlen($tail), strlen($tail), true) && 0 !== substr_compare($real, $tail, -strlen($tail), strlen($tail), false)) {
                 throw new \RuntimeException(sprintf('Case mismatch between class and source file names: %s vs %s', $class, $real));
             }
         }
         return true;
//.........这里部分代码省略.........
开发者ID:vadim2404,项目名称:symfony,代码行数:101,代码来源:DebugClassLoader.php

示例3: loadClass

 /**
  * Loads the given class or interface.
  *
  * @param string $class The name of the class
  *
  * @return bool|null    True, if loaded
  *
  * @throws \RuntimeException
  */
 public function loadClass($class)
 {
     ErrorHandler::stackErrors();
     try {
         if ($this->isFinder) {
             if ($file = $this->classLoader[0]->findFile($class)) {
                 require $file;
             }
         } else {
             call_user_func($this->classLoader, $class);
             $file = false;
         }
     } catch (\Exception $e) {
         ErrorHandler::unstackErrors();
         throw $e;
     }
     ErrorHandler::unstackErrors();
     $exists = class_exists($class, false) || interface_exists($class, false) || function_exists('trait_exists') && trait_exists($class, false);
     if ('\\' === $class[0]) {
         $class = substr($class, 1);
     }
     if ($exists) {
         $refl = new \ReflectionClass($class);
         $name = $refl->getName();
         if ($name !== $class && 0 === strcasecmp($name, $class)) {
             throw new \RuntimeException(sprintf('Case mismatch between loaded and declared class names: %s vs %s', $class, $name));
         }
     }
     if ($file) {
         if (!$exists) {
             if (false !== strpos($class, '/')) {
                 throw new \RuntimeException(sprintf('Trying to autoload a class with an invalid name "%s". Be careful that the namespace separator is "\\" in PHP, not "/".', $class));
             }
             throw new \RuntimeException(sprintf('The autoloader expected class "%s" to be defined in file "%s". The file was found but the class was not in it, the class name or namespace probably has a typo.', $class, $file));
         }
         if (self::$caseCheck && preg_match('#([/\\\\][a-zA-Z_\\x7F-\\xFF][a-zA-Z0-9_\\x7F-\\xFF]*)+\\.(php|hh)$#D', $file, $tail)) {
             $tail = $tail[0];
             $real = $refl->getFilename();
             if (2 === self::$caseCheck) {
                 // realpath() on MacOSX doesn't normalize the case of characters
                 $cwd = getcwd();
                 $basename = strrpos($real, '/');
                 chdir(substr($real, 0, $basename));
                 $basename = substr($real, $basename + 1);
                 // glob() patterns are case-sensitive even if the underlying fs is not
                 if (!in_array($basename, glob($basename . '*', GLOB_NOSORT), true)) {
                     $real = getcwd() . '/';
                     $h = opendir('.');
                     while (false !== ($f = readdir($h))) {
                         if (0 === strcasecmp($f, $basename)) {
                             $real .= $f;
                             break;
                         }
                     }
                     closedir($h);
                 }
                 chdir($cwd);
             }
             if (0 === substr_compare($real, $tail, -strlen($tail), strlen($tail), true) && 0 !== substr_compare($real, $tail, -strlen($tail), strlen($tail), false)) {
                 throw new \RuntimeException(sprintf('Case mismatch between class and source file names: %s vs %s', $class, $real));
             }
         }
         return true;
     }
 }
开发者ID:brennantom,项目名称:hackazon,代码行数:74,代码来源:DebugClassLoader.php

示例4: loadClass

 /**
  * Loads the given class or interface.
  *
  * @param string $class The name of the class
  *
  * @return Boolean|null True, if loaded
  *
  * @throws \RuntimeException
  */
 public function loadClass($class)
 {
     ErrorHandler::stackErrors();
     try {
         if ($this->isFinder) {
             if ($file = $this->classLoader[0]->findFile($class)) {
                 require $file;
             }
         } else {
             call_user_func($this->classLoader, $class);
             $file = false;
         }
     } catch (\Exception $e) {
         ErrorHandler::unstackErrors();
         throw $e;
     }
     ErrorHandler::unstackErrors();
     $exists = class_exists($class, false) || interface_exists($class, false) || function_exists('trait_exists') && trait_exists($class, false);
     if ($exists) {
         $name = new \ReflectionClass($class);
         $name = $name->getName();
         if ($name !== $class) {
             throw new \RuntimeException(sprintf('Case mismatch between loaded and declared class names: %s vs %s', $class, $name));
         }
     }
     if ($file) {
         if ('\\' == $class[0]) {
             $class = substr($class, 1);
         }
         $i = 0;
         $tail = DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php';
         $len = strlen($tail);
         do {
             $tail = substr($tail, $i);
             $len -= $i;
             if (0 === substr_compare($file, $tail, -$len, $len, true)) {
                 if (0 !== substr_compare($file, $tail, -$len, $len, false)) {
                     if (method_exists($this->classLoader[0], 'getClassMap')) {
                         $map = $this->classLoader[0]->getClassMap();
                     } else {
                         $map = array();
                     }
                     if (!isset($map[$class])) {
                         throw new \RuntimeException(sprintf('Case mismatch between class and source file names: %s vs %s', $class, $file));
                     }
                 }
                 break;
             }
         } while (false !== ($i = strpos($tail, DIRECTORY_SEPARATOR, 1)));
         if (!$exists) {
             if (false !== strpos($class, '/')) {
                 throw new \RuntimeException(sprintf('Trying to autoload a class with an invalid name "%s". Be careful that the namespace separator is "\\" in PHP, not "/".', $class));
             }
             throw new \RuntimeException(sprintf('The autoloader expected class "%s" to be defined in file "%s". The file was found but the class was not in it, the class name or namespace probably has a typo.', $class, $file));
         }
         return true;
     }
 }
开发者ID:romainneutron,项目名称:symfony,代码行数:67,代码来源:DebugClassLoader.php


注:本文中的ErrorHandler::unstackErrors方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。