-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcompression.diff
More file actions
502 lines (477 loc) · 17.2 KB
/
Copy pathcompression.diff
File metadata and controls
502 lines (477 loc) · 17.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
--- input/input.php
+++ output/output.php
@@ -248,36 +248,10 @@
* @throws \TypeError
*/
public function bind($abstract, $concrete = null, $shared = false)
- {
$this->dropStaleInstances($abstract);
-
- // If no concrete type was given, we will simply set the concrete type to the
- // abstract type. After that, the concrete type to be registered as shared
- // without being forced to state their classes in both of the parameters.
- if (is_null($concrete)) {
- $concrete = $abstract;
- }
-
- // If the factory is not a Closure, it means it is just a class name which is
- // bound into this container to the abstract type and we will just wrap it
- // up inside its own Closure to give us more convenience when extending.
- if (! $concrete instanceof Closure) {
- if (! is_string($concrete)) {
- throw new TypeError(self::class.'::bind(): Argument #2 ($concrete) must be of type Closure|string|null');
- }
- $concrete = $this->getClosure($abstract, $concrete);
- }
-
- $this->bindings[$abstract] = compact('concrete', 'shared');
-
- // If the abstract type was already resolved in this container we'll fire the
- // rebound listener so that any objects which have already gotten resolved
- // can have their copy of the object updated via the listener callbacks.
- if ($this->resolved($abstract)) {
- $this->rebound($abstract);
+ { … 25 line(s) … ⟦tj:511183738b493d1dff775e8fd564912c⟧ }
}
- }
/**
* Get the Closure to be used when building a type.
@@ -287,18 +261,8 @@
* @return \Closure
*/
protected function getClosure($abstract, $concrete)
- {
- return function ($container, $parameters = []) use ($abstract, $concrete) {
- if ($abstract == $concrete) {
- return $container->build($concrete);
- }
+ { … 11 line(s) … ⟦tj:76c96e5eecfaa2b4a21256a1a63bb068⟧ }
- return $container->resolve(
- $concrete, $parameters, $raiseEvents = false
- );
- };
- }
-
/**
* Determine if the container has a method binding.
*
@@ -441,21 +405,10 @@
* @throws \InvalidArgumentException
*/
public function extend($abstract, Closure $closure)
- {
$abstract = $this->getAlias($abstract);
- if (isset($this->instances[$abstract])) {
- $this->instances[$abstract] = $closure($this->instances[$abstract], $this);
-
- $this->rebound($abstract);
- } else {
- $this->extenders[$abstract][] = $closure;
-
- if ($this->resolved($abstract)) {
- $this->rebound($abstract);
- }
+ { … 10 line(s) … ⟦tj:c886145882a071ab89ebbb7bca915ea9⟧ }
}
- }
/**
* Register an existing instance as shared in the container.
@@ -465,24 +418,10 @@
* @return mixed
*/
public function instance($abstract, $instance)
- {
$this->removeAbstractAlias($abstract);
- $isBound = $this->bound($abstract);
-
- unset($this->aliases[$abstract]);
-
- // We'll check to determine if this type has been bound before, and if it has
- // we will fire the rebound callbacks registered with the container and it
- // can be updated with consuming classes that have gotten resolved here.
- $this->instances[$abstract] = $instance;
-
- if ($isBound) {
- $this->rebound($abstract);
- }
-
+ { … 13 line(s) … ⟦tj:17b9419e374a6c3da86704e29350c048⟧ }
return $instance;
- }
/**
* Remove an alias from the contextual binding alias cache.
@@ -491,19 +430,7 @@
* @return void
*/
protected function removeAbstractAlias($searched)
- {
- if (! isset($this->aliases[$searched])) {
- return;
- }
-
- foreach ($this->abstractAliases as $abstract => $aliases) {
- foreach ($aliases as $index => $alias) {
- if ($alias == $searched) {
- unset($this->abstractAliases[$abstract][$index]);
- }
- }
- }
- }
+ { … 13 line(s) … ⟦tj:eb0cc319f2c7672bae088fdf7021a848⟧ }
/**
* Assign a set of tags to a given binding.
@@ -513,20 +440,8 @@
* @return void
*/
public function tag($abstracts, $tags)
- {
- $tags = is_array($tags) ? $tags : array_slice(func_get_args(), 1);
+ { … 13 line(s) … ⟦tj:e28149ae9e99fd1c60e9e08740f9b6a1⟧ }
- foreach ($tags as $tag) {
- if (! isset($this->tags[$tag])) {
- $this->tags[$tag] = [];
- }
-
- foreach ((array) $abstracts as $abstract) {
- $this->tags[$tag][] = $abstract;
- }
- }
- }
-
/**
* Resolve all of the bindings for a given tag.
*
@@ -534,18 +449,8 @@
* @return iterable
*/
public function tagged($tag)
- {
- if (! isset($this->tags[$tag])) {
- return [];
- }
+ { … 11 line(s) … ⟦tj:a13109783f132e5c564b64f16d690a6e⟧ }
- return new RewindableGenerator(function () use ($tag) {
- foreach ($this->tags[$tag] as $abstract) {
- yield $this->make($abstract);
- }
- }, count($this->tags[$tag]));
- }
-
/**
* Alias a type to a different name.
*
@@ -646,27 +551,10 @@
* @throws \InvalidArgumentException
*/
public function call($callback, array $parameters = [], $defaultMethod = null)
- {
$pushedToBuildStack = false;
- if (($className = $this->getClassForCallable($callback)) && ! in_array(
- $className,
- $this->buildStack,
- true
- )) {
- $this->buildStack[] = $className;
-
- $pushedToBuildStack = true;
- }
-
- $result = BoundMethod::call($this, $callback, $parameters, $defaultMethod);
-
- if ($pushedToBuildStack) {
- array_pop($this->buildStack);
- }
-
+ { … 16 line(s) … ⟦tj:e7ce25dd46dc6572a6189d8e63fe1dca⟧ }
return $result;
- }
/**
* Get the class name for the given callback, if one can be determined.
@@ -753,67 +641,10 @@
* @throws \Illuminate\Contracts\Container\CircularDependencyException
*/
protected function resolve($abstract, $parameters = [], $raiseEvents = true)
- {
$abstract = $this->getAlias($abstract);
- // First we'll fire any event handlers which handle the "before" resolving of
- // specific types. This gives some hooks the chance to add various extends
- // calls to change the resolution of objects that they're interested in.
- if ($raiseEvents) {
- $this->fireBeforeResolvingCallbacks($abstract, $parameters);
- }
-
- $concrete = $this->getContextualConcrete($abstract);
-
- $needsContextualBuild = ! empty($parameters) || ! is_null($concrete);
-
- // If an instance of the type is currently being managed as a singleton we'll
- // just return an existing instance instead of instantiating new instances
- // so the developer can keep using the same objects instance every time.
- if (isset($this->instances[$abstract]) && ! $needsContextualBuild) {
- return $this->instances[$abstract];
- }
-
- $this->with[] = $parameters;
-
- if (is_null($concrete)) {
- $concrete = $this->getConcrete($abstract);
- }
-
- // We're ready to instantiate an instance of the concrete type registered for
- // the binding. This will instantiate the types, as well as resolve any of
- // its "nested" dependencies recursively until all have gotten resolved.
- $object = $this->isBuildable($concrete, $abstract)
- ? $this->build($concrete)
- : $this->make($concrete);
-
- // If we defined any extenders for this type, we'll need to spin through them
- // and apply them to the object being built. This allows for the extension
- // of services, such as changing configuration or decorating the object.
- foreach ($this->getExtenders($abstract) as $extender) {
- $object = $extender($object, $this);
- }
-
- // If the requested type is registered as a singleton we'll want to cache off
- // the instances in "memory" so we can return it later without creating an
- // entirely new instance of an object on each subsequent request for it.
- if ($this->isShared($abstract) && ! $needsContextualBuild) {
- $this->instances[$abstract] = $object;
- }
-
- if ($raiseEvents) {
- $this->fireResolvingCallbacks($abstract, $object);
- }
-
- // Before returning, we will also set the resolved flag to "true" and pop off
- // the parameter overrides for this build. After those two things are done
- // we will be ready to return back the fully constructed class instance.
- $this->resolved[$abstract] = true;
-
- array_pop($this->with);
-
+ { … 56 line(s) … ⟦tj:da99df9b63a396505b62c51d1cfef4e3⟧ }
return $object;
- }
/**
* Get the concrete type for a given abstract.
@@ -822,17 +653,8 @@
* @return mixed
*/
protected function getConcrete($abstract)
- {
- // If we don't have a registered resolver or concrete for the type, we'll just
- // assume each type is a concrete name and will attempt to resolve it as is
- // since the container should be able to resolve concretes automatically.
- if (isset($this->bindings[$abstract])) {
- return $this->bindings[$abstract]['concrete'];
- }
+ { … 10 line(s) … ⟦tj:d4a9e07b0070a0f6923ff0b6f2d5e2b0⟧ }
- return $abstract;
- }
-
/**
* Get the contextual concrete binding for the given abstract.
*
@@ -840,25 +662,11 @@
* @return \Closure|string|array|null
*/
protected function getContextualConcrete($abstract)
- {
if (! is_null($binding = $this->findInContextualBindings($abstract))) {
return $binding;
+ { … 13 line(s) … ⟦tj:a518f4584046d66273d431d998888446⟧ }
}
- // Next we need to see if a contextual binding might be bound under an alias of the
- // given abstract type. So, we will need to check if any aliases exist with this
- // type and then spin through them and check for contextual bindings on these.
- if (empty($this->abstractAliases[$abstract])) {
- return;
- }
-
- foreach ($this->abstractAliases[$abstract] as $alias) {
- if (! is_null($binding = $this->findInContextualBindings($alias))) {
- return $binding;
- }
- }
- }
-
/**
* Find the concrete binding for the given abstract in the contextual binding array.
*
@@ -953,35 +761,10 @@
* @throws \Illuminate\Contracts\Container\BindingResolutionException
*/
protected function resolveDependencies(array $dependencies)
- {
$results = [];
- foreach ($dependencies as $dependency) {
- // If the dependency has an override for this particular build we will use
- // that instead as the value. Otherwise, we will continue with this run
- // of resolutions and let reflection attempt to determine the result.
- if ($this->hasParameterOverride($dependency)) {
- $results[] = $this->getParameterOverride($dependency);
-
- continue;
- }
-
- // If the class is null, it means the dependency is a string or some other
- // primitive type which we can not resolve since it is not a class and
- // we will just bomb out with an error since we have no-where to go.
- $result = is_null(Util::getParameterClassName($dependency))
- ? $this->resolvePrimitive($dependency)
- : $this->resolveClass($dependency);
-
- if ($dependency->isVariadic()) {
- $results = array_merge($results, $result);
- } else {
- $results[] = $result;
- }
- }
-
+ { … 24 line(s) … ⟦tj:c5525036771b15cd1c3968d085c625d1⟧ }
return $results;
- }
/**
* Determine if the given dependency has a parameter override.
@@ -1026,21 +809,10 @@
* @throws \Illuminate\Contracts\Container\BindingResolutionException
*/
protected function resolvePrimitive(ReflectionParameter $parameter)
- {
if (! is_null($concrete = $this->getContextualConcrete('$'.$parameter->getName()))) {
return Util::unwrapIfClosure($concrete, $this);
- }
-
- if ($parameter->isDefaultValueAvailable()) {
- return $parameter->getDefaultValue();
- }
-
- if ($parameter->isVariadic()) {
- return [];
- }
-
+ { … 10 line(s) … ⟦tj:f521cbff41eb48c1e2d533ebeabd707b⟧ }
$this->unresolvablePrimitive($parameter);
- }
/**
* Resolve a class based dependency from the container.
@@ -1085,18 +857,8 @@
* @return mixed
*/
protected function resolveVariadicClass(ReflectionParameter $parameter)
- {
- $className = Util::getParameterClassName($parameter);
+ { … 11 line(s) … ⟦tj:31db2e1ca891247d27374db8f09b369b⟧ }
- $abstract = $this->getAlias($className);
-
- if (! is_array($concrete = $this->getContextualConcrete($abstract))) {
- return $this->make($className);
- }
-
- return array_map(fn ($abstract) => $this->resolve($abstract), $concrete);
- }
-
/**
* Throw an exception that the concrete is not instantiable.
*
@@ -1106,18 +868,8 @@
* @throws \Illuminate\Contracts\Container\BindingResolutionException
*/
protected function notInstantiable($concrete)
- {
- if (! empty($this->buildStack)) {
- $previous = implode(', ', $this->buildStack);
+ { … 11 line(s) … ⟦tj:a0d68e0a8662a209bd02108b39daa0c2⟧ }
- $message = "Target [$concrete] is not instantiable while building [$previous].";
- } else {
- $message = "Target [$concrete] is not instantiable.";
- }
-
- throw new BindingResolutionException($message);
- }
-
/**
* Throw an exception for an unresolvable primitive.
*
@@ -1141,17 +893,7 @@
* @return void
*/
public function beforeResolving($abstract, Closure $callback = null)
- {
- if (is_string($abstract)) {
- $abstract = $this->getAlias($abstract);
- }
-
- if ($abstract instanceof Closure && is_null($callback)) {
- $this->globalBeforeResolvingCallbacks[] = $abstract;
- } else {
- $this->beforeResolvingCallbacks[$abstract][] = $callback;
- }
- }
+ { … 11 line(s) … ⟦tj:071f51b2a396e503cecc4d49a74046fa⟧ }
/**
* Register a new resolving callback.
@@ -1161,18 +903,8 @@
* @return void
*/
public function resolving($abstract, Closure $callback = null)
- {
- if (is_string($abstract)) {
- $abstract = $this->getAlias($abstract);
- }
+ { … 11 line(s) … ⟦tj:b443fe314c5594d6f45da2b85ab5bf6f⟧ }
- if (is_null($callback) && $abstract instanceof Closure) {
- $this->globalResolvingCallbacks[] = $abstract;
- } else {
- $this->resolvingCallbacks[$abstract][] = $callback;
- }
- }
-
/**
* Register a new after resolving callback for all types.
*
@@ -1181,17 +913,7 @@
* @return void
*/
public function afterResolving($abstract, Closure $callback = null)
- {
- if (is_string($abstract)) {
- $abstract = $this->getAlias($abstract);
- }
-
- if ($abstract instanceof Closure && is_null($callback)) {
- $this->globalAfterResolvingCallbacks[] = $abstract;
- } else {
- $this->afterResolvingCallbacks[$abstract][] = $callback;
- }
- }
+ { … 11 line(s) … ⟦tj:e0c8ccd3f7fbca6ba2ab21a8f89138fe⟧ }
/**
* Fire all of the before resolving callbacks.
@@ -1269,18 +991,8 @@
* @return array
*/
protected function getCallbacksForType($abstract, $object, array $callbacksPerType)
- {
- $results = [];
-
- foreach ($callbacksPerType as $type => $callbacks) {
- if ($type === $abstract || $object instanceof $type) {
- $results = array_merge($results, $callbacks);
- }
- }
+ { … 11 line(s) … ⟦tj:8ac963a6b5460ad13ac7eb6f79de6fde⟧ }
- return $results;
- }
-
/**
* Fire an array of callbacks with an object.
*
@@ -1492,3 +1204,6 @@
$this[$key] = $value;
}
}
+[omitted blocks are individually retrievable: call tinyjuice_retrieve with the token inside an omission marker to expand just that block]
+
+[PARTIAL view — full original (41037 bytes): call tinyjuice_retrieve with token "e551ccfb9fceb5f3a970a74a6aaeb70a"]
\ No newline at end of file