@@ -22,7 +22,7 @@ class Container implements ContainerInterface, \ArrayAccess
22
22
/** @var array[] Information about cached container entries */
23
23
protected $ entries = [];
24
24
25
- /** @var EntryInterface[] Cached entries used to resolve values */
25
+ /** @var EntryInterface[] Cached entry instances used to resolve values */
26
26
private $ entryCache ;
27
27
28
28
/** @var array Cached values for container entries */
@@ -81,18 +81,14 @@ public function getCacheFile(callable $encoder = null): string
81
81
*/
82
82
private function loadCacheParameters (): void
83
83
{
84
- foreach ($ this ->entries as $ id => $ data ) {
85
- if (!isset ($ this ->entryCache [$ id ])) {
86
- continue ;
87
- }
88
-
89
- $ parameters = $ this ->entryCache [$ id ]->getCacheParameters ();
84
+ foreach ($ this ->entryCache as $ id => $ entry ) {
85
+ $ parameters = $ entry ->getCacheParameters ();
90
86
91
87
if (!$ this ->isConstantValue ($ parameters )) {
92
88
throw new ContainerException ("Unable to cache entry ' $ id', the cache parameters are not static " );
93
89
}
94
90
95
- $ this ->entries [$ id ] = [\get_class ($ this -> entryCache [ $ id ] ), $ parameters ];
91
+ $ this ->entries [$ id ] = [\get_class ($ entry ), $ parameters ];
96
92
}
97
93
}
98
94
@@ -124,11 +120,10 @@ private function isConstantValue($value): bool
124
120
*/
125
121
public function addEntry (string $ id , EntryInterface $ type ): void
126
122
{
127
- if (isset ($ this -> entries [$ id ])) {
123
+ if (isset ($ this [$ id ])) {
128
124
throw new ContainerException ("Entry for identifier ' $ id' already exists " );
129
125
}
130
126
131
- $ this ->entries [$ id ] = [];
132
127
$ this ->entryCache [$ id ] = $ type ;
133
128
}
134
129
@@ -186,7 +181,7 @@ private function getEntry(string $id): EntryInterface
186
181
*/
187
182
public function has ($ id ): bool
188
183
{
189
- return isset ($ this ->entries [$ id ]);
184
+ return isset ($ this ->entries [$ id ]) || isset ( $ this -> entryCache [ $ id ]) ;
190
185
}
191
186
192
187
/**
0 commit comments