本文整理汇总了PHP中Zephir\Variable::setLocalOnly方法的典型用法代码示例。如果您正苦于以下问题:PHP Variable::setLocalOnly方法的具体用法?PHP Variable::setLocalOnly怎么用?PHP Variable::setLocalOnly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zephir\Variable
的用法示例。
在下文中一共展示了Variable::setLocalOnly方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addVariable
/**
* Adds a variable to the symbol table
*
* @param int $type
* @param string $name
* @param CompilationContext $compilationContext
* @param mixed $defaultValue
* @return Variable
*/
public function addVariable($type, $name, CompilationContext $compilationContext, $defaultValue = null)
{
$variable = new Variable($type, $name, $compilationContext->currentBranch, $defaultValue);
if ($type == 'variable') {
if ($this->localContext) {
/**
* Checks whether a variable can be optimized to be static or not
*/
if ($this->localContext->shouldBeLocal($name)) {
$variable->setLocalOnly(true);
}
}
}
$this->variables[$name] = $variable;
return $variable;
}
示例2: addVariable
/**
* Adds a variable to the symbol table
*
* @param int $type
* @param string $name
* @param CompilationContext $compilationContext
* @param mixed $defaultValue
* @return Variable
*/
public function addVariable($type, $name, CompilationContext $compilationContext, $defaultValue = null)
{
$currentBranch = $compilationContext->branchManager->getCurrentBranch();
$branchId = $currentBranch->getUniqueId();
if ($this->isSuperGlobal($name) || $type == 'zephir_fcall_cache_entry') {
$branchId = 1;
}
$varName = $name;
if ($branchId > 1 && $currentBranch->getType() != Branch::TYPE_ROOT) {
$varName = $name . Variable::BRANCH_MAGIC . $branchId;
}
$variable = new Variable($type, $varName, $compilationContext->currentBranch, $defaultValue);
if ($type == 'variable') {
if ($this->localContext) {
/**
* Checks whether a variable can be optimized to be static or not
*/
if ($this->localContext->shouldBeLocal($name)) {
$variable->setLocalOnly(true);
}
}
}
if (!isset($this->branchVariables[$branchId])) {
$this->branchVariables[$branchId] = array();
}
$this->branchVariables[$branchId][$name] = $variable;
return $variable;
}