@@ -58,8 +58,10 @@ discard block |
||
| 58 | 58 | $constructor = new Internal\Registry($config, [ |
| 59 | 59 | 'state' => new Internal\State(), |
| 60 | 60 | ]); |
| 61 | - foreach ($config as $property => $class) { |
|
| 62 | - if (\property_exists($this, $property)) { |
|
| 61 | + foreach ($config as $property => $class) |
|
| 62 | + { |
|
| 63 | + if (\property_exists($this, $property)) |
|
| 64 | + { |
|
| 63 | 65 | $this->$property = $constructor->get($property, $class); |
| 64 | 66 | } |
| 65 | 67 | } |
@@ -145,26 +147,35 @@ discard block |
||
| 145 | 147 | { |
| 146 | 148 | $binds = &$this->state->bindings; |
| 147 | 149 | $cleanup = $previous = []; |
| 148 | - foreach ($bindings as $alias => $resolver) { |
|
| 149 | - if (isset($binds[$alias])) { |
|
| 150 | + foreach ($bindings as $alias => $resolver) |
|
| 151 | + { |
|
| 152 | + if (isset($binds[$alias])) |
|
| 153 | + { |
|
| 150 | 154 | $previous[$alias] = $binds[$alias]; |
| 151 | - } else { |
|
| 155 | + } |
|
| 156 | + else |
|
| 157 | + { |
|
| 152 | 158 | $cleanup[] = $alias; |
| 153 | 159 | } |
| 154 | 160 | |
| 155 | 161 | $this->binder->bind($alias, $resolver); |
| 156 | 162 | } |
| 157 | 163 | |
| 158 | - try { |
|
| 164 | + try |
|
| 165 | + { |
|
| 159 | 166 | return ContainerScope::getContainer() !== $this |
| 160 | 167 | ? ContainerScope::runScope($this, $scope) |
| 161 | 168 | : $scope($this); |
| 162 | - } finally { |
|
| 163 | - foreach ($previous as $alias => $resolver) { |
|
| 169 | + } |
|
| 170 | + finally |
|
| 171 | + { |
|
| 172 | + foreach ($previous as $alias => $resolver) |
|
| 173 | + { |
|
| 164 | 174 | $binds[$alias] = $resolver; |
| 165 | 175 | } |
| 166 | 176 | |
| 167 | - foreach ($cleanup as $alias) { |
|
| 177 | + foreach ($cleanup as $alias) |
|
| 178 | + { |
|
| 168 | 179 | unset($binds[$alias]); |
| 169 | 180 | } |
| 170 | 181 | } |