Skip to content

Commit ccf365e

Browse files
committed
fix several executions on null returns
1 parent b6c3ba6 commit ccf365e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Container.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ class Container implements \ArrayAccess
2121
*/
2222
protected $objects = array();
2323

24+
/**
25+
* Table of generated objects
26+
*/
27+
protected $calcs = array();
28+
2429
/**
2530
* Table of all closures that should always return fresh objects.
2631
*/
@@ -57,6 +62,7 @@ public function set($id, $value)
5762
throw new Exception("Cannot override locked key {$id}");
5863
}
5964
$this->definitions[$id] = $value;
65+
$this->calcs[$id] = false;
6066
// unset on override
6167
unset($this->objects[$id]);
6268
}
@@ -83,11 +89,12 @@ public function get($id)
8389
return $this->definitions[$id]();
8490
}
8591

86-
if (isset($this->objects[$id])) {
92+
if ($this->calcs[$id]) {
8793
return $this->objects[$id];
8894
}
8995
$obj = $this->definitions[$id]();
9096
$this->objects[$id] = $obj;
97+
$this->calcs[$id] = true;
9198

9299
return $obj;
93100
}

0 commit comments

Comments
 (0)