本文整理匯總了PHP中Generator::key方法的典型用法代碼示例。如果您正苦於以下問題:PHP Generator::key方法的具體用法?PHP Generator::key怎麽用?PHP Generator::key使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Generator
的用法示例。
在下文中一共展示了Generator::key方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: key
public function key()
{
if ($this->_currentGen) {
return $this->_currentGen->key();
}
return key($this->_records);
}
示例2: __construct
/**
* @param \Generator $generator
* @param string $prefix
*/
public function __construct(\Generator $generator, string $prefix)
{
$yielded = $generator->current();
$prefix .= \sprintf("; %s yielded at key %s", \is_object($yielded) ? \get_class($yielded) : \gettype($yielded), $generator->key());
if (!$generator->valid()) {
parent::__construct($prefix);
return;
}
$reflGen = new \ReflectionGenerator($generator);
$exeGen = $reflGen->getExecutingGenerator();
if ($isSubgenerator = $exeGen !== $generator) {
$reflGen = new \ReflectionGenerator($exeGen);
}
parent::__construct(\sprintf("%s on line %s in %s", $prefix, $reflGen->getExecutingLine(), $reflGen->getExecutingFile()));
}
示例3: key
/**
* Return the key of the current element
* @see Iterator::key
* @link http://php.net/manual/en/iterator.key.php
* @return mixed scalar on success, or null on failure.
*/
public function key()
{
return $this->generator->key();
}
示例4: hasTokens
protected function hasTokens()
{
return $this->_tokens->key() !== null;
}
示例5: key
public function key()
{
if (!$this->generator) {
$this->rewind();
}
return $this->generator->key();
}
示例6: key
/**
* Get current key
*
* @return mixed
*/
public function key()
{
return $this->generator ? $this->generator->key() : $this->index++;
}
示例7: key
/**
* Return current key.
* @return mixed
*/
public function key()
{
$this->validateValidity();
return $this->g->key();
}