Creates a new FileViewFinder, copying the current contents

@param FileViewFinder $finder
@param array          $paths

@return FileViewFinder
431366
protected function createViewFinder(FileViewFinder $finder, array $paths = [])
    {
        $new = new FileViewFinder(app('files'), $paths, $finder->getExtensions());

        foreach ($finder->getHints() as $namespace => $hints) {
            $new->addNamespace($namespace, $hints);
        }

        return $new;
    }
1294885
public function createMap(...$paths)
    {
        $classes = [];

        $this->finder->files()
            ->ignoreUnreadableDirs()
            ->in($paths);

        foreach($this->excludePathPatterns as $exclude)
        {
            $this->finder->notPath($exclude);
        }

        foreach($this->inPathPatterns as $inPath)
        {
            $this->finder->path($inPath);
        }

        foreach($this->names as $name)
        {
            $this->finder->name($name);
        }

        /** @var SplFileInfo $file */
        foreach ($this->finder as $file) {
            $content = file_get_contents($file->getPathname());

            preg_match('^\s*class ([\S]*)\s*(extends|implements|{)^', $content, $match, PREG_OFFSET_CAPTURE);

            if (isset($match[1])) {
                $className = '\\'. trim($match[1][0]);
                $offset = $match[1][1];
            } else {
                continue;
            }

            preg_match('|\s*namespace\s*([\S]*)\s*;|', substr($content, 0 , $offset), $match);

            if (isset($match[1]) && trim($match[1]) !== '') {
                $className = '\\' . trim($match[1]) . $className;
            }

            if ($className !== '\\') {
                $classes[$file->getPathname()] = $className;
            }
        }

        return $classes;
    }
200321
public function getFinder(array $paths)
    {
        $finder = (empty($this->finder)) ? Finder::create() : $this->finder;

        return $finder->files()->in($paths)->name('*.'.$this->laravel['twig.extension']);
    }
120188
public function analysePaths(Finder $finder)
    {
        $classes = [];
        foreach ($finder as $file) {
            $this->analyse($file, $classes);
        }

        return $classes;
    }
723635
public function getFinder()
    {
        if (!$this->finder) {
            $this->finder = new FileViewFinder($this->getFilesystem(), $this->dumpPaths());
        }

        return $this->finder;
    }
165272
public function addFinder(FormatFinder ...$finder) {
        foreach ($finder as $f) {
            if (false === array_search($f, $this->finders, true)) {
                $this->finders[] = $f;
            }
        }
    }
772428
public function findFiles()
    {
        $search = (new Finder())->files();
        // Add in paths
        foreach ($this->paths as $path) {
            if (is_readable($path)) {
                $search->in($path);
            }
        }
        // Add in names
        foreach ($this->files as $pattern) {
            $search->name($pattern);
        }

        $array = array();
        foreach ($search as $f) {
            $array[] = $f->getRealPath();
        }

        return $array;

    }
826641
private function readNode(Finder $finder)
    {
        $uri = str_replace($this->contentPath, '', $finder->getPath());
        $uri = !$uri ? '/' : $uri;

        if(false !== $finder->getPropertiesPath())
        {
            $properties = PropertiesParser::parse($finder);
            $node = new Node($properties['name'], $uri);

            //Set properties
            foreach($properties['properties'] as $key => $value)
            {
                $node->setProperty($key, $value);
            }

            //Read properties from parent nodes
            $parentDir = realpath(dirname($finder->getPropertiesPath()));

            while(strcmp($this->contentPath, $parentDir) <= 0)
            {
                $parentFinder = new Finder($parentDir);
                if(false !== $parentFinder->getPropertiesPath())
                {
                    $properties = PropertiesParser::parse($parentFinder);
                    foreach($properties['properties'] as $key => $value)
                    {
                        if((substr($key, 0, 5) == 'tree_') && !$node->hasProperty($key))
                        {
                            $node->setProperty($key, $value);
                        }
                    }
                }
                else
                {
                    throw new SitemapException(sprintf('Unable to read properties [%s].', $parentFinder->getPath()));
                }
                $parentDir = realpath($parentDir . '/..');
            }

            return $node;
        }

        throw new SitemapException(sprintf('Unable to read node for request [%s].', $uri));
    }
812908
public function createTraversable(array $paths, array $checkedExtensions, array $excludedPaths)
    {
        $directlyPassedFiles = array();
        $excludedPaths = $this->excludedPathCanonicalizer->canonicalize($paths, $excludedPaths);
        foreach ($paths as $path) {
            if (is_dir($path) && !$checkedExtensions) {
                throw new \DomainException('At least 1 extension must be specified to check a directory');
            } elseif (is_file($path)) {
                $directlyPassedFiles[] = realpath($path);
            }
        }

        $fileDirectoryIterator = new FileDirectoryListRecursiveIterator($paths);
        $extensionFilteringIterator = new ExtensionFilteringRecursiveIterator(
            $fileDirectoryIterator,
            $checkedExtensions,
            $directlyPassedFiles
        );
        $excludedPathFilteringIterator = new ExcludedPathFilteringRecursiveIterator(
            $extensionFilteringIterator,
            $excludedPaths
        );

        return new \RecursiveIteratorIterator(
            $excludedPathFilteringIterator,
            \RecursiveIteratorIterator::LEAVES_ONLY
        );
    }
569031
public function addDirectory($path)
    {
        $finder = new Finder();
        $finder->files()
            ->ignoreVCS(true)
            ->name('*.php')
            ->in($path);

        foreach ($finder as $file) {
            $this->addFile($file);
        }

        return $this;
    }
827362
public function detect(Finder $finder, array $rules): array
    {
        $nodes = $this->parseNodes($finder);
        $violations = array();

        $this->eventDispatcher->dispatch(Events::PRE_RULES_CHECKED, new PreRulesCheckedEvent($rules));

        foreach ($rules as $rule) {
            $ruleViolations = array();

            foreach ($nodes as $node) {
                $violation = $this->ruleChecker->check($rule, $node);
                if (null !== $violation) {
                    $ruleViolations[] = $violation;
                }

                $this->eventDispatcher->dispatch(
                    Events::NODE_CHECKED,
                    new NodeChecked($node, $rule, $violation)
                );
            }

            $this->eventDispatcher->dispatch(
                Events::RULE_CHECKED,
                new RuleCheckedEvent($rule, $ruleViolations)
            );

            $violations = array_merge($violations, $ruleViolations);
        }

        $this->eventDispatcher->dispatch(Events::POST_RULES_CHECKED, new PostRulesCheckedEvent($violations));

        return $violations;
    }
1220322
public function getMigrationFiles($paths = [], $recursive = true)
    {
        if ($recursive) {
            $paths = $this->getRecursiveFolders($paths);
        }

        $files = parent::getMigrationFiles($paths);

        return $files;
    }
553614
public function load(array $paths)
    {
        $finder = new Finder();
        $finder->in($paths);
        $finder->name('*Fixture.php');

        foreach ($finder as $file) {
            $declaredClasses = get_declared_classes();
            require_once $file;
            $declaredClassesDiff = array_diff(get_declared_classes(), $declaredClasses);
            $fixtureClass = array_pop($declaredClassesDiff);

            if (!$fixtureClass) {
                throw new \InvalidArgumentException(sprintf(
                    'Could not determine class from included file "%s". Class detection will only work once per request.',
                    $file
                ));
            }

            $refl = new \ReflectionClass($fixtureClass);

            if ($refl->isAbstract()) {
                continue;
            }

            if (false === $refl->isSubclassOf(DocumentFixtureInterface::class)) {
                continue;
            }

            $fixture = new $fixtureClass();

            if ($fixture instanceof ContainerAwareInterface) {
                $fixture->setContainer($this->container);
            }

            $fixtures[] = $fixture;
        }

        usort($fixtures, function(DocumentFixtureInterface $fixture1, DocumentFixtureInterface $fixture2) {
            return $fixture1->getOrder() > $fixture2->getOrder();
        });

        return $fixtures;
    }
1333381
public static function start($path, Finder $finder = null, Filesystem $files = null)
	{
		$finder = $finder ?: new Finder;

		// We will use the finder to locate all "autoload.php" files in the workbench
		// directory, then we will include them each so that they are able to load
		// the appropriate classes and file used by the given workbench package.
		$files = $files ?: new Filesystem;

		$autoloads = $finder->in($path)->files()->name('autoload.php')->depth('<= 3')->followLinks();

		foreach ($autoloads as $file)
		{
			$files->requireOnce($file->getRealPath());
		}
	}
1312631
protected function registerViewFinder()
    {
        $container = $this->container;

        $this->container->bindShared('view.finder', function ($app) use ($container) {
            return new FileViewFinder($app['files'], $container['view.paths']);
        });
    }
1026542
protected function getYamlFilesetFinder() {
    $finder = new Finder();
    $finder
      ->files()
      ->name("*.yml")
      ->name("*.yaml")
      ->notPath('bower_components')
      ->notPath('node_modules')
      ->notPath('vendor');

    return $finder;
  }
1332335
public function registerViewFinder()
    {
        $this->app->singleton('view.finder', function ($app) {
            $paths = $app->make('config')->get('view.paths');
            return new FileViewFinder($app->make('files'), $paths);
        });
    }