當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CMap::make方法代碼示例

本文整理匯總了PHP中CMap::make方法的典型用法代碼示例。如果您正苦於以下問題:PHP CMap::make方法的具體用法?PHP CMap::make怎麽用?PHP CMap::make使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CMap的用法示例。


在下文中一共展示了CMap::make方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __construct

 /**
  * Creates a URL query from a query string or as empty.
  *
  * Just like in any valid URL, a provided query string is not expected to contain characters that cannot be
  * represented literally and percent-encoding is expected to be used for any such characters. The query string
  * should not contain a leading "?" because it's rather a delimiter that is used to separate the query string from
  * the preceding URL part.
  *
  * @param  string $queryString **OPTIONAL. Default is** *create an empty URL query*. The source query string.
  * @param  reference $parsingWasFruitful **OPTIONAL. OUTPUT.** After the object is constructed, this parameter,
  * which is of type `bool`, tells whether the parsing of the query string resulted in any valid fields.
  */
 public function __construct($queryString = null, &$parsingWasFruitful = null)
 {
     assert('!isset($queryString) || is_cstring($queryString)', vs(isset($this), get_defined_vars()));
     if (isset($queryString)) {
         if (!CString::isEmpty($queryString)) {
             // Before parsing, normalize field delimiters to the default one (e.g. make ";" to be "&").
             $delimiters = CString::splitIntoChars(self::$ms_fieldDelimiters);
             $fields = CString::split($queryString, $delimiters);
             $queryString = CArray::join($fields, self::$ms_fieldDelimiters[0]);
             // Parse the query string.
             parse_str($queryString, $this->m_query);
             if (!is_cmap($this->m_query)) {
                 $this->m_query = CMap::make();
             }
             // Recursively convert any PHP's associative array with sequential keys into a CArray.
             foreach ($this->m_query as &$value) {
                 $value = self::recurseQueryValueAfterParsing($value, 0);
             }
             unset($value);
         } else {
             $this->m_query = CMap::make();
         }
         $parsingWasFruitful = !CMap::isEmpty($this->m_query);
     } else {
         $this->m_query = CMap::make();
     }
 }
開發者ID:nunodotferreira,項目名稱:Phred,代碼行數:39,代碼來源:CUrlQuery.php

示例2: keywords

 /**
  * Returns the keyword-value pairs of a locale.
  *
  * @return CMapObject The locale's keyword-value pairs, with values of type `CUStringObject`.
  */
 public function keywords()
 {
     assert('$this->hasKeywords()', vs(isset($this), get_defined_vars()));
     $keywords = Locale::getKeywords($this->m_name);
     return oop_m(is_cmap($keywords) ? $keywords : CMap::make());
 }
開發者ID:nunodotferreira,項目名稱:Phred,代碼行數:11,代碼來源:CULocale.php

示例3: union

 /**
  * Unites two or more arrays together and returns the new array.
  *
  * The arrays that need to be united are passed as arguments to this method. The order in which the arrays are
  * passed determines the order of elements in the resulting array.
  *
  * None of the source arrays is modified by this method.
  *
  * @return CArray The union array.
  */
 public static function union()
 {
     $funcNumArgs = func_num_args();
     assert('$funcNumArgs >= 2', vs(isset($this), get_defined_vars()));
     $resArray = CMap::make();
     $arguments = func_get_args();
     foreach ($arguments as $array) {
         assert('is_carray($array)', vs(isset($this), get_defined_vars()));
         $array = splarray($array);
         $resArray = array_merge($resArray, self::toPArray($array));
     }
     return self::fromPArray($resArray);
 }
開發者ID:nunodotferreira,項目名稱:Phred,代碼行數:23,代碼來源:CArray.php

示例4: leaveNode

 public function leaveNode(PhpParser\Node $node)
 {
     if ($node->hasAttribute("_insertGetMMethodAfterMe") || $node->hasAttribute("_insertSetMMethodAfterMe")) {
         $statements = [$node];
         if ($node->hasAttribute("_insertGetMMethodAfterMe")) {
             $subStatements = CMap::make();
             $len = CArray::length($this->m_propsToWrap);
             for ($i = 0; $i < $len; $i++) {
                 $propName = $this->m_propsToWrap[$i];
                 $subCondition = new PhpParser\Node\Expr\BooleanNot(new PhpParser\Node\Expr\FuncCall(new PhpParser\Node\Name(self::$ms_isFwCallFuncName)));
                 $return0 = new PhpParser\Node\Stmt\Return_(new PhpParser\Node\Expr\PropertyFetch(new PhpParser\Node\Expr\Variable("this"), $propName));
                 $return1 = new PhpParser\Node\Stmt\Return_(new PhpParser\Node\Expr\FuncCall(new PhpParser\Node\Name(self::$ms_toOopFuncName), [new PhpParser\Node\Expr\PropertyFetch(new PhpParser\Node\Expr\Variable("this"), $propName)]));
                 $else = new PhpParser\Node\Stmt\Else_([$return1]);
                 $subIf = new PhpParser\Node\Stmt\If_($subCondition, ["stmts" => [$return0], "else" => $else]);
                 $condition = new PhpParser\Node\Expr\BinaryOp\Identical(new PhpParser\Node\Expr\Variable("name"), new PhpParser\Node\Scalar\String($propName));
                 $if = new PhpParser\Node\Stmt\If_($condition, ["stmts" => [$subIf]]);
                 CMap::insertValue($subStatements, $if);
             }
             $method = new PhpParser\Node\Stmt\ClassMethod("__get", ["type" => PhpParser\Node\Stmt\Class_::MODIFIER_PUBLIC, "byRef" => true, "params" => [new PhpParser\Node\Param("name")], "stmts" => $subStatements]);
             CMap::insertValue($statements, $method);
         }
         if ($node->hasAttribute("_insertSetMMethodAfterMe")) {
             $subStatements = CMap::make();
             $len = CArray::length($this->m_propsToWrap);
             for ($i = 0; $i < $len; $i++) {
                 $propName = $this->m_propsToWrap[$i];
                 $subCondition = new PhpParser\Node\Expr\BooleanNot(new PhpParser\Node\Expr\FuncCall(new PhpParser\Node\Name(self::$ms_isFwCallFuncName)));
                 $assignment0 = new PhpParser\Node\Expr\Assign(new PhpParser\Node\Expr\PropertyFetch(new PhpParser\Node\Expr\Variable("this"), $propName), new PhpParser\Node\Expr\Variable("value"));
                 $assignment1 = new PhpParser\Node\Expr\Assign(new PhpParser\Node\Expr\PropertyFetch(new PhpParser\Node\Expr\Variable("this"), $propName), new PhpParser\Node\Expr\FuncCall(new PhpParser\Node\Name(self::$ms_fromOopFuncName), [new PhpParser\Node\Expr\Variable("value")]));
                 $else = new PhpParser\Node\Stmt\Else_([$assignment1]);
                 $subIf = new PhpParser\Node\Stmt\If_($subCondition, ["stmts" => [$assignment0], "else" => $else]);
                 $condition = new PhpParser\Node\Expr\BinaryOp\Identical(new PhpParser\Node\Expr\Variable("name"), new PhpParser\Node\Scalar\String($propName));
                 $if = new PhpParser\Node\Stmt\If_($condition, ["stmts" => [$subIf]]);
                 CMap::insertValue($subStatements, $if);
             }
             $method = new PhpParser\Node\Stmt\ClassMethod("__set", ["type" => PhpParser\Node\Stmt\Class_::MODIFIER_PUBLIC, "params" => [new PhpParser\Node\Param("name"), new PhpParser\Node\Param("value")], "stmts" => $subStatements]);
             CMap::insertValue($statements, $method);
         }
         return $statements;
     }
 }
開發者ID:nunodotferreira,項目名稱:Phred,代碼行數:41,代碼來源:CSystem.php

示例5: addBcc

 /**
  * Adds the email address and, optionally, the name of a "blind carbon copy" recipient who should receive a copy of
  * a message so that this recipient is not visible to any other recipients.
  *
  * @param  string $address The email address of the recipient.
  * @param  string $name **OPTIONAL.** The name of the recipient.
  *
  * @return void
  */
 public function addBcc($address, $name = null)
 {
     assert('is_cstring($address) && (!isset($name) || is_cstring($name))', vs(isset($this), get_defined_vars()));
     if (!isset($this->m_bcc)) {
         $this->m_bcc = CMap::make();
     }
     if (!isset($name)) {
         CMap::insertValue($this->m_bcc, $address);
     } else {
         $this->m_bcc[$address] = $name;
     }
 }
開發者ID:nunodotferreira,項目名稱:Phred,代碼行數:21,代碼來源:CMail.php

示例6: setInternalOptions

 /**
  * @ignore
  */
 public function setInternalOptions(&$success, $cookiesFp = null, $newCookieSession = null)
 {
     $success = true;
     if ($this->m_hasError) {
         $success = false;
         $this->finalize();
         return;
     }
     $options = CMap::make();
     // How to deal with the response.
     if (!$this->m_echoResponse) {
         $options[CURLOPT_RETURNTRANSFER] = true;
         $this->m_isReturnTransferSet = true;
     } else {
         $options[CURLOPT_RETURNTRANSFER] = false;
         $this->m_isReturnTransferSet = false;
     }
     if (isset($this->m_verboseOutput) && $this->m_verboseOutput) {
         $options[CURLOPT_VERBOSE] = true;
     }
     // The destination URL and port.
     $options[CURLOPT_URL] = $this->m_url;
     if (isset($this->m_port)) {
         $options[CURLOPT_PORT] = $this->m_port;
     }
     // Avoid response caching and reuse, which might happen because of any unconventional caching strategies used
     // by cURL.
     $options[CURLOPT_FORBID_REUSE] = true;
     $options[CURLOPT_FRESH_CONNECT] = true;
     if ($this->m_type != self::HTTP_HEAD) {
         $options[CURLOPT_HEADER] = false;
     }
     if ($this->isHttp()) {
         if ($this->m_type == self::HTTP_GET) {
             $options[CURLOPT_HTTPGET] = true;
         } else {
             if ($this->m_type == self::HTTP_DOWNLOAD || $this->m_type == self::ANY_DOWNLOAD) {
                 $options[CURLOPT_HTTPGET] = true;
                 assert('isset($this->m_downloadDestinationFp)', vs(isset($this), get_defined_vars()));
                 $this->m_downloadFile = new CFile($this->m_downloadDestinationFp, CFile::WRITE_NEW);
                 $options[CURLOPT_FILE] = $this->m_downloadFile->systemResource();
             } else {
                 if ($this->m_type == self::HTTP_POST) {
                     // POST.
                     $options[CURLOPT_POST] = true;
                     // At least one POST variable needs to be set in order to make a POST request.
                     assert('isset($this->m_postQuery)', vs(isset($this), get_defined_vars()));
                     // POST variables use the same format as the query string (application/x-www-form-urlencoded).
                     $options[CURLOPT_POSTFIELDS] = $this->m_postQuery->queryString();
                 } else {
                     if ($this->m_type == self::HTTP_UPLOAD) {
                         // File upload via POST and using the CURLFile class.
                         $options[CURLOPT_POST] = true;
                         assert('isset($this->m_postFileUploadRecord)', vs(isset($this), get_defined_vars()));
                         $options[CURLOPT_POSTFIELDS] = $this->m_postFileUploadRecord;
                     } else {
                         if ($this->m_type == self::HTTP_PUT) {
                             // PUT.
                             assert('isset($this->m_nonPostFileUploadFp)', vs(isset($this), get_defined_vars()));
                             $options[CURLOPT_PUT] = true;
                             $this->m_uploadFile = new CFile($this->m_nonPostFileUploadFp, CFile::READ);
                             $options[CURLOPT_INFILE] = $this->m_uploadFile->systemResource();
                             $options[CURLOPT_INFILESIZE] = CFile::size($this->m_nonPostFileUploadFp);
                         } else {
                             if ($this->m_type == self::HTTP_DELETE) {
                                 // DELETE.
                                 $options[CURLOPT_CUSTOMREQUEST] = "DELETE";
                             } else {
                                 if ($this->m_type == self::HTTP_HEAD) {
                                     // HEAD.
                                     $options[CURLOPT_HEADER] = true;
                                     $options[CURLOPT_NOBODY] = true;
                                 }
                             }
                         }
                     }
                 }
             }
         }
         // HTTP redirections.
         $options[CURLOPT_FOLLOWLOCATION] = $this->m_redirection;
         if ($this->m_redirection) {
             if (isset($this->m_maxNumRedirections)) {
                 $options[CURLOPT_MAXREDIRS] = $this->m_maxNumRedirections;
             }
             if (isset($this->m_redirectionAutoReferer)) {
                 $options[CURLOPT_AUTOREFERER] = $this->m_redirectionAutoReferer;
             }
             if (isset($this->m_redirectionKeepAuth)) {
                 $options[CURLOPT_UNRESTRICTED_AUTH] = $this->m_redirectionKeepAuth;
             }
         }
         // HTTP response code treatment.
         $options[CURLOPT_FAILONERROR] = $this->m_failOn400ResponseCodeOrGreater;
         // HTTP headers.
         if ($this->m_sendDefaultAcceptEncodingHeader && !(isset($this->m_requestHeaders) && $this->hasHeader(CHttpRequest::ACCEPT_ENCODING))) {
             $options[CURLOPT_ENCODING] = "";
//.........這裏部分代碼省略.........
開發者ID:nunodotferreira,項目名稱:Phred,代碼行數:101,代碼來源:CInetRequest.php

示例7: testFindScalar

 public function testFindScalar()
 {
     $map = ["one" => "a", "two" => "b", "three" => "c", "four" => "d", "five" => "e"];
     $found = CMap::findScalar($map, "c");
     $this->assertTrue($found);
     $foundUnderKey;
     $found = CMap::findScalar($map, "d", $foundUnderKey);
     $this->assertTrue($found);
     $this->assertTrue($foundUnderKey === "four");
     $found = CMap::findScalar($map, "C");
     $this->assertFalse($found);
     $found = CMap::findScalar($map, "f");
     $this->assertFalse($found);
     // Special case.
     $map = CMap::make();
     $found = CMap::findScalar($map, "a");
     $this->assertFalse($found);
 }
開發者ID:nunodotferreira,項目名稱:Phred,代碼行數:18,代碼來源:CMapTest.php

示例8: __construct

 /**
  * Creates a filter suited for a specified data type to be outputted.
  *
  * @param  enum $expectedType The output data type that is expected (see [Summary](#summary)).
  * @param  mixed $collectionInputFilters **OPTIONAL.** *Required only when the expected type is `CARRAY` or
  * `CMAP`*. The array or map containing the filters to be applied to the elements in the input array if the
  * expected type is `CARRAY` or to the values in the input map if the expected type is `CMAP`. If the input value
  * is going to be an array, the number of filters in this parameter should match the length of the input array, and
  * if the input value is going to be a map, the keys in this parameter should match the keys in the input map. Same
  * as input arrays and maps, this parameter can be multidimensional in order to correspond with the input value.
  */
 public function __construct($expectedType, $collectionInputFilters = null)
 {
     assert('is_enum($expectedType) && !($expectedType != self::CARRAY && $expectedType != self::CMAP && ' . 'isset($collectionInputFilters)) && !($expectedType == self::CARRAY && ' . '!is_carray($collectionInputFilters)) && !($expectedType == self::CMAP && ' . '!is_cmap($collectionInputFilters))', vs(isset($this), get_defined_vars()));
     $this->m_expectedType = $expectedType;
     $this->m_collectionInputFilters = $collectionInputFilters;
     switch ($expectedType) {
         case self::BOOL:
             $this->m_defaultValue = false;
             break;
         case self::INT:
             $this->m_defaultValue = 0;
             break;
         case self::FLOAT:
             $this->m_defaultValue = 0.0;
             break;
         case self::CSTRING:
         case self::CUSTRING:
             $this->m_defaultValue = "";
             break;
         case self::CARRAY:
             $this->m_defaultValue = CArray::make();
             break;
         case self::CMAP:
             $this->m_defaultValue = CMap::make();
             break;
         case self::EMAIL:
         case self::URL:
         case self::IP:
             $this->m_defaultValue = "";
             break;
         default:
             assert('false', vs(isset($this), get_defined_vars()));
             break;
     }
 }
開發者ID:nunodotferreira,項目名稱:Phred,代碼行數:46,代碼來源:CInputFilter.php


注:本文中的CMap::make方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。