コード例 #1
0
ファイル: functions.php プロジェクト: puzzlehttp/streams
 /**
  * @deprecated Moved to puzzle_stream_Utils::open()
  */
 function puzzle_stream_safe_open($filename, $mode)
 {
     return puzzle_stream_Utils::open($filename, $mode);
 }
コード例 #2
0
ファイル: StreamAdapter.php プロジェクト: puzzlehttp/puzzle
 /**
  * Drain the stream into the destination stream
  */
 private function getSaveToBody(puzzle_message_RequestInterface $request, puzzle_stream_StreamInterface $stream)
 {
     $config = $request->getConfig();
     if ($saveTo = $config['save_to']) {
         // Stream the response into the destination stream
         $saveTo = is_string($saveTo) ? new puzzle_stream_Stream(puzzle_stream_Utils::open($saveTo, 'r+')) : puzzle_stream_Stream::factory($saveTo);
     } else {
         // Stream into the default temp stream
         $saveTo = puzzle_stream_Stream::factory();
     }
     puzzle_stream_Utils::copyToStream($stream, $saveTo);
     $saveTo->seek(0);
     $stream->close();
     return $saveTo;
 }
コード例 #3
0
ファイル: LazyOpenStream.php プロジェクト: puzzlehttp/streams
 /**
  * Creates the underlying stream lazily when required.
  *
  * @return puzzle_stream_StreamInterface
  */
 protected function createStream()
 {
     return puzzle_stream_Stream::factory(puzzle_stream_Utils::open($this->filename, $this->mode));
 }
コード例 #4
0
ファイル: UtilsTest.php プロジェクト: puzzlehttp/streams
 /**
  * @expectedException RuntimeException
  * @expectedExceptionMessage Unable to open /path/to/does/not/exist using mode r
  */
 public function testThrowsExceptionNotWarning()
 {
     puzzle_stream_Utils::open('/path/to/does/not/exist', 'r');
 }