本文整理匯總了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;
}