本文整理汇总了PHP中Streams::readableUri方法的典型用法代码示例。如果您正苦于以下问题:PHP Streams::readableUri方法的具体用法?PHP Streams::readableUri怎么用?PHP Streams::readableUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Streams
的用法示例。
在下文中一共展示了Streams::readableUri方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDom
/**
* Returns a DOM object for this response's contents. Lazy/Cached.
*
* @return php.DOMDocument
*/
public function getDom()
{
if (NULL === $this->dom) {
$this->dom = new DOMDocument();
@$this->dom->loadHTMLFile(Streams::readableUri($this->response->getInputStream()));
}
return $this->dom;
}
示例2: usableInLoad
public function usableInLoad()
{
$dom = new \DOMDocument();
$this->assertTrue($dom->load(Streams::readableUri(new MemoryInputStream(trim('
<?xml version="1.0" encoding="utf-8"?>
<root>
<child>übercoder</child>
</root>
')))));
$this->assertEquals('übercoder', $dom->getElementsByTagName('child')->item(0)->nodeValue);
}
示例3: __construct
/**
* 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));
}
}
}
示例4: unmarshalFrom
/**
* Unmarshal XML to an object
*
* @param xml.parser.InputSource source
* @param string classname
* @param [:var] inject
* @return lang.Object
* @throws lang.ClassNotFoundException
* @throws xml.XMLFormatException
* @throws lang.reflect.TargetInvocationException
* @throws lang.IllegalArgumentException
*/
public function unmarshalFrom(InputSource $input, $classname, $inject = array())
{
libxml_clear_errors();
$doc = new DOMDocument();
if (!$doc->load(Streams::readableUri($input->getStream()))) {
$e = libxml_get_last_error();
throw new XMLFormatException(trim($e->message), $e->code, $input->getSource(), $e->line, $e->column);
}
$xpath = new XPath($doc);
// Class factory based on tag name, reference to a static method which is called with
// the class name and returns an XPClass instance.
$class = XPClass::forName($classname);
if ($class->hasAnnotation('xmlmapping', 'factory')) {
if ($class->hasAnnotation('xmlmapping', 'pass')) {
$factoryArgs = array();
foreach ($class->getAnnotation('xmlmapping', 'pass') as $pass) {
$factoryArgs[] = self::contentOf($xpath->query($pass, $doc->documentElement));
}
} else {
$factoryArgs = array($doc->documentElement->nodeName);
}
$class = $class->getMethod($class->getAnnotation('xmlmapping', 'factory'))->invoke(NULL, $factoryArgs);
}
return self::recurse($xpath, $doc->documentElement, $class, $inject);
}
示例5: readImage
/**
* Read an image
*
* @return resource
* @throws img.ImagingException
*/
public function readImage()
{
return $this->readImage0(Streams::readableUri($this->stream));
}
示例6: is_file
public function is_file()
{
$this->assertTrue(is_file(Streams::readableUri(new MemoryInputStream('Hello'))));
}
示例7: largefileGetContents
public function largefileGetContents()
{
$data = str_repeat('x', 16384);
$this->assertEquals($data, file_get_contents(Streams::readableUri(new MemoryInputStream($data))));
}