コード例 #1
0
ファイル: Stream.php プロジェクト: radphp/network
 /**
  * Rad\Network\Http\Message\Stream constructor
  *
  * @param string|resource $stream
  * @param string          $mode
  * @param bool            $useIncludePath
  * @param null|resource   $context
  *
  * @throws BaseException
  */
 public function __construct($stream, $mode = 'r+', $useIncludePath = false, $context = null)
 {
     if (is_string($stream)) {
         set_error_handler([$this, 'connectionErrorHandler']);
         if ($context === null) {
             $this->handle = fopen($stream, $mode, $useIncludePath);
         } else {
             $this->handle = fopen($stream, $mode, $useIncludePath, $context);
         }
         restore_error_handler();
         if (!empty($this->connectionErrors)) {
             $lastError = end($this->connectionErrors);
             $exc = new BaseException($lastError['message']);
             $exc->setFile($lastError['file'])->setLine($lastError['line']);
             throw $exc;
         }
     } elseif (is_resource($stream)) {
         $this->handle = $stream;
     } else {
         throw new InvalidArgumentException('Stream argument type must be resource or string.');
     }
 }
コード例 #2
0
 /**
  * MissingMethodException constructor
  *
  * @param string $message  Exception message
  * @param int    $code     Exception code
  * @param null   $previous Previous exception
  */
 public function __construct($message = '', $code = 500, $previous = null)
 {
     parent::__construct($message, $code, $previous);
 }
コード例 #3
0
ファイル: FatalErrorException.php プロジェクト: radphp/error
 /**
  * Rad\Error\FatalErrorException Constructor
  *
  * @param string      $message Message string.
  * @param int         $code    Code.
  * @param string|null $file    File name.
  * @param int|null    $line    Line number.
  */
 public function __construct($message, $code = 500, $file = null, $line = null)
 {
     parent::__construct($message, $code);
     $this->file = $file;
     $this->line = $line;
 }