本文整理汇总了PHP中Func::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Func::get方法的具体用法?PHP Func::get怎么用?PHP Func::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Func
的用法示例。
在下文中一共展示了Func::get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fopen
}
$opts->set('append', $append);
$mode = $append ? 'ab' : 'wb';
try {
$stream = fopen($fullPath, $mode);
} catch (Exception $e) {
$helpers['handleException']($e, $fullPath);
}
//fallback for if set_error_handler didn't do it's thing
if ($stream === false) {
$helpers['throwError']('EIO', $fullPath);
}
$self->stream = $stream;
$self->finished = false;
});
$prototype = $WriteStream->get('prototype');
$prototype->setMethods(array('setEncoding' => function ($enc) {
$self = Func::getContext();
$self->opts->set('encoding', $enc);
}, 'write' => function ($data, $enc = null) use(&$helpers) {
$self = Func::getContext();
if ($self->finished) {
return;
}
$data = $data instanceof Buffer ? $data->raw : $data;
write_all($self->stream, $data);
}, 'end' => function () {
$self = Func::getContext();
if ($self->finished) {
return;
}
示例2: Func
Test::assert('this is global', $self === Object::$global);
});
$fn->call();
$fn = new Func('foo', function () use($fn, $Array) {
$self = Func::getContext();
$arguments = Func::getArguments();
Test::assert('arguments length', $arguments->get('length') === 1.0);
Test::assert('arguments -> args', join(',', $arguments->args) === 'foo');
Test::assert('this is global', $self === $Array);
});
$fn->call($Array, 'foo');
});
Test::suite('Object.create', function () use($Object) {
$Animal = new Func(function () {
});
$Animal->get('prototype')->set('speak', new Func(function () {
return 'hi';
}));
$Dog = new Func(function () {
});
$Dog->set('prototype', $Object->callMethod('create', $Animal->get('prototype')));
$dog = $Dog->construct();
Test::assert('has method', $dog->get('speak') instanceof Func);
Test::assert('method call', $dog->callMethod('speak') === 'hi');
Test::assert('proto inherit', _instanceof($dog, $Dog));
Test::assert('proto inherit parent', _instanceof($dog, $Animal));
Test::assert('proto inherit top', _instanceof($dog, $Object));
$Thing = new Func(function () {
});
Test::assert('proto not instance foreign', !_instanceof($dog, $Thing));
$Dog->get('prototype')->set('speak', new Func(function () {