/** * Constructor * * @param var stream either an io.streams.OutputStream or an io.Stream (BC) * @throws lang.IllegalArgumentException when types are not met */ public function __construct($stream) { $this->stream = deref($stream); if ($this->stream instanceof OutputStream) { // Already open } else { if ($this->stream instanceof Stream) { $this->stream->open(STREAM_MODE_WRITE); } else { throw new IllegalArgumentException('Expected either an io.streams.OutputStream or an io.Stream, have ' . xp::typeOf($this->stream)); } } if (self::$GD_USERSTREAMS_BUG) { $this->writer = function ($writer, $stream, $handle) { ob_start(); $r = $writer->output($handle); if ($r) { $stream->write(ob_get_contents()); } ob_end_clean(); return $r; }; } else { // Use output buffering with a callback method to capture the // image(gd|jpeg|png|...) functions' output. $this->writer = function ($writer, $stream, $handle) { ob_start(function ($data) use($stream) { $stream->write($data); }); $r = $writer->output($handle); ob_end_flush(); return $r; }; } }
/** * Constructor * * @param var stream either an io.streams.OutputStream or an io.Stream (BC) * @throws lang.IllegalArgumentException when types are not met */ public function __construct($stream) { $this->stream = deref($stream); if ($this->stream instanceof OutputStream) { // Already open } else { if ($this->stream instanceof Stream) { $this->stream->open(STREAM_MODE_WRITE); } else { throw new IllegalArgumentException('Expected either an io.streams.OutputStream or an io.Stream, have ' . xp::typeOf($this->stream)); } } }
/** * Constructor * * @param var stream either an io.streams.InputStream or an io.Stream (BC) * @throws lang.IllegalArgumentException when types are not met */ public function __construct($stream) { $this->stream = deref($stream); if ($this->stream instanceof InputStream) { if ($this instanceof img·io·UriReader && !self::$GD_USERSTREAMS_BUG) { $this->reader = function ($reader, $stream) { return $reader->readImageFromUri(Streams::readableUri($stream)); }; } else { $this->reader = function ($reader, $stream) { $bytes = ''; while ($stream->available() > 0) { $bytes .= $stream->read(); } $stream->close(); return $reader->readImageFromString($bytes); }; } } else { if ($this->stream instanceof Stream) { if ($this instanceof img·io·UriReader && !self::$GD_USERSTREAMS_BUG) { $this->reader = function ($reader, $stream) { $stream->open(STREAM_MODE_READ); return $reader->readImageFromUri($stream->getURI()); }; } else { $this->reader = function ($reader, $stream) { $stream->open(STREAM_MODE_READ); $bytes = ''; do { $bytes .= $stream->read(); } while (!$stream->eof()); $stream->close(); return $reader->readImageFromString($bytes); }; } } else { throw new IllegalArgumentException('Expected either an io.streams.InputStream or an io.Stream, have ' . xp::typeOf($this->stream)); } } }
}, 'nth' => function ($a, $b) { return nth($a, $b); }, 'first' => function ($a) { return first($a); }, 'rest' => function ($a) { return rest($a); }, 'empty?' => function ($a) { return empty_Q($a); }, 'count' => function ($a) { return scount($a); }, 'conj' => function () { return call_user_func_array('conj', func_get_args()); }, 'apply' => function () { return call_user_func_array('apply', func_get_args()); }, 'map' => function ($a, $b) { return map($a, $b); }, 'with-meta' => function ($a, $b) { return with_meta($a, $b); }, 'meta' => function ($a) { return meta($a); }, 'atom' => function ($a) { return _atom($a); }, 'atom?' => function ($a) { return _atom_Q($a); }, 'deref' => function ($a) { return deref($a); }, 'reset!' => function ($a, $b) { return reset_BANG($a, $b); }, 'swap!' => function () { return call_user_func_array('swap_BANG', func_get_args()); });
public function derefOfRef() { $object = new \lang\Object(); $r = ref($object); $this->assertReference($object, deref($r)); }