本文整理汇总了PHP中CMap::insertValue方法的典型用法代码示例。如果您正苦于以下问题:PHP CMap::insertValue方法的具体用法?PHP CMap::insertValue怎么用?PHP CMap::insertValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMap
的用法示例。
在下文中一共展示了CMap::insertValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: insertValue
/**
* Inserts a value into a map under the next integer key.
*
* This method could serve as a more eloquent alternative when dealing with interfaces that are using the PHP's
* associative array in the role of a regular array.
*
* The new value is inserted under the integer key that is greater by one compared to the greatest integer key
* already in the map or under `0` if there were no integer keys.
*
* @param mixed $value The value to be inserted.
*
* @return void
*/
public function insertValue($value)
{
CMap::insertValue($this->m_map, $value);
}
示例2: 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;
}
}
示例3: 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;
}
}
示例4: testInsertValue
public function testInsertValue()
{
$map = ["one" => "a", "two" => "b", "three" => "c"];
CMap::insertValue($map, "d");
$this->assertTrue(CMap::equals($map, ["one" => "a", "two" => "b", "three" => "c", 0 => "d"]));
}