本文整理汇总了PHP中stream_filter_register函数的典型用法代码示例。如果您正苦于以下问题:PHP stream_filter_register函数的具体用法?PHP stream_filter_register怎么用?PHP stream_filter_register使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了stream_filter_register函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: runGiven
/**
* Handle a "given" step.
*
* @param array &$world Joined "world" of variables.
* @param string $action The description of the step.
* @param array $arguments Additional arguments to the step.
*
* @return mixed The outcome of the step.
*/
public function runGiven(&$world, $action, $arguments)
{
switch ($action) {
case 'an incoming message on host':
$world['hostname'] = $arguments[0];
$world['type'] = 'Incoming';
break;
case 'the SMTP sender address is':
$world['sender'] = $arguments[0];
break;
case 'the SMTP recipient address is':
$world['recipient'] = $arguments[0];
break;
case 'the client address is':
$world['client'] = $arguments[0];
break;
case 'the hostname is':
$world['hostname'] = $arguments[0];
break;
case 'the unmodified message content is':
$world['infile'] = $arguments[0];
$world['fp'] = fopen($world['infile'], 'r');
break;
case 'the modified message template is':
$world['infile'] = $arguments[0];
$world['fp'] = fopen($world['infile'], 'r');
stream_filter_register('addresses', 'Horde_Kolab_Filter_Helper_AddressFilter');
stream_filter_append($world['fp'], 'addresses', STREAM_FILTER_READ, array('recipient' => $world['recipient'], 'sender' => $world['sender']));
break;
default:
return $this->notImplemented($action);
}
}
示例2: main
function main()
{
stream_filter_register('test.md5', 'Md5Filter');
stream_filter_register('test.ucase', 'UpperCaseFilter');
doTest('stream_filter_append');
doTest('stream_filter_prepend');
}
示例3: setup
public function setup()
{
stream_filter_register('horde_crc32', 'Horde_Stream_Filter_Crc32');
$this->testdata = str_repeat("0123456789ABCDE", 1000);
$this->fp = fopen('php://temp', 'r+');
fwrite($this->fp, $this->testdata);
}
示例4: setup
public function setup()
{
stream_filter_register('horde_null', 'Horde_Stream_Filter_Null');
$this->testdata = "abcdefghij";
$this->fp = fopen('php://temp', 'r+');
fwrite($this->fp, $this->testdata);
}
示例5: register
/**
* Attaches the current filter to a stream.
*
* @return bool true on success or false on failure.
*/
public function register()
{
if (!$this->isRegistered) {
$this->isRegistered = stream_filter_register(static::NAME, get_called_class());
}
return $this->isRegistered;
}
示例6: register_default_stream_filters
function register_default_stream_filters()
{
\stream_filter_register('zlib.deflate', '__SystemLib\\DeflateStreamFilter');
\stream_filter_register('zlib.inflate', '__SystemLib\\InflateStreamFilter');
\stream_filter_register('string.rot13', '__SystemLib\\StringRot13StreamFilter');
\stream_filter_Register('string.toupper', '__SystemLib\\StringToUpperStreamFilter');
\stream_filter_Register('string.tolower', '__SystemLib\\StringToLowerStreamFilter');
}
示例7: setUp
public function setUp()
{
// register filter
$filters = stream_get_filters();
if (!in_array('crypto.filter', $filters)) {
stream_filter_register('crypto.filter', 'Fruit\\CryptoKit\\CryptoFilter');
}
}
示例8: registerModules
/**
* Register Influence loader and filter.
*/
private function registerModules()
{
$loaders = spl_autoload_functions();
foreach ($loaders as $loader) {
spl_autoload_unregister($loader);
}
spl_autoload_register([$this, 'loadClass']);
stream_filter_register('influence.reader', 'Influence\\Filter');
}
示例9: sgregister
function sgregister()
{
static $registered = null;
if ($registered === null) {
$registered = 'stream-callback';
stream_filter_register($registered, 'CallbackFilter');
}
return $registered;
}
示例10: register
/**
* Register the stream filter
*
* @return bool
*/
public static function register()
{
$result = false;
$name = self::getName();
if (!empty($name) && !in_array($name, stream_get_filters())) {
$result = stream_filter_register(self::getName(), get_called_class());
}
return $result;
}
示例11: register
/**
* Register this class as a stream filter
* @throws \RuntimeException
*/
public static function register()
{
if (self::$hasBeenRegistered === true) {
return;
}
if (stream_filter_register(self::getFilterName(), __CLASS__) === false) {
throw new RuntimeException('Failed to register stream filter: ' . self::getFilterName());
}
self::$hasBeenRegistered = true;
}
示例12: register
static function register($filter = null, $class = null)
{
if (empty($filter)) {
$filter = empty($class) ? new static() : new $class();
}
$class = get_class($filter);
self::$registry[$class] = $filter;
stream_filter_register($class, $class);
return $filter->filterPrefix = 'php://filter/read=' . $class . '/resource=';
}
示例13: testBodyFilter
/**
* @dataProvider bodyFilterProvider()
*/
public function testBodyFilter($data, $result)
{
$params = new stdClass();
$stream = fopen('php://temp', 'r+');
stream_filter_register('horde_smtp_body', 'Horde_Smtp_Filter_Body');
stream_filter_append($stream, 'horde_smtp_body', STREAM_FILTER_WRITE, $params);
fwrite($stream, $data);
fclose($stream);
$this->assertEquals($result, $params->body);
}
示例14: testUserFilter
public function testUserFilter()
{
stream_filter_register("strtoupper", "strtoupper_filter");
$fp = fopen("php://memory", 'r+');
stream_filter_append($fp, "strtoupper");
fputs($fp, "test\n");
rewind($fp);
$contents = stream_get_contents($fp);
$this->assertEquals("TEST\n", $contents);
}
示例15: testFilterHandlesBrokenParameter
/**
* @dataProvider provideBrokenParameters
*/
public function testFilterHandlesBrokenParameter($param)
{
$fp = fopen('php://memory', 'w+');
$append = "hello {$param}\n";
fputs($fp, str_repeat('a', 16384 - strlen($append)) . $append . str_repeat('test', 300));
rewind($fp);
stream_filter_register('addresses', 'Horde_Kolab_Filter_Helper_AddressFilter');
stream_filter_append($fp, 'addresses');
fread($fp, 16384 - strlen($append));
$this->assertEquals("hello {$param}\n", fread($fp, strlen($append)));
}