Overview

Namespaces

  • TokenReflection
    • Broker
      • Backend
    • Dummy
    • Exception
    • Invalid
    • Php
    • Stream

Exceptions

  • BaseException
  • BrokerException
  • FileProcessingException
  • ParseException
  • RuntimeException
  • StreamException
  • Overview
  • Namespace
  • Class
  • Tree
  • Download
  1: <?php
  2: /**
  3:  * PHP Token Reflection
  4:  *
  5:  * Version 1.3.1
  6:  *
  7:  * LICENSE
  8:  *
  9:  * This source file is subject to the new BSD license that is bundled
 10:  * with this library in the file LICENSE.
 11:  *
 12:  * @author Ondřej Nešpor
 13:  * @author Jaroslav Hanslík
 14:  */
 15: 
 16: namespace TokenReflection\Exception;
 17: 
 18: use RuntimeException;
 19: 
 20: /**
 21:  * Base TokenReflection exception.
 22:  */
 23: abstract class BaseException extends RuntimeException
 24: {
 25:     /**
 26:      * The property/element does not exist.
 27:      *
 28:      * @var integer
 29:      */
 30:     const DOES_NOT_EXIST = 1;
 31: 
 32:     /**
 33:      * An invalid argument was provided.
 34:      *
 35:      * @var integer
 36:      */
 37:     const INVALID_ARGUMENT = 2;
 38: 
 39:     /**
 40:      * A required PHP extension is missing.
 41:      *
 42:      * @var integer
 43:      */
 44:     const PHP_EXT_MISSING = 3;
 45: 
 46:     /**
 47:      * The requested feature is not supported.
 48:      *
 49:      * @var integer
 50:      */
 51:     const UNSUPPORTED = 4;
 52: 
 53:     /**
 54:      * The reflected element already exists.
 55:      *
 56:      * @var integer
 57:      */
 58:     const ALREADY_EXISTS = 5;
 59: 
 60:     /**
 61:      * Returns an exception description detail.
 62:      *
 63:      * @return string
 64:      */
 65:     public abstract function getDetail();
 66: 
 67:     /**
 68:      * Returns an exception description as string.
 69:      *
 70:      * @return string
 71:      */
 72:     final public function getOutput()
 73:     {
 74:         $detail = $this->getDetail();
 75: 
 76:         return sprintf(
 77:             "exception '%s'%s in %s on line %d\n%s\nStack trace:\n%s",
 78:             get_class($this),
 79:             $this->getMessage() ? " with message '" . $this->getMessage() . "'" : '',
 80:             $this->getFile(),
 81:             $this->getLine(),
 82:             empty($detail) ? '' : $detail . "\n",
 83:             $this->getTraceAsString()
 84:         );
 85:     }
 86: 
 87:     /**
 88:      * Returns the exception details as string.
 89:      *
 90:      * @return string
 91:      */
 92:     final public function __toString()
 93:     {
 94:         $output = '';
 95: 
 96:         if ($ex = $this->getPrevious()) {
 97:             $output .= (string) $ex . "\n\nNext ";
 98:         }
 99: 
100:         return $output . $this->getOutput() . "\n";
101:     }
102: }
103: 
PHP Token Reflection API documentation generated by ApiGen 2.8.0