本文整理汇总了PHP中Closure::bind方法的典型用法代码示例。如果您正苦于以下问题:PHP Closure::bind方法的具体用法?PHP Closure::bind怎么用?PHP Closure::bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Closure
的用法示例。
在下文中一共展示了Closure::bind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInitializer
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitf1352f2cf6649e5122b3200d19030cce::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitf1352f2cf6649e5122b3200d19030cce::$prefixDirsPsr4;
}, null, ClassLoader::class);
}
示例2: getInitializer
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit2103f6e438c101833cc1f952a48877c1::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit2103f6e438c101833cc1f952a48877c1::$prefixDirsPsr4;
}, null, ClassLoader::class);
}
示例3: getInitializer
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use($loader) {
$loader->prefixesPsr0 = ComposerStaticInit387a61af024f277d76be6a9ad67ce9d2::$prefixesPsr0;
$loader->classMap = ComposerStaticInit387a61af024f277d76be6a9ad67ce9d2::$classMap;
}, null, ClassLoader::class);
}
示例4: getInitializer
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit85a1cefa95be2f464cf7f947cbc4c785::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit85a1cefa95be2f464cf7f947cbc4c785::$prefixDirsPsr4;
}, null, ClassLoader::class);
}
示例5: fillClassInstance
private function fillClassInstance($instance, $data)
{
$instantiator = $this;
$valueProcessor = function ($value) use(&$valueProcessor, $instantiator) {
if ($value instanceof ArrayedObject) {
$value = $instantiator->instantiate($value);
}
if (is_array($value)) {
foreach ($value as &$innerValue) {
$innerValue = $valueProcessor($innerValue);
}
}
return $value;
};
$setObjectVarsClosure = function ($data, $class, &$valueProcessor) {
foreach ($data as $property => $value) {
if (property_exists($class, $property)) {
$value = $valueProcessor($value);
$this->{$property} = $value;
}
}
};
$class = get_class($instance);
do {
$bindedSetObjectVarsClosure = \Closure::bind($setObjectVarsClosure, $instance, $class);
$bindedSetObjectVarsClosure($data, $class, $valueProcessor);
} while ($class = get_parent_class($class));
}
示例6: __construct
protected function __construct($namespace = '', $defaultLifetime = 0)
{
$this->namespace = '' === $namespace ? '' : $this->getId($namespace) . ':';
if (null !== $this->maxIdLength && strlen($namespace) > $this->maxIdLength - 24) {
throw new InvalidArgumentException(sprintf('Namespace must be %d chars max, %d given ("%s")', $this->maxIdLength - 24, strlen($namespace), $namespace));
}
$this->createCacheItem = \Closure::bind(function ($key, $value, $isHit) use($defaultLifetime) {
$item = new CacheItem();
$item->key = $key;
$item->value = $value;
$item->isHit = $isHit;
$item->defaultLifetime = $defaultLifetime;
return $item;
}, null, CacheItem::class);
$this->mergeByLifetime = \Closure::bind(function ($deferred, $namespace, &$expiredIds) {
$byLifetime = array();
$now = time();
$expiredIds = array();
foreach ($deferred as $key => $item) {
if (null === $item->expiry) {
$byLifetime[0 < $item->defaultLifetime ? $item->defaultLifetime : 0][$namespace . $key] = $item->value;
} elseif ($item->expiry > $now) {
$byLifetime[$item->expiry - $now][$namespace . $key] = $item->value;
} else {
$expiredIds[] = $namespace . $key;
}
}
return $byLifetime;
}, null, CacheItem::class);
}
示例7: getInitializer
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitc9b168e8400f8789b0e099f4aa1d40aa::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitc9b168e8400f8789b0e099f4aa1d40aa::$prefixDirsPsr4;
}, null, ClassLoader::class);
}
示例8: get_changed_values
function get_changed_values($object)
{
$function = \Closure::bind(function ($object) {
$changedValues = $object->changedValues;
// hack I know
if (property_exists($object, 'objects')) {
foreach ($object->objects as $namespace => $namespaceValues) {
foreach ($namespaceValues as $name => $values) {
if (is_array($values)) {
foreach ($values as $valueKey => $value) {
$changed = get_changed_values($value);
if (false == empty($changed)) {
$changedValues[$namespace][$name][$valueKey] = $changed;
}
}
} elseif (is_object($values)) {
$changed = get_changed_values($values);
if (false == empty($changed)) {
$changedValues[$namespace][$name] = $changed;
}
}
}
}
}
return $changedValues;
}, null, $object);
return $function($object);
}
示例9: partial
function partial(callable $callable, $partialArgs, $defaultArgs = [])
{
$partialMerge = function ($partialArgs, $addedArgs, $defaultArgs = []) {
end($partialArgs);
$l = key($partialArgs);
for ($i = 0; $i <= $l; $i++) {
if (!array_key_exists($i, $partialArgs) && count($addedArgs)) {
$partialArgs[$i] = array_shift($addedArgs);
}
}
if (count($addedArgs)) {
// there are $addedArgs left, so there should be no 'holes' in $partialArgs
$partialArgs = array_merge($partialArgs, $addedArgs);
}
// fill any 'holes' in $partialArgs with entries from $defaultArgs
$result = array_replace($defaultArgs, $partialArgs);
ksort($result);
return $result;
};
return function () use($callable, $partialArgs, $defaultArgs, $partialMerge) {
if ($callable instanceof \Closure && isset($this)) {
$callable = \Closure::bind($callable, $this);
}
return call_user_func_array($callable, $partialMerge($partialArgs, func_get_args(), $defaultArgs));
};
}
示例10: addMethod
public function addMethod($methodName, $methodCallable)
{
if (!is_callable($methodCallable)) {
throw new \InvalidArgumentException('Second param must be callable');
}
$this->methods[$methodName] = \Closure::bind($methodCallable, $this, get_class());
}
示例11: getInitializer
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitee24b804a2f00cc5ec6cefabe5f3d658::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitee24b804a2f00cc5ec6cefabe5f3d658::$prefixDirsPsr4;
}, null, ClassLoader::class);
}
示例12: getInitializer
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit4136185281a97be0e373e4c1a575a123::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit4136185281a97be0e373e4c1a575a123::$prefixDirsPsr4;
}, null, ClassLoader::class);
}
示例13: getInitializer
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit923639f9b6d3390d9802ecd1f72b6130::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit923639f9b6d3390d9802ecd1f72b6130::$prefixDirsPsr4;
}, null, ClassLoader::class);
}
示例14: getInitializer
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use($loader) {
$loader->prefixesPsr0 = ComposerStaticInit8c00ac27a90dfc4ac1a7acb480023ed4::$prefixesPsr0;
$loader->classMap = ComposerStaticInit8c00ac27a90dfc4ac1a7acb480023ed4::$classMap;
}, null, ClassLoader::class);
}
示例15: getInitializer
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit5aaf7da0fd82b6a6ed0ed396a67edc3d::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit5aaf7da0fd82b6a6ed0ed396a67edc3d::$prefixDirsPsr4;
}, null, ClassLoader::class);
}