Skip to content

Commit

Permalink
update some for bean
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Jan 9, 2020
1 parent c4d6d7b commit 1c674c2
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/bean/src/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,24 +390,25 @@ public function getSession(string $name, string $sid)
*
* When class name will return all of instance for class name
*
* @return object
* @return object|mixed
* @throws InvalidArgumentException
*/
public function get($id)
{
// It is singleton
// It is singleton bean
if (isset($this->singletonPool[$id])) {
return $this->singletonPool[$id];
}

// Prototype by clone
// Prototype bean by clone
if (isset($this->prototypePool[$id])) {
return clone $this->prototypePool[$id];
}

// Alias name
// Has alias name
$aliasId = $this->aliases[$id] ?? '';
if ($aliasId) {
// Fix: $aliasId !== $id deny loop get
if ($aliasId && $aliasId !== $id) {
return $this->get($aliasId);
}

Expand All @@ -432,7 +433,7 @@ public function get($id)
/* @var ObjectDefinition $objectDefinition */
$objectDefinition = $this->objectDefinitions[$id];

// Prototype
// Prototype bean
return $this->safeNewBean($objectDefinition->getName());
}

Expand Down Expand Up @@ -920,8 +921,8 @@ private function newBean(string $beanName, string $id = '')
// Inject properties values
$this->newProperty($reflectObject, $reflectionClass, $propertyInjects, $id);

// Alias
if (!empty($alias)) {
// Alias name
if ($alias && $alias !== $beanName) {
$this->aliases[$alias] = $beanName;
}

Expand Down

0 comments on commit 1c674c2

Please sign in to comment.