public function testContains() { $list = new ResolverList(); $a = $this->makeResolver('a'); $this->assertFalse($list->contains($a)); $this->assertFalse($list->containsId('a')); $list[] = $a; $this->assertTrue($list->contains($a)); $this->assertTrue($list->containsId('a')); }
public function resolve(ResolverList $resolved, ResolverList $unresolved, $performResolution = true) { // already resolved if ($resolved->contains($this)) { return true; } if ($unresolved->contains($this)) { throw new CircularDependencyException($unresolved, $this); } // add to unresolved list whilst we sort out dependencies $unresolved[] = $this; foreach ($this->depends as $dependency) { $dependency->resolve($resolved, $unresolved, $performResolution); } // all dependencies resolved so we can execute our code $unresolved->remove($this); if ($performResolution) { // pre resolve callback if (isset($this->options['PRE_RESOLVE'])) { call_user_func($this->options['PRE_RESOLVE']); } $output = call_user_func($this->resolve); // post resolution callback if (isset($this->options['POST_RESOLVE'])) { call_user_func($this->options['POST_RESOLVE']); } } $resolved[] = $this; return $output; }