示例#1
0
--TEST--
Test php\lang\Module - test include with variables
--FILE--
<?php 
use php\io\Stream;
use php\lang\Module;
$module = new Module(Stream::of('res://resources/ext/standard/module/basic_003.inc.php'));
$foo = 'fail';
$bar = 'fail';
$undefined = 'fail';
$module->call(['foo' => 'success_foo', 'bar' => 'success_bar']);
?>
--EXPECT--
string(11) "success_foo"
string(11) "success_bar"
NULL
示例#2
0
--TEST--
Jsoup test #2
--FILE--
<?php 
use php\io\Stream;
use php\jsoup\Jsoup;
$source = Stream::of('php://memory', 'w+');
$source->write('<a>foobar</a>');
$source->seek(0);
$doc = Jsoup::parse($source, 'UTF-8', 'examle.com');
var_dump($doc->select('a')->text());
?>
--EXPECT--
string(6) "foobar"
示例#3
0
文件: Process.php 项目: lihuibin/jphp
 /**
  * Returns the input stream connected to the error output of the
  * subprocess.  The stream obtains data piped from the error output
  * of the process represented by this `Process` object.
  *
  * @return Stream
  * @throws IllegalStateException
  */
 public function getError()
 {
     return Stream::of('');
 }
示例#4
0
 /**
  * @return Stream
  */
 public function getContent()
 {
     return Stream::of('');
 }
示例#5
0
--TEST--
Test php\io\Stream - test file stream
--FILE--
<?php 
use php\io\FileStream;
use php\io\Stream;
$memory = Stream::of(__DIR__ . '/stream_002.inc.txt');
var_dump($memory->readFully());
$memory->close();
var_dump(Stream::getContents(__DIR__ . '/stream_002.inc.txt'));
$memory = Stream::of('file://' . __DIR__ . '/stream_002.inc.txt');
var_dump($memory->read(3));
$memory->close();
$memory = new FileStream(__DIR__ . '/stream_002.inc.txt');
var_dump($memory->readFully());
$memory->close();
try {
    $memory->read(10);
} catch (\php\io\IOException $e) {
    var_dump($e->getMessage());
}
?>
--EXPECTF--
string(6) "foobar"
string(6) "foobar"
string(3) "foo"
string(6) "foobar"
string(13) "Stream Closed"
示例#6
0
--TEST--
Test php\io\Stream - test common
--FILE--
<?php 
use php\io\Stream;
$memory = Stream::of('php://memory', 'w+');
$memory->write('foobar');
$memory->seek(0);
var_dump($memory->readFully());
?>
--EXPECTF--
string(6) "foobar"