FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fixed tests and use of resolving('db', function(){}) · JavaDevl/framework@bf5c2fe · GitHub

Commit bf5c2fe

Browse files
Fixed tests and use of resolving('db', function(){})
1 parent 781241a commit bf5c2fe

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

‎src/Illuminate/Container/Container.php‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ public function make($abstract, $parameters = [])
676676
$this->instances[$abstract] = $object;
677677
}
678678

679-
$this->fireResolvingCallbacks($object);
679+
$this->fireResolvingCallbacks($abstract, $object);
680680

681681
$this->resolved[$abstract] = true;
682682

@@ -1029,43 +1029,45 @@ protected function getFunctionHint(Closure $callback)
10291029
/**
10301030
* Fire all of the resolving callbacks.
10311031
*
1032+
* @param string $abstract
10321033
* @param mixed $object
10331034
* @return void
10341035
*/
1035-
protected function fireResolvingCallbacks($object)
1036+
protected function fireResolvingCallbacks($abstract, $object)
10361037
{
10371038
$this->fireCallbackArray($object, $this->globalResolvingCallbacks);
10381039

10391040
$this->fireCallbackArray(
10401041
$object, $this->getCallbacksForType(
1041-
$object, $this->resolvingCallbacks
1042+
$abstract, $object, $this->resolvingCallbacks
10421043
)
10431044
);
10441045

10451046
$this->fireCallbackArray($object, $this->globalAfterResolvingCallbacks);
10461047

10471048
$this->fireCallbackArray(
10481049
$object, $this->getCallbacksForType(
1049-
$object, $this->afterResolvingCallbacks
1050+
$abstract, $object, $this->afterResolvingCallbacks
10501051
)
10511052
);
10521053
}
10531054

10541055
/**
10551056
* Get all callbacks for a given type.
10561057
*
1058+
* @param string $abstract
10571059
* @param object $object
10581060
* @param array $callbacksPerType
10591061
*
10601062
* @return array
10611063
*/
1062-
protected function getCallbacksForType($object, array $callbacksPerType)
1064+
protected function getCallbacksForType($abstract, $object, array $callbacksPerType)
10631065
{
10641066
$results = [];
10651067

10661068
foreach ($callbacksPerType as $type => $callbacks)
10671069
{
1068-
if ($object instanceof $type)
1070+
if ($type === $abstract || $object instanceof $type)
10691071
{
10701072
$results = array_merge($results, $callbacks);
10711073
}

‎tests/Container/ContainerTest.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ public function testResolvingCallbacksAreCalledForSpecificAbstracts()
262262
public function testResolvingCallbacksAreCalled()
263263
{
264264
$container = new Container;
265-
$container->resolvingAny(function($object) { return $object->name = 'taylor'; });
265+
$container->resolving(function($object) { return $object->name = 'taylor'; });
266266
$container->bind('foo', function() { return new StdClass; });
267267
$instance = $container->make('foo');
268268

@@ -273,7 +273,7 @@ public function testResolvingCallbacksAreCalled()
273273
public function testResolvingCallbacksAreCalledForType()
274274
{
275275
$container = new Container;
276-
$container->resolvingType('StdClass', function($object) { return $object->name = 'taylor'; });
276+
$container->resolving('StdClass', function($object) { return $object->name = 'taylor'; });
277277
$container->bind('foo', function() { return new StdClass; });
278278
$instance = $container->make('foo');
279279

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL