@param SplFileInfo $file
@param string      $domain

@return array
182862
public function getFileTranslationMessages(SplFileInfo $file, $domain)
    {
        $locale = explode('.', $file->getFilename())[1];

        if (!in_array($locale, $this->getLocales())) {
            return [];
        }

        $translations = [];

        try {
            $domainMessages = $this->parser->parse(file_get_contents($file->getPath().DIRECTORY_SEPARATOR.$file->getFilename()));
        } catch (ParseException $e) {
            throw new InvalidResourceException(sprintf('Error parsing YAML, invalid file "%s"', $file->getPath()), 0, $e);
        }

        $path = substr(pathinfo($file->getPathname(), PATHINFO_DIRNAME), strlen(getcwd()) + 1);

        $domainMessages = $this->flatten($domainMessages);

        foreach ($domainMessages as $key => $content) {
            $translations[$domain][$key]['messages'][$locale] = $content;
            $translations[$domain][$key]['path'] = $path;
            $translations[$domain][$key]['format'] = $file->getExtension();
        }

        return $translations;
    }
517423
public function getFileInfo(string $destination): SplFileInfo
    {
        $name = Normalizer::normalizeClassname($this->getName());
        $path = rtrim($destination, '/\\').DIRECTORY_SEPARATOR.$name.'.php';

        return new SplFileInfo($path);
    }
249060
protected function parse(\SplFileInfo $file)
    {
        if ($file->getExtension() !== 'php') {
            throw new \InvalidArgumentException(
                'Invalid file type.'
            );
        }
        $info = [];
        $tokens = token_get_all($file->getContents());

        for ($i = 0; $i < count($tokens); ++$i) {
            $token = is_array($tokens[$i])
                ? $tokens[$i][0]
                : $tokens[$i];

            switch ($token) {
                case T_NAMESPACE:
                    $info[$tokens[$i][1]] = $this->getTokenValue(
                        $tokens,
                        [';'],
                        $i
                    );
                    continue;

                case T_USE:
                    $info[$tokens[$i][1]][] = $this->getTokenValue(
                        $tokens,
                        [';', '{', T_AS],
                        $i
                    );
                    continue;

                case T_CLASS:
                    $classname = $this->getTokenValue(
                        $tokens,
                        [T_EXTENDS, T_IMPLEMENTS, '{'],
                        $i
                    );

                    // Resolve the class fully qualified namespace.
                    $info[$tokens[$i][1]] = $this->resolveNamespace(
                        $info,
                        $classname
                    );

                    continue;

                case T_EXTENDS:
                    $classname = $this->getTokenValue(
                        $tokens,
                        [T_IMPLEMENTS, '{'],
                        $i
                    );

                    // Resolve the extends class fully qualified namespace.
                    $info[$tokens[$i][1]] = $this->resolveNamespace(
                        $info,
                        $classname
                    );

                    continue;

                case T_IMPLEMENTS:
                    $interface = $this->getTokenValue(
                        $tokens,
                        ['{'],
                        $i
                    );

                    // Resolve the interface fully qualified namespace.
                    $info[$tokens[$i][1]][] = $this->resolveNamespace(
                        $info,
                        $interface
                    );

                    continue;
            }
        }

        return $info;
    }
1105308
private function parseIniFile(string $file): array
    {
        $ini = parse_ini_file($file, true);

        if (!\is_array($ini)) {
            throw new \RuntimeException("File $file cannot be decoded");
        }

        if (!isset($ini['requires']) || !\is_array($ini['requires'])) {
            return [];
        }

        return $ini['requires'];
    }
1189176
public function getPath(\SplFileInfo $file): ?string
    {
        $realpath = realpath($file->getPathname());

        if (false === $realpath) {
            return null;
        }

        switch ($file->getExtension()) {
            case 'gz':
                $path = 'compress.zlib://' . $realpath;

                break;
            case 'bz2':
                $path = 'compress.bzip2://' . $realpath;

                break;
            case 'tgz':
                $path = 'phar://' . $realpath;

                break;
            default:
                $path = $realpath;

                break;
        }

        return $path;
    }
604618
protected function instanceOf(SplFileInfo $file): bool
    {
        $reflecter = new ReflectionClass($this->getClassName($file));

        if (! $this->isSkip($reflecter)) {
            if ($this->interface === null) {
                return true;
            }
            return (bool) $reflecter->implementsInterface($this->interface);
        }

        unset($reflecter);

        return false;
    }
408751
private function getClassFullNameFromFile(SplFileInfo $file)
    {
        $targets = [
            realpath($this->namespaceDirectory).'/',
            '.php',
        ];

        $replaceValues = ['', ''];

        $className = str_replace($targets, $replaceValues, realpath($file->getPathname()));
        $className = str_replace('/', "\\", $className);

        return $this->namespace."\\".$className;
    }
860550
public function getMimeType(\SplFileInfo $file)
    {
        $fileInfo = finfo_open(FILEINFO_MIME_TYPE);
        $mimeType = finfo_file($fileInfo, $file->getPathname());
        finfo_close($fileInfo);

        return $mimeType;
    }
218289
protected function loadConfigurationFile(array $configuration, SplFileInfo $file, $key = null)
    {
        $pathname = $file->getPathname();
        $contents = $this->loader->load($pathname);
        $contents = mb_strpos($key, 'plugins') === false ? $this->wrapConfigurationContents($file, $contents) : $contents;
        if (!is_array($contents)) {
            return $configuration;
        }

        // Since non-PHP files don't support closures
        // unset them to pass configuration validation
        if ($file->getExtension() !== 'php') {
            unset($contents['config']['logs'], $contents['remote']['permissions']['callback']);
        }

        // Append configuration to the queue
        $configuration[$pathname] = [];
        Arr::set($configuration[$pathname], $key, $contents);

        return $configuration;
    }
991334
public static function proccessFile(\SplFileInfo $file, ContainerBuilder $container, array $configs, bool $resolveClassMap = false): array
    {
        self::$doctrineMapping = $configs['doctrine']['types_mapping'];

        $rootQueryType = $configs['definitions']['schema']['default']['query'] ?? false;
        $rootMutationType = $configs['definitions']['schema']['default']['mutation'] ?? false;

        $container->addResource(new FileResource($file->getRealPath()));

        if (!$resolveClassMap) {
            $container->setParameter(self::CLASSESMAP_CONTAINER_PARAMETER, self::$classesMap);
        }

        try {
            $fileContent = \file_get_contents($file->getRealPath());

            $shortClassName = \substr($file->getFilename(), 0, -4);
            if (\preg_match('#namespace (.+);#', $fileContent, $namespace)) {
                $className = $namespace[1].'\\'.$shortClassName;
                $namespace = $namespace[1];
            } else {
                $className = $shortClassName;
            }

            $reflexionEntity = new \ReflectionClass($className);

            $classAnnotations = self::getAnnotationReader()->getClassAnnotations($reflexionEntity);

            $properties = [];
            foreach ($reflexionEntity->getProperties() as $property) {
                $properties[$property->getName()] = ['property' => $property, 'annotations' => self::getAnnotationReader()->getPropertyAnnotations($property)];
            }

            $methods = [];
            foreach ($reflexionEntity->getMethods() as $method) {
                $methods[$method->getName()] = ['method' => $method, 'annotations' => self::getAnnotationReader()->getMethodAnnotations($method)];
            }

            $gqlTypes = [];

            foreach ($classAnnotations as $classAnnotation) {
                $gqlConfiguration = $gqlType = $gqlName = false;

                switch (true) {
                    case $classAnnotation instanceof GQL\Type:
                        $gqlType = self::GQL_TYPE;
                        $gqlName = $classAnnotation->name ?: $shortClassName;

                        if (!$resolveClassMap) {
                            $isRootQuery = ($rootQueryType && $gqlName === $rootQueryType);
                            $isRootMutation = ($rootMutationType && $gqlName === $rootMutationType);
                            $currentValue = ($isRootQuery || $isRootMutation) ? \sprintf("service('%s')", self::formatNamespaceForExpression($className)) : 'value';

                            $gqlConfiguration = self::getGraphqlType($classAnnotation, $classAnnotations, $properties, $methods, $namespace, $currentValue);
                            $providerFields = self::getGraphqlFieldsFromProviders($namespace, $className, $isRootMutation ? 'Mutation' : 'Query', $gqlName, ($isRootQuery || $isRootMutation));
                            $gqlConfiguration['config']['fields'] = $providerFields + $gqlConfiguration['config']['fields'];

                            if ($classAnnotation instanceof GQL\Relay\Edge) {
                                if (!$reflexionEntity->implementsInterface(EdgeInterface::class)) {
                                    throw new InvalidArgumentException(\sprintf('The annotation @Edge on class "%s" can only be used on class implementing the EdgeInterface.', $className));
                                }
                                if (!isset($gqlConfiguration['config']['builders'])) {
                                    $gqlConfiguration['config']['builders'] = [];
                                }
                                \array_unshift($gqlConfiguration['config']['builders'], ['builder' => 'relay-edge', 'builderConfig' => ['nodeType' => $classAnnotation->node]]);
                            }

                            if ($classAnnotation instanceof GQL\Relay\Connection) {
                                if (!$reflexionEntity->implementsInterface(ConnectionInterface::class)) {
                                    throw new InvalidArgumentException(\sprintf('The annotation @Connection on class "%s" can only be used on class implementing the ConnectionInterface.', $className));
                                }

                                if (!($classAnnotation->edge xor $classAnnotation->node)) {
                                    throw new InvalidArgumentException(\sprintf('The annotation @Connection on class "%s" is invalid. You must define the "edge" OR the "node" attribute.', $className));
                                }

                                $edgeType = $classAnnotation->edge;
                                if (!$edgeType) {
                                    $edgeType = \sprintf('%sEdge', $gqlName);
                                    $gqlTypes[$edgeType] = [
                                        'type' => 'object',
                                        'config' => [
                                            'builders' => [
                                                ['builder' => 'relay-edge', 'builderConfig' => ['nodeType' => $classAnnotation->node]],
                                            ],
                                        ],
                                    ];
                                }
                                if (!isset($gqlConfiguration['config']['builders'])) {
                                    $gqlConfiguration['config']['builders'] = [];
                                }
                                \array_unshift($gqlConfiguration['config']['builders'], ['builder' => 'relay-connection', 'builderConfig' => ['edgeType' => $edgeType]]);
                            }
                        }
                        break;
                    case $classAnnotation instanceof GQL\Input:
                        $gqlType = self::GQL_INPUT;
                        $gqlName = $classAnnotation->name ?: self::suffixName($shortClassName, 'Input');
                        if (!$resolveClassMap) {
                            $gqlConfiguration = self::getGraphqlInput($classAnnotation, $classAnnotations, $properties, $namespace);
                        }
                        break;
                    case $classAnnotation instanceof GQL\Scalar:
                        $gqlType = self::GQL_SCALAR;
                        if (!$resolveClassMap) {
                            $gqlConfiguration = self::getGraphqlScalar($className, $classAnnotation, $classAnnotations);
                        }
                        break;
                    case $classAnnotation instanceof GQL\Enum:
                        $gqlType = self::GQL_ENUM;
                        if (!$resolveClassMap) {
                            $gqlConfiguration = self::getGraphqlEnum($classAnnotation, $classAnnotations, $reflexionEntity->getConstants());
                        }
                        break;
                    case $classAnnotation instanceof GQL\Union:
                        $gqlType = self::GQL_UNION;
                        if (!$resolveClassMap) {
                            $gqlConfiguration = self::getGraphqlUnion($className, $classAnnotation, $classAnnotations, $methods);
                        }
                        break;
                    case $classAnnotation instanceof GQL\TypeInterface:
                        $gqlType = self::GQL_INTERFACE;
                        if (!$resolveClassMap) {
                            $gqlConfiguration = self::getGraphqlInterface($classAnnotation, $classAnnotations, $properties, $methods, $namespace);
                        }
                        break;
                    case $classAnnotation instanceof GQL\Provider:
                        if ($resolveClassMap) {
                            self::$providers[$className] = ['annotation' => $classAnnotation, 'methods' => $methods];
                        }
                        break;
                    default:
                        continue 2;
                }

                if ($gqlType) {
                    if (!$gqlName) {
                        $gqlName = $classAnnotation->name ?: $shortClassName;
                    }

                    if ($resolveClassMap) {
                        if (isset(self::$classesMap[$gqlName])) {
                            throw new InvalidArgumentException(\sprintf('The GraphQL type "%s" has already been registered in class "%s"', $gqlName, self::$classesMap[$gqlName]['class']));
                        }
                        self::$classesMap[$gqlName] = ['type' => $gqlType, 'class' => $className];
                    } else {
                        $gqlTypes = [$gqlName => $gqlConfiguration] + $gqlTypes;
                    }
                }
            }

            return $resolveClassMap ? self::$classesMap : $gqlTypes;
        } catch (\InvalidArgumentException $e) {
            throw new InvalidArgumentException(\sprintf('Failed to parse GraphQL annotations from file "%s".', $file), $e->getCode(), $e);
        }
    }
754511
private function FileGetContents($file) {
    $fileObj = new SplFileObject($file, 'r');
    while (!$fileObj->flock(LOCK_EX)) {
      usleep(1);
    }
    $str = $fileObj->fread($fileObj->getSize());
    $fileObj->flock(LOCK_UN);
    return $str;
  }
1281821
public function filter(\SplFileInfo $file)
    {
        $fh = fopen($file->getPathName(), 'r');
        $content = fread($fh, $this->length);
        fclose($fh);

        return false !== strpos($content, $this->contains);
    }
1070192
private function convertResource(Resource $resource, \SplFileInfo $file)
    {
        return new Resource(
            array_merge(
                $resource->getMetadata(),
                [
                    'file' => $file->getRealpath(),
                ]
            ),
            $resource->getMetadata('type')
        );
    }
674980
private static function getLinks(string $file): array
    {
        $links    = [];
        $contents = (string)file_get_contents($file);
        if (false !== preg_match_all(
            '/\[(.+?)\].*?\((.+?)\)/',
            $contents,
            $matches,
            PREG_SET_ORDER
        )) {
            $links = array_merge($links, $matches);
        }

        return $links;
    }
651436
public function filter(\SplFileInfo $file)
    {
        foreach ($this->filter as $filter) {
            if ($filter->filter($file)) {
                return true;
            }
        }
        return false;
    }
1006014
public function getClassName(SplFileInfo $file): string
    {
        return
            rtrim($this->getRootNamespace(), '\\') .
            str_replace('/', '\\', str_replace($this->getAppPath(), '', $file->getPath())) .
            '\\' .
            $file->getBasename('.' . $file->getExtension())
        ;
    }
540001
public static function getFormat(SplFileInfo $file)
    {
        $name = $file->getRelativePathname();
        $ext  = substr($name, strrpos($name, '.') + 1);

        switch ($ext) {
            case 'md':
                return 'markdown';

            case 'yml':
                return 'yaml';

            default:
                return $ext;
        }
    }