private function resolveFinder()
    {
        $this->configFinderIsOverridden = false;

        if ($this->isStdIn()) {
            return new \ArrayIterator([new StdinFileInfo()]);
        }

        $modes = [self::PATH_MODE_OVERRIDE, self::PATH_MODE_INTERSECTION];

        if (!\in_array(
            $this->options['path-mode'],
            $modes,
            true
        )) {
            throw new InvalidConfigurationException(sprintf(
                'The path-mode "%s" is not defined, supported are "%s".',
                $this->options['path-mode'],
                implode('", "', $modes)
            ));
        }

        $isIntersectionPathMode = self::PATH_MODE_INTERSECTION === $this->options['path-mode'];

        $paths = array_filter(array_map(
            static function ($path) {
                return realpath($path);
            },
            $this->getPath()
        ));

        if (!\count($paths)) {
            if ($isIntersectionPathMode) {
                return new \ArrayIterator([]);
            }

            return $this->iterableToTraversable($this->getConfig()->getFinder());
        }

        $pathsByType = [
            'file' => [],
            'dir' => [],
        ];

        foreach ($paths as $path) {
            if (is_file($path)) {
                $pathsByType['file'][] = $path;
            } else {
                $pathsByType['dir'][] = $path.\DIRECTORY_SEPARATOR;
            }
        }

        $nestedFinder = null;
        $currentFinder = $this->iterableToTraversable($this->getConfig()->getFinder());

        try {
            $nestedFinder = $currentFinder instanceof \IteratorAggregate ? $currentFinder->getIterator() : $currentFinder;
        } catch (\Exception $e) {
        }

        if ($isIntersectionPathMode) {
            if (null === $nestedFinder) {
                throw new InvalidConfigurationException(
                    'Cannot create intersection with not-fully defined Finder in configuration file.'
                );
            }

            return new \CallbackFilterIterator(
                $nestedFinder,
                static function (\SplFileInfo $current) use ($pathsByType) {
                    $currentRealPath = $current->getRealPath();

                    if (\in_array($currentRealPath, $pathsByType['file'], true)) {
                        return true;
                    }

                    foreach ($pathsByType['dir'] as $path) {
                        if (0 === strpos($currentRealPath, $path)) {
                            return true;
                        }
                    }

                    return false;
                }
            );
        }

        if (null !== $this->getConfigFile() && null !== $nestedFinder) {
            $this->configFinderIsOverridden = true;
        }

        if ($currentFinder instanceof SymfonyFinder && null === $nestedFinder) {
            // finder from configuration Symfony finder and it is not fully defined, we may fulfill it
            return $currentFinder->in($pathsByType['dir'])->append($pathsByType['file']);
        }

        return Finder::create()->in($pathsByType['dir'])->append($pathsByType['file']);
    }
private function resolveFinder()
    {
        $this->configFinderIsOverridden = false;

        if ($this->isStdIn()) {
            return new \ArrayIterator([new StdinFileInfo()]);
        }

        $modes = [self::PATH_MODE_OVERRIDE, self::PATH_MODE_INTERSECTION];

        if (!\in_array(
            $this->options['path-mode'],
            $modes,
            true
        )) {
            throw new InvalidConfigurationException(sprintf(
                'The path-mode "%s" is not defined, supported are "%s".',
                $this->options['path-mode'],
                implode('", "', $modes)
            ));
        }

        $isIntersectionPathMode = self::PATH_MODE_INTERSECTION === $this->options['path-mode'];

        $paths = array_filter(array_map(
            static function ($path) {
                return realpath($path);
            },
            $this->getPath()
        ));

        if (!\count($paths)) {
            if ($isIntersectionPathMode) {
                return new \ArrayIterator([]);
            }

            return $this->iterableToTraversable($this->getConfig()->getFinder());
        }

        $pathsByType = [
            'file' => [],
            'dir' => [],
        ];

        foreach ($paths as $path) {
            if (is_file($path)) {
                $pathsByType['file'][] = $path;
            } else {
                $pathsByType['dir'][] = $path.\DIRECTORY_SEPARATOR;
            }
        }

        $nestedFinder = null;
        $currentFinder = $this->iterableToTraversable($this->getConfig()->getFinder());

        try {
            $nestedFinder = $currentFinder instanceof \IteratorAggregate ? $currentFinder->getIterator() : $currentFinder;
        } catch (\Exception $e) {
        }

        if ($isIntersectionPathMode) {
            if (null === $nestedFinder) {
                throw new InvalidConfigurationException(
                    'Cannot create intersection with not-fully defined Finder in configuration file.'
                );
            }

            return new \CallbackFilterIterator(
                $nestedFinder,
                static function (\SplFileInfo $current) use ($pathsByType) {
                    $currentRealPath = $current->getRealPath();

                    if (\in_array($currentRealPath, $pathsByType['file'], true)) {
                        return true;
                    }

                    foreach ($pathsByType['dir'] as $path) {
                        if (0 === strpos($currentRealPath, $path)) {
                            return true;
                        }
                    }

                    return false;
                }
            );
        }

        if (null !== $this->getConfigFile() && null !== $nestedFinder) {
            $this->configFinderIsOverridden = true;
        }

        if ($currentFinder instanceof SymfonyFinder && null === $nestedFinder) {
            
            return $currentFinder->in($pathsByType['dir'])->append($pathsByType['file']);
        }

        return Finder::create()->in($pathsByType['dir'])->append($pathsByType['file']);
    }
private function resolveFinder ( ) { $ this -> configFinderIsOverridden = false ; if ( $ this -> isStdIn ( ) ) { return new \ ArrayIterator ( [ new StdinFileInfo ( ) ] ) ; } $ modes = [ self :: PATH_MODE_OVERRIDE , self :: PATH_MODE_INTERSECTION ] ; if ( ! \ in_array ( $ this -> options [ 'path-mode' ] , $ modes , true ) ) { throw new InvalidConfigurationException ( sprintf ( 'The path-mode "%s" is not defined, supported are "%s".' , $ this -> options [ 'path-mode' ] , implode ( '", "' , $ modes ) ) ) ; } $ isIntersectionPathMode = self :: PATH_MODE_INTERSECTION === $ this -> options [ 'path-mode' ] ; $ paths = array_filter ( array_map ( static function ( $ path ) { return realpath ( $ path ) ; } , $ this -> getPath ( ) ) ) ; if ( ! \ count ( $ paths ) ) { if ( $ isIntersectionPathMode ) { return new \ ArrayIterator ( [ ] ) ; } return $ this -> iterableToTraversable ( $ this -> getConfig ( ) -> getFinder ( ) ) ; } $ pathsByType = [ 'file' => [ ] , 'dir' => [ ] , ] ; foreach ( $ paths as $ path ) { if ( is_file ( $ path ) ) { $ pathsByType [ 'file' ] [ ] = $ path ; } else { $ pathsByType [ 'dir' ] [ ] = $ path . \ DIRECTORY_SEPARATOR ; } } $ nestedFinder = null ; $ currentFinder = $ this -> iterableToTraversable ( $ this -> getConfig ( ) -> getFinder ( ) ) ; try { $ nestedFinder = $ currentFinder instanceof \ IteratorAggregate ? $ currentFinder -> getIterator ( ) : $ currentFinder ; } catch ( \ Exception $ e ) { } if ( $ isIntersectionPathMode ) { if ( null === $ nestedFinder ) { throw new InvalidConfigurationException ( 'Cannot create intersection with not-fully defined Finder in configuration file.' ) ; } return new \ CallbackFilterIterator ( $ nestedFinder , static function ( \ SplFileInfo $ current ) use ( $ pathsByType ) { $ currentRealPath = $ current -> getRealPath ( ) ; if ( \ in_array ( $ currentRealPath , $ pathsByType [ 'file' ] , true ) ) { return true ; } foreach ( $ pathsByType [ 'dir' ] as $ path ) { if ( 0 === strpos ( $ currentRealPath , $ path ) ) { return true ; } } return false ; } ) ; } if ( null !== $ this -> getConfigFile ( ) && null !== $ nestedFinder ) { $ this -> configFinderIsOverridden = true ; } if ( $ currentFinder instanceof SymfonyFinder && null === $ nestedFinder ) { // finder from configuration Symfony finder and it is not fully defined, we may fulfill it return $ currentFinder -> in ( $ pathsByType [ 'dir' ] ) -> append ( $ pathsByType [ 'file' ] ) ; } return Finder :: create ( ) -> in ( $ pathsByType [ 'dir' ] ) -> append ( $ pathsByType [ 'file' ] ) ; }
Apply path on config instance.
Apply path on config instance .