function stream_open($path, $mode, $options, &$opened_path) { $this->_currentstring = StringStreamController::getRef(str_replace('string://', '', $path)); if ($this->_currentstring) { $this->_len = strlen($this->_currentstring); $this->_pos = 0; return true; } else { return false; } }
<?php /** * String Stream Test * * This file tests that the string stream operators * appropriately with the correct values returned * and no corruption * * PHP5 * * Created on Aug 7, 2008 * * @package stringstream * @author Sam Moffatt <*****@*****.**> * @author Toowoomba Regional Council Information Management Branch * @license GNU/GPL http://www.gnu.org/licenses/gpl.html * @copyright 2008 Toowoomba Regional Council/Sam Moffatt * @version SVN: $Id:$ */ include 'stringstream.php'; $data = file_get_contents('test.csv') or die('failed to open data'); StringStreamController::createRef('csv', $data); $data2 = file_get_contents('string://csv') or die('failed to open data2'); print_r(array_diff(explode("\n", $data), explode("\n", $data2)));
#: standard input:3299 msgid "Hard id" "foo bar\\n" "a \\" quote" msgstr "" #: standard input:116 input:1115 input:1205 #: input:1838 input:1868 #~ msgid "Password" #~ "xxx" #~ msgstr "Mot de passe:" #~ "xxx" FILE; StringStreamController::createRef('reference', $easy_file); $fh = fopen('string://reference', 'r'); $store = new TempPoMsgStore(); $t = new Tester(); $parser = new POParser($store); $parser->parseEntriesFromStream($fh); $objects = $store->read(); $t->assertTrue($objects[1]); $t->assertTrue($objects[0]); $t->assertFalse($objects[10]); $t->assertTrue($objects[0]['msgid']); $t->assertTrue($objects[0]['msgstr']); $t->assertFalse($objects[0]['should_not_exist']); $t->assertEquals($objects[0]['msgid'], 'Password'); $t->assertEquals($objects[0]['msgstr'], 'Mot de passe:'); $t->assertEquals($objects[1]['msgid'], "Hard idfoo bar\na \" quote");
/** * Test for the String Stream Controller * * * PHP/5 * * Created on Aug 7, 2008 * * @package stringstream * @author Sam Moffatt <*****@*****.**> * @author Toowoomba Regional Council Information Management Branch * @license GNU/GPL http://www.gnu.org/licenses/gpl.html * @copyright 2008 Toowoomba Regional Council/Sam Moffatt * @version SVN: $Id:$ */ include 'stringstream.php'; echo "<pre>"; $mystring = "Joe is good"; $ref = ''; echo "My String: {$mystring}\n"; echo "Ref: {$ref}\n"; echo "\n\n"; StringStreamController::createRef('mystring', $mystring); $ref =& StringStreamController::getRef('mystring'); echo "My String: {$mystring}\n"; echo "Ref: {$ref}\n"; echo "\n\n"; $mystring = "Pie"; echo "My String: {$mystring}\n"; echo "Ref: {$ref}\n"; echo "\n\n";