当前位置: 首页>>代码示例>>PHP>>正文


PHP FilterIterator::key方法代码示例

本文整理汇总了PHP中FilterIterator::key方法的典型用法代码示例。如果您正苦于以下问题:PHP FilterIterator::key方法的具体用法?PHP FilterIterator::key怎么用?PHP FilterIterator::key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FilterIterator的用法示例。


在下文中一共展示了FilterIterator::key方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: accept

 /**
  * @return bool
  */
 public function accept()
 {
     $key = parent::key();
     $innerIterator = $this->getInnerIterator();
     $token = $innerIterator[$key - $this->offset];
     $label = null;
     if (is_array($token)) {
         $label = $token[0];
     } elseif (is_string($token)) {
         $label = $token;
     }
     return in_array($label, $this->allowedTokens);
 }
开发者ID:jeabakker,项目名称:code_review,代码行数:16,代码来源:PhpTokensFilterIterator.php

示例2: accept

 /**
  * ( excerpt from http://php.net/manual/en/regexiterator.accept.php )
  *
  * Matches (string) RegexIterator::current() (or RegexIterator::key() if
  * the RegexIterator::USE_KEY flag is set) against the regular expression.
  *
  * @return boolean TRUE if a match, FALSE otherwise.
  */
 public function accept()
 {
     $this->key = parent::key();
     $this->current = parent::current();
     $matches = array();
     $useKey = $this->flags & self::USE_KEY;
     $subject = $useKey ? (string) $this->key : (string) $this->current;
     switch ($this->mode) {
         case self::MATCH:
             $ret = preg_match($this->regex, $subject, $matches, $this->pregFlags) > 0;
             break;
         case self::GET_MATCH:
             $this->current = array();
             $ret = preg_match($this->regex, $subject, $this->current, $this->pregFlags) > 0;
             break;
         case self::ALL_MATCHES:
             $this->current = array();
             preg_match_all($this->regex, $subject, $this->current, $this->pregFlags);
             $ret = count($this->current) > 0;
             break;
         case self::SPLIT:
             $this->current = preg_split($this->regex, $subject, null, $this->pregFlags);
             $ret = $this->current && count($this->current) > 1;
             break;
         case self::REPLACE:
             $replace_count = 0;
             $result = preg_replace($this->regex, $this->replacement, $subject, -1, $replace_count);
             if ($result === null || $replace_count == 0) {
                 $ret = false;
                 break;
             }
             if ($useKey) {
                 $this->key = $result;
                 $ret = true;
                 break;
             }
             $this->current = $result;
             $ret = true;
             break;
         default:
             $ret = false;
             break;
     }
     if ($this->flags & self::INVERT_MATCH) {
         return !$ret;
     } else {
         return $ret;
     }
 }
开发者ID:alphaxxl,项目名称:hhvm,代码行数:57,代码来源:RegexIterator.php

示例3: accept

 /** Call the filter callback
  * @return result of filter callback
  */
 public function accept()
 {
     $this->key = parent::key();
     $this->current = parent::current();
     switch ($this->mode) {
         default:
         case self::USE_FALSE:
             return false;
         case self::USE_TRUE:
             return true;
         case self::USE_VALUE:
             return (bool) call_user_func($this->callback, $this->current);
         case self::USE_KEY:
             return (bool) call_user_func($this->callback, $this->key);
         case self::USE_BOTH:
             return (bool) call_user_func($this->callback, $this->key, $this->current);
     }
 }
开发者ID:eugenehiggins,项目名称:wordpress-intermediate,代码行数:21,代码来源:Sns_Callback_Filter_Iterator.php

示例4: current

 function current()
 {
     $xml = parent::current();
     if (isset($xml[0])) {
         $tasks = array();
         $task = str_replace(array($this->_tasksNs . ':', '-'), array('', ' '), parent::key());
         $task = str_replace(' ', '/', ucwords($task));
         $task = str_replace('/', '_', $task);
         $task = '\\Pyrus\\Task\\' . $task;
         foreach ($xml as $info) {
             $attribs = array();
             if (isset($xml['attribs'])) {
                 $attribs = $xml['attribs'];
             }
             $tasks[] = new $task($this->_parent, $this->_installphase, $info, $attribs, $this->lastversion);
         }
         $attribs = isset($this->_inner['attribs']) ? array($this->_inner['attribs']) : $this->_inner;
         // use proxy for multiple tasks
         return new \Pyrus\Task\MultipleProxy($this->_parent, $tasks, $attribs, $this->key());
     }
     $attribs = array();
     if (isset($xml['attribs'])) {
         $attribs = $xml['attribs'];
     }
     $task = \Pyrus\Task\Common::getTask(parent::key());
     if ($task === false) {
         throw new \RuntimeException('Unknown task `' . parent::key() . '` specified.');
     }
     return new $task($this->_parent, $this->_installphase, $xml, $attribs, $this->lastversion);
 }
开发者ID:peopleplan,项目名称:Pyrus,代码行数:30,代码来源:TaskIterator.php

示例5: key

	public function key() {
		$this->init();
		return parent::key();
	}
开发者ID:nahoj,项目名称:mediawiki_ynh,代码行数:4,代码来源:MappedIterator.php

示例6: accept

 public function accept()
 {
     return preg_match($this->regex, parent::key());
 }
开发者ID:xtrasmal,项目名称:iinano,代码行数:4,代码来源:KeyRegexFilter.php

示例7: current

    function current()
    {
        $xml = parent::current();
        if (isset($xml[0])) {
            $tasks = array();
            $task = str_replace(array($this->_tasksNs . ':', '-'), array('', ' '), parent::key());
            $task = str_replace(' ', '/', ucwords($task));
            $task = str_replace('/', '_', $task);
            $task = '\PEAR2\Pyrus\Task\\' . $task;
            foreach ($xml as $info) {
                $attribs = array();
                if (isset($xml['attribs'])) {
                    $attribs = $xml['attribs'];
                }

                $tasks[] = new $task($this->_parent, $this->_installphase, $info, $attribs, $this->lastversion);
            }

            $attribs = isset($this->_inner['attribs']) ? array($this->_inner['attribs']) : $this->_inner;
            // use proxy for multiple tasks
            return new \PEAR2\Pyrus\Task\MultipleProxy($this->_parent, $tasks, $attribs, $this->key());
        }

        $attribs = array();
        if (isset($xml['attribs'])) {
            $attribs = $xml['attribs'];
        }

        $task = str_replace(array($this->_tasksNs . ':', '-'), array('', ' '), parent::key());
        $task = str_replace(' ', '/', ucwords($task));
        $task = str_replace('/', '_', $task);
        $task = '\PEAR2\Pyrus\Task\\' . $task;
        return new $task($this->_parent, $this->_installphase, $xml, $attribs, $this->lastversion);
    }
开发者ID:naderman,项目名称:PEAR2_Pyrus,代码行数:34,代码来源:TaskIterator.php

示例8: accept

 public function accept()
 {
     $fn = $this->callback;
     return $fn(parent::current(), parent::key());
 }
开发者ID:Garcy111,项目名称:Garcy-Framework-2,代码行数:5,代码来源:Filter.php


注:本文中的FilterIterator::key方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。