本文整理匯總了PHP中Zephir\Variable::getAssociatedClass方法的典型用法代碼示例。如果您正苦於以下問題:PHP Variable::getAssociatedClass方法的具體用法?PHP Variable::getAssociatedClass怎麽用?PHP Variable::getAssociatedClass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zephir\Variable
的用法示例。
在下文中一共展示了Variable::getAssociatedClass方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: get
/**
* Retrieves/Creates a function cache for a method call
*
* @param CompilationContext $compilationContext
* @param ClassMethod $method
* @param Variable $caller
*/
public function get(CompilationContext $compilationContext, $methodName, Variable $caller)
{
$compiler = $compilationContext->compiler;
$numberPoly = 0;
if ($caller->getRealName() == 'this') {
$classDefinition = $compilationContext->classDefinition;
if ($classDefinition->hasMethod($methodName)) {
$numberPoly++;
$method = $classDefinition->getMethod($methodName);
}
} else {
$classTypes = $caller->getClassTypes();
foreach ($classTypes as $classType) {
if ($compiler->isClass($classType) || $compiler->isInterface($classType) || $compiler->isBundledClass($classType) || $compiler->isBundledInterface($classType)) {
if ($compiler->isInterface($classType)) {
continue;
}
if ($compiler->isClass($classType)) {
$classDefinition = $compiler->getClassDefinition($classType);
} else {
$classDefinition = $compiler->getInternalClassDefinition($classType);
}
if (!$classDefinition) {
continue;
}
if ($classDefinition->hasMethod($methodName) && !$classDefinition->isInterface()) {
$numberPoly++;
$method = $classDefinition->getMethod($methodName);
}
}
}
}
if (!$numberPoly) {
// Try to generate a cache based on the fact the variable is not modified within the loop block
if ($compilationContext->insideCycle && !$caller->isTemporal()) {
if (count($compilationContext->cycleBlocks) && $caller->getType() == 'variable') {
$currentBlock = $compilationContext->cycleBlocks[count($compilationContext->cycleBlocks) - 1];
if ($currentBlock->getMutateGatherer(true)->getNumberOfMutations($caller->getName()) == 0) {
$functionCache = $compilationContext->symbolTable->getTempVariableForWrite('zephir_fcall_cache_entry', $compilationContext);
$functionCache->setMustInitNull(true);
$functionCache->setReusable(false);
return '&' . $functionCache->getName() . ', 0';
}
}
}
return 'NULL, 0';
}
if (!$method instanceof \ReflectionMethod) {
if ($method->getClassDefinition()->isExternal()) {
return 'NULL, 0';
}
$completeName = $method->getClassDefinition()->getCompleteName();
if (isset($this->cache[$completeName][$method->getName()])) {
return $this->cache[$completeName][$method->getName()] . ', ' . SlotsCache::getExistingMethodSlot($method);
}
$gatherer = $this->gatherer;
if (is_object($gatherer)) {
$number = $gatherer->getNumberOfMethodCalls($method->getClassDefinition()->getCompleteName(), $method->getName());
} else {
$number = 0;
}
$staticCacheable = !$method->getClassDefinition()->isInterface() && ($compilationContext->currentMethod == $method || $method->getClassDefinition()->isFinal() || $method->isFinal() || $method->isPrivate());
if ($number > 1 || $compilationContext->insideCycle) {
$cacheable = true;
} else {
$cacheable = false;
}
} else {
$staticCacheable = false;
$cacheable = false;
}
// Recursive methods require warm-up
if ($compilationContext->currentMethod == $method) {
if (!$compilationContext->methodWarmUp) {
$compilationContext->methodWarmUp = new MethodCallWarmUp();
}
}
$associatedClass = false;
if ($caller->getName() != 'this_ptr') {
$associatedClass = $caller->getAssociatedClass();
if ($this->isClassCacheable($associatedClass)) {
$staticCacheable = true;
}
}
if ($staticCacheable) {
$cacheSlot = SlotsCache::getMethodSlot($method);
} else {
$cacheSlot = '0';
}
if ($cacheable) {
$functionCacheVar = $compilationContext->symbolTable->getTempVariableForWrite('zephir_fcall_cache_entry', $compilationContext);
$functionCacheVar->setMustInitNull(true);
$functionCacheVar->setReusable(false);
//.........這裏部分代碼省略.........