Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
- Removed "_" prefix from getCallParameters()
- whitespace between operators and parens
- added braces to logic blocks
  • Loading branch information
weierophinney committed Jan 2, 2013
1 parent ce5410a commit 394947b
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/Di.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,18 @@ public function instanceManager()
* @param string $method
* @return array
*/

public function _getCallParameters($name, array $params, $method = "__construct")
protected function getCallParameters($name, array $params, $method = "__construct")
{
$im = $this->instanceManager;
$im = $this->instanceManager;
$class = $im->hasAlias($name) ? $im->getClassFromAlias($name) : $name;
if($this->definitions->hasClass($class)) {
if ($this->definitions->hasClass($class)) {
$callParameters = array();
if($this->definitions->hasMethod($class, $method)) {
foreach($this->definitions->getMethodParameters($class, $method) as $param)
if(isset($params[$param[0]]))
if ($this->definitions->hasMethod($class, $method)) {
foreach ($this->definitions->getMethodParameters($class, $method) as $param) {
if (isset($params[$param[0]])) {
$callParameters[$param[0]] = $params[$param[0]];
}
}
}
return $callParameters;
}
Expand All @@ -159,22 +160,21 @@ public function get($name, array $params = array())

$im = $this->instanceManager;

$callParameters = $this->_getCallParameters($name, $params);
if($callParameters) {
$callParameters = $this->getCallParameters($name, $params);
if ($callParameters) {
$fastHash = $im->hasSharedInstanceWithParameters($name, $callParameters, true);
if ($fastHash) {
array_pop($this->instanceContext);

return $im->getSharedInstanceWithParameters(null, array(), $fastHash);
}
} else {
if ($im->hasSharedInstance($name, $callParameters)) {
array_pop($this->instanceContext);

return $im->getSharedInstance($name, $callParameters);
}
}
$config = $im->getConfig($name);

$config = $im->getConfig($name);
$instance = $this->newInstance($name, $params, $config['shared']);
array_pop($this->instanceContext);

Expand Down Expand Up @@ -250,7 +250,7 @@ public function newInstance($name, array $params = array(), $isShared = true)
}

if ($isShared) {
if ($callParameters = $this->_getCallParameters($name, $params)) {
if ($callParameters = $this->getCallParameters($name, $params)) {
$this->instanceManager->addSharedInstanceWithParameters($instance, $name, $callParameters);
} else {
$this->instanceManager->addSharedInstance($instance, $name);
Expand Down

0 comments on commit 394947b

Please sign in to comment.