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


PHP CMap::isEmpty方法代码示例

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


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

示例1: testIsEmpty

 public function testIsEmpty()
 {
     $map = CMap::make();
     $this->assertTrue(CMap::isEmpty($map));
     $map = CMap::make();
     $map["one"] = "a";
     $this->assertFalse(CMap::isEmpty($map));
     $map = CMap::make();
     $map["one"] = null;
     $this->assertFalse(CMap::isEmpty($map));
 }
开发者ID:nunodotferreira,项目名称:Phred,代码行数:11,代码来源:CMapTest.php

示例2: requestField

 protected static function requestField($map, $fieldName, CInputFilter $inputFilter, &$success)
 {
     $success = true;
     // Account for the fact that, with PHP, GET and POST (and cookie) fields arrive having "." replaced with "_"
     // in their names.
     $fieldName = CString::replace($fieldName, ".", "_");
     $value;
     $hasField = false;
     if (CMap::hasKey($map, $fieldName)) {
         $value = $map[$fieldName];
         if (isset($value)) {
             if (!is_cstring($value) && !is_cmap($value)) {
                 // Should not happen in the known versions of PHP.
                 assert('false', vs(isset($this), get_defined_vars()));
                 $success = false;
                 return $inputFilter->defaultValue();
             }
             if (!self::$ms_treatEmptyRequestValuesAsAbsent) {
                 $hasField = true;
             } else {
                 if (is_cstring($value)) {
                     $hasField = !CString::isEmpty($value);
                 } else {
                     $hasField = !CMap::isEmpty($value) && !(CMap::length($value) == 1 && CMap::hasKey($value, 0) && is_cstring($value[0]) && CString::isEmpty($value[0]));
                 }
             }
         }
     }
     if (!$hasField) {
         $success = false;
         return $inputFilter->defaultValue();
     }
     $inputFilterOrFilterCollection;
     if ($inputFilter->expectedType() != CInputFilter::CARRAY && $inputFilter->expectedType() != CInputFilter::CMAP) {
         $inputFilterOrFilterCollection = $inputFilter;
     } else {
         $inputFilterOrFilterCollection = $inputFilter->collectionInputFilters();
     }
     // Recursively convert any PHP array that has sequential keys and for which CArray type is expected into a
     // CArray, while leaving PHP arrays for which CMap type is expected untouched.
     $value = self::recurseValueBeforeFiltering($value, $inputFilterOrFilterCollection, $success, 0);
     if (!$success) {
         return $inputFilter->defaultValue();
     }
     return $inputFilter->filter($value, $success);
 }
开发者ID:nunodotferreira,项目名称:Phred,代码行数:46,代码来源:CRequest.php

示例3: hasKeywords

 /**
  * Determines if a locale has any keyword-value pairs.
  *
  * @return bool `true` if the locale has any keyword-value pairs, `false` otherwise.
  */
 public function hasKeywords()
 {
     $keywords = Locale::getKeywords($this->m_name);
     return is_cmap($keywords) && !CMap::isEmpty($keywords);
 }
开发者ID:nunodotferreira,项目名称:Phred,代码行数:10,代码来源:CULocale.php

示例4: leaveNode

 public function leaveNode(PhpParser\Node $node)
 {
     if ($node instanceof PhpParser\Node\Stmt\Class_ || $node instanceof PhpParser\Node\Stmt\Trait_) {
         $this->m_numEnteredClassesOrTraits--;
     } else {
         if ($node instanceof PhpParser\Node\Stmt\Interface_) {
             $this->m_numEnteredInterfaces--;
         } else {
             if ($node instanceof PhpParser\Node\Stmt\ClassMethod) {
                 $numEnteredMethods = $this->m_numEnteredMethods;
                 $this->m_numEnteredMethods--;
                 if (!($this->m_numEnteredClassesOrTraits == 1 && $this->m_numEnteredInterfaces == 0 && $numEnteredMethods == 1 && $this->m_numEnteredClosures == 0 && $this->m_numEnteredFunctions == 0)) {
                     return;
                 }
                 $method = $node;
                 if ($method->isProtected() && !$this->m_wrapProtectedMethods && !$this->m_isTrait || $method->isPrivate() && !$this->m_wrapPrivateMethods && !$this->m_isTrait || $method->isAbstract()) {
                     return;
                 }
                 if (!isset($method->stmts) || CMap::isEmpty($method->stmts)) {
                     return;
                 }
                 $hasParams = false;
                 $params = CArray::make();
                 $hasParamsByRef = false;
                 $paramsByRef = CArray::make();
                 if (isset($method->params) && !CMap::isEmpty($method->params)) {
                     $hasParams = true;
                     $params = CArray::fromPArray($method->params);
                     $paramsByRef = CArray::filter($params, function ($param) {
                         return $param->byRef;
                     });
                     $hasParamsByRef = !CArray::isEmpty($paramsByRef);
                 }
                 $method->stmts[0]->setAttribute("_imFirstStmtInMethodOrFunction", true);
                 $method->stmts[CMap::length($method->stmts) - 1]->setAttribute("_imLastStmtInMethodOrFunction", true);
                 $statements = [$method];
                 $methodFirstLastStmtVisitor = new CMethodOrFunctionFirstLastStmtVisitor($hasParams, $params, $hasParamsByRef, $paramsByRef);
                 $traverser = new PhpParser\NodeTraverser();
                 $traverser->addVisitor($methodFirstLastStmtVisitor);
                 $statements = $traverser->traverse($statements);
                 $method = $statements[0];
                 $returnVisitor = new CReturnVisitor($hasParams, $params, $hasParamsByRef, $paramsByRef, $method->byRef, CReturnVisitor::SUBJ_METHOD);
                 $traverser = new PhpParser\NodeTraverser();
                 $traverser->addVisitor($returnVisitor);
                 $statements = $traverser->traverse($statements);
                 return $statements;
             } else {
                 if ($node instanceof PhpParser\Node\Expr\Closure) {
                     $this->m_numEnteredClosures--;
                 } else {
                     if ($node instanceof PhpParser\Node\Stmt\Function_) {
                         $this->m_numEnteredFunctions--;
                     }
                 }
             }
         }
     }
 }
开发者ID:nunodotferreira,项目名称:Phred,代码行数:58,代码来源:CSystem.php

示例5: queryString

 /**
  * Composes a URL query into a query string ready to be used as a part of a URL and returns it.
  *
  * Any characters that cannot be represented literally in a valid query string come out percent-encoded. The
  * resulting query string never starts with "?".
  *
  * Because the characters in field named and field values are stored in their literal representations, the
  * resulting query string is always normalized, with only those characters appearing percent-encoded that really
  * require it for the query string to be valid and with the hexadecimal letters in percent-encoded characters
  * appearing uppercased. Also, no duplicate fields are produced in the resulting query string (even if the object
  * was constructed from a query string with duplicate fields in it) and "=" is added after any field name that goes
  * without a value and is not followed by "=".
  *
  * @param  bool $sortFields **OPTIONAL. Default is** `false`. Tells whether the fields in the query string should
  * appear sorted in the ascending order, case-insensitively, and with natural order comparison used for sorting.
  *
  * @return CUStringObject The query string.
  */
 public function queryString($sortFields = false)
 {
     assert('is_bool($sortFields)', vs(isset($this), get_defined_vars()));
     if (!CMap::isEmpty($this->m_query)) {
         $useQuery = CMap::makeCopy($this->m_query);
         // Recursively convert any CArray into a CMap for `http_build_query` function to accept the query.
         $useQuery = self::recurseQueryValueBeforeComposingQs($useQuery, 0);
         // Compose a preliminary query string.
         $queryString = http_build_query($useQuery, "", self::$ms_fieldDelimiters[0], PHP_QUERY_RFC1738);
         if (!is_cstring($queryString)) {
             return "";
         }
         // Break the string into fields.
         $fields = CString::split($queryString, self::$ms_fieldDelimiters[0]);
         // Adjust the result of `http_build_query` function.
         $len = CArray::length($fields);
         for ($i = 0; $i < $len; $i++) {
             if (CString::find($fields[$i], "=")) {
                 // Revert excessive percent-encoding of the square brackets next to the identifiers of
                 // multidimensional data.
                 $fields[$i] = CRegex::replaceWithCallback($fields[$i], "/(?:%5B(?:[^%]++|%(?!5B|5D))*+%5D)+?=/i", function ($matches) {
                     $value = $matches[0];
                     $value = CString::replace($value, "%5B", "[");
                     $value = CString::replace($value, "%5D", "]");
                     return $value;
                 });
                 // Remove redundant indexing next to the identifiers of simple arrays.
                 $fields[$i] = CRegex::replaceWithCallback($fields[$i], "/^.+?=/", function ($matches) {
                     return CRegex::replace($matches[0], "/\\[\\d+\\]/", "[]");
                 });
             }
         }
         if ($sortFields) {
             // Normalize the order of fields.
             CArray::sortStringsNatCi($fields);
         }
         $queryString = CArray::join($fields, self::$ms_fieldDelimiters[0]);
         return $queryString;
     } else {
         return "";
     }
 }
开发者ID:nunodotferreira,项目名称:Phred,代码行数:60,代码来源:CUrlQuery.php


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