public function addDirectory($path)
    {
        $finder = new \Symfony\Component\Finder\Finder();

        $patterns = $this->getIgnorePatterns()->getRegularExpression();

        if ($this->follow_symlinks) {
            $finder->followLinks();
        }

        // restrict names to those ending in the given extensions
        $finder
            ->files()
            ->in($path)
            ->name(
                '/\.('.implode('|', $this->allowed_extensions->getArrayCopy()).')$/'
            )
            ->ignoreDotFiles($this->getIgnoreHidden())
            ->filter(
                function(\SplFileInfo $file) use ($patterns) {
                    if (!$patterns) {
                        return true;
                    }

                    // apply ignore list on path instead of file, finder
                    // can't do that by default
                    return !preg_match($patterns, $file->getPathname());
                }
            );

        try {
            /** @var \SplFileInfo $file */
            foreach ($finder as $file) {
                $file = new File($file);
                $path = $file->getRealPath()
                    ? $file->getRealPath()
                    : $file->getPathname();

                $this[$path] = $file;
            }
        } catch(\LogicException $e)
        {
            // if a logic exception is thrown then no folders were included
            // for phpDocumentor this is not an issue since we accept separate
            // files as well
        }
    }