本文整理汇总了PHP中Definition::getInjectionMethodParameters方法的典型用法代码示例。如果您正苦于以下问题:PHP Definition::getInjectionMethodParameters方法的具体用法?PHP Definition::getInjectionMethodParameters怎么用?PHP Definition::getInjectionMethodParameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Definition
的用法示例。
在下文中一共展示了Definition::getInjectionMethodParameters方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: resolveMethodParameters
/**
* Resolve parameters referencing other services
*
* @param string $class
* @param string $method
* @param array $callTimeUserParams
* @param bool $isInstantiator
* @param string $alias
* @return array
*/
protected function resolveMethodParameters($class, $method, array $callTimeUserParams, $isInstantiator, $alias)
{
/* @var $isSubclassFunc Closure */
static $isSubclassFunc = null;
static $isSubclassFuncCache = null; // null as unset, array when set
$isSubclassFunc = function($class, $type) use (&$isSubclassFuncCache) {
/* @see https://bugs.php.net/bug.php?id=53727 */
if ($isSubclassFuncCache === null) {
$isSubclassFuncCache = array();
}
if (!array_key_exists($class, $isSubclassFuncCache)) {
$isSubclassFuncCache[$class] = class_parents($class, true) + class_implements($class, true);
}
return (isset($isSubclassFuncCache[$class][$type]));
};
// parameters for this method, in proper order, to be returned
$resolvedParams = array();
// parameter requirements from the definition
$injectionMethodParameters = $this->definition->getInjectionMethodParameters($class, $method);
// computed parameters array
$computedParams = array(
'value' => array(),
'lookup' => array(),
'optional' => array()
);
// retrieve instance configurations for all contexts
$iConfig = array();
$aliases = $this->instanceManager->getAliases();
// for the alias in the dependency tree
if ($alias && $this->instanceManager->hasConfiguration($alias)) {
$iConfig['thisAlias'] = $this->instanceManager->getConfiguration($alias);
}
// for the current class in the dependency tree
if ($this->instanceManager->hasConfiguration($class)) {
$iConfig['thisClass'] = $this->instanceManager->getConfiguration($class);
}
// for the parent class, provided we are deeper than one node
list($requestedClass, $requestedAlias) = ($this->instanceContext[0][0] == 'NEW')
? array($this->instanceContext[0][1], $this->instanceContext[0][2])
: array($this->instanceContext[1][1], $this->instanceContext[1][2]);
if ($requestedClass != $class && $this->instanceManager->hasConfiguration($requestedClass)) {
$iConfig['requestedClass'] = $this->instanceManager->getConfiguration($requestedClass);
if ($requestedAlias) {
$iConfig['requestedAlias'] = $this->instanceManager->getConfiguration($requestedAlias);
}
}
// This is a 2 pass system for resolving parameters
// first pass will find the sources, the second pass will order them and resolve lookups if they exist
// MOST methods will only have a single parameters to resolve, so this should be fast
foreach ($injectionMethodParameters as $name => $info) {
list($type, $isOptional, $isTypeInstantiable) = $info;
// PRIORITY 1 - consult user provided parameters
if (isset($callTimeUserParams[$name])) {
if (is_string($callTimeUserParams[$name])) {
if ($this->instanceManager->hasAlias($callTimeUserParams[$name])) {
// was an alias provided?
$computedParams['lookup'][$name] = array(
$callTimeUserParams[$name],
$this->instanceManager->getClassFromAlias($callTimeUserParams[$name])
);
} elseif ($this->definition->hasClass($callTimeUserParams[$name])) {
// was a known class provided?
$computedParams['lookup'][$name] = array(
$callTimeUserParams[$name],
$callTimeUserParams[$name]
);
} else {
// must be a value
$computedParams['value'][$name] = $callTimeUserParams[$name];
}
} else {
// int, float, null, object, etc
$computedParams['value'][$name] = $callTimeUserParams[$name];
}
continue;
}
// PRIORITY 2 -specific instance configuration (thisAlias) - this alias
//.........这里部分代码省略.........