public function build()
{
$sources = array_reverse($this->definitionSources);
if ($this->useAnnotations) {
$sources[] = new AnnotationReader($this->ignorePhpDocErrors);
} elseif ($this->useAutowiring) {
$sources[] = new Autowiring();
}
$chain = new SourceChain($sources);
if ($this->cache) {
$source = new CachedDefinitionSource($chain, $this->cache);
$chain->setRootDefinitionSource($source);
} else {
$source = $chain;
// Mutable definition source
$source->setMutableDefinitionSource(new DefinitionArray());
}
$proxyFactory = new ProxyFactory($this->writeProxiesToFile, $this->proxyDirectory);
$this->locked = true;
$containerClass = $this->containerClass;
return new $containerClass($source, $proxyFactory, $this->wrapperContainer);
}