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


PHP CMap::areKeysSequential方法代码示例

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


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

示例1: recurseValueBeforeFiltering

 protected static function recurseValueBeforeFiltering($value, $inputFilterOrFilterCollection, &$success, $currDepth)
 {
     assert('$inputFilterOrFilterCollection instanceof CInputFilter || ' . 'is_collection($inputFilterOrFilterCollection)', vs(isset($this), get_defined_vars()));
     if ($currDepth == self::$ms_maxRecursionDepth) {
         $success = false;
         return;
     }
     $currDepth++;
     if (!is_cmap($value)) {
         // Only interested in PHP arrays.
         return $value;
     }
     if (is_carray($inputFilterOrFilterCollection)) {
         // The output value is expected to be a CArray; the keys in the arrived PHP array should be sequential.
         if (!CMap::areKeysSequential($value)) {
             $success = false;
             return;
         }
         $value = CArray::fromPArray($value);
         $len = CArray::length($value);
         if ($len != CArray::length($inputFilterOrFilterCollection)) {
             $success = false;
             return;
         }
         for ($i = 0; $i < $len; $i++) {
             $inputValue = $value[$i];
             $inputFilterElement = $inputFilterOrFilterCollection[$i];
             $inputValue = self::recurseValueBeforeFiltering($inputValue, $inputFilterElement, $success, $currDepth);
             if (!$success) {
                 return;
             }
             $value[$i] = $inputValue;
         }
     } else {
         if (is_cmap($inputFilterOrFilterCollection)) {
             // The output value is expected to be a CMap; already got one.
             foreach ($value as $inputKey => &$inputValue) {
                 if (!CMap::hasKey($inputFilterOrFilterCollection, $inputKey)) {
                     $success = false;
                     return;
                 }
                 $inputFilterElement = $inputFilterOrFilterCollection[$inputKey];
                 $inputValue = self::recurseValueBeforeFiltering($inputValue, $inputFilterElement, $success, $currDepth);
                 if (!$success) {
                     return;
                 }
             }
             unset($inputValue);
         } else {
             $success = false;
             return;
         }
     }
     return $value;
 }
开发者ID:nunodotferreira,项目名称:Phred,代码行数:55,代码来源:CRequest.php

示例2: areKeysSequential

 /**
  * Determines if the keys in a map are all integer and sequential.
  *
  * Sequential keys are a sequence of integers that start with a `0` and go up, incrementing exactly by one.
  *
  * This method could be useful to see if a PHP's associative array (a map) can be naturally converted into a
  * regular array (an OOP array) when dealing with interfaces that are using the PHP's associative array in the role
  * of a regular array.
  *
  * As a special case, the method returns `true` for an empty map.
  *
  * @return bool `true` if all keys in the map are integer and sequential, `false` otherwise.
  */
 public function areKeysSequential()
 {
     return CMap::areKeysSequential($this->m_map);
 }
开发者ID:nunodotferreira,项目名称:Phred,代码行数:17,代码来源:CMapObject.php

示例3: testAreKeysSequential

 public function testAreKeysSequential()
 {
     $map = [0 => "a", 1 => "b", 2 => "c", 3 => "d", 4 => "e"];
     $this->assertTrue(CMap::areKeysSequential($map));
     $map = [0 => "a", 1 => "b", 2 => "c", 4 => "d", 5 => "e"];
     $this->assertFalse(CMap::areKeysSequential($map));
     $map = [0 => "a", 1 => "b", 2 => "c", "three" => "d", 4 => "e"];
     $this->assertFalse(CMap::areKeysSequential($map));
 }
开发者ID:nunodotferreira,项目名称:Phred,代码行数:9,代码来源:CMapTest.php

示例4: _to_oop_tp

/**
 * @ignore
 */
function _to_oop_tp($value)
{
    // Only used with OOP wrapping for third-party components.
    if (is_array($value)) {
        foreach ($value as &$mapValue) {
            $mapValue = _to_oop_tp($mapValue);
        }
        unset($mapValue);
        if (!CMap::areKeysSequential($value)) {
            $value = oop_m($value);
        } else {
            $value = oop_a(CArray::fromPArray($value));
        }
        return $value;
    }
    if ($value instanceof SplFixedArray) {
        $len = CArray::length($value);
        for ($i = 0; $i < $len; $i++) {
            $value[$i] = _to_oop_tp($value[$i]);
        }
        return oop_a($value);
    }
    return $value;
}
开发者ID:nunodotferreira,项目名称:Phred,代码行数:27,代码来源:FType.php

示例5: recurseQueryValueAfterParsing

 protected static function recurseQueryValueAfterParsing($value, $currDepth)
 {
     if ($currDepth == self::$ms_maxRecursionDepth) {
         return $value;
     }
     $currDepth++;
     if (!is_cmap($value)) {
         // Only interested in PHP's associative arrays.
         return $value;
     }
     if (CMap::areKeysSequential($value)) {
         $value = CArray::fromPArray($value);
         $len = CArray::length($value);
         for ($i = 0; $i < $len; $i++) {
             $value[$i] = self::recurseQueryValueAfterParsing($value[$i], $currDepth);
         }
         return oop_a($value);
     } else {
         foreach ($value as &$mapValue) {
             $mapValue = self::recurseQueryValueAfterParsing($mapValue, $currDepth);
         }
         unset($mapValue);
         return oop_m($value);
     }
 }
开发者ID:nunodotferreira,项目名称:Phred,代码行数:25,代码来源:CUrlQuery.php


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