protected function applyFix(\SplFileInfo $file, Tokens $tokens)
    {
        for ($index = $tokens->count() - 1; 0 < $index; --$index) {
            if (!$tokens[$index]->isGivenKind(T_FUNCTION)) {
                continue;
            }

            $funcName = $tokens->getNextMeaningfulToken($index);
            if ($tokens[$funcName]->equalsAny($this->blacklistFuncNames, false)) {
                continue;
            }

            $returnTypeAnnotation = $this->findReturnAnnotations($tokens, $index);
            if (1 !== \count($returnTypeAnnotation)) {
                continue;
            }
            $returnTypeAnnotation = current($returnTypeAnnotation);
            $types = array_values($returnTypeAnnotation->getTypes());
            $typesCount = \count($types);
            if (1 > $typesCount || 2 < $typesCount) {
                continue;
            }

            $isNullable = false;
            $returnType = current($types);
            if (2 === $typesCount) {
                $null = $types[0];
                $returnType = $types[1];
                if ('null' !== $null) {
                    $null = $types[1];
                    $returnType = $types[0];
                }

                if ('null' !== $null) {
                    continue;
                }

                $isNullable = true;

                if (\PHP_VERSION_ID < 70100) {
                    continue;
                }

                if ('void' === $returnType) {
                    continue;
                }
            }

            if ('static' === $returnType) {
                $returnType = 'self';
            }

            if (isset($this->skippedTypes[$returnType])) {
                continue;
            }

            if (isset($this->versionSpecificTypes[$returnType]) && \PHP_VERSION_ID < $this->versionSpecificTypes[$returnType]) {
                continue;
            }

            if (isset($this->scalarTypes[$returnType]) && false === $this->configuration['scalar_types']) {
                continue;
            }

            if (1 !== Preg::match($this->classRegex, $returnType, $matches)) {
                continue;
            }

            if (isset($matches['array'])) {
                $returnType = 'array';
            }

            $startIndex = $tokens->getNextTokenOfKind($index, ['{', ';']);

            if ($this->hasReturnTypeHint($tokens, $startIndex)) {
                continue;
            }

            $this->fixFunctionDefinition($tokens, $startIndex, $isNullable, $returnType);
        }
    }
protected function applyFix(\SplFileInfo $file, Tokens $tokens)
    {
        for ($index = $tokens->count() - 1; 0 < $index; --$index) {
            if (!$tokens[$index]->isGivenKind(T_FUNCTION)) {
                continue;
            }

            $funcName = $tokens->getNextMeaningfulToken($index);
            if ($tokens[$funcName]->equalsAny($this->blacklistFuncNames, false)) {
                continue;
            }

            $returnTypeAnnotation = $this->findReturnAnnotations($tokens, $index);
            if (1 !== \count($returnTypeAnnotation)) {
                continue;
            }
            $returnTypeAnnotation = current($returnTypeAnnotation);
            $types = array_values($returnTypeAnnotation->getTypes());
            $typesCount = \count($types);
            if (1 > $typesCount || 2 < $typesCount) {
                continue;
            }

            $isNullable = false;
            $returnType = current($types);
            if (2 === $typesCount) {
                $null = $types[0];
                $returnType = $types[1];
                if ('null' !== $null) {
                    $null = $types[1];
                    $returnType = $types[0];
                }

                if ('null' !== $null) {
                    continue;
                }

                $isNullable = true;

                if (\PHP_VERSION_ID < 70100) {
                    continue;
                }

                if ('void' === $returnType) {
                    continue;
                }
            }

            if ('static' === $returnType) {
                $returnType = 'self';
            }

            if (isset($this->skippedTypes[$returnType])) {
                continue;
            }

            if (isset($this->versionSpecificTypes[$returnType]) && \PHP_VERSION_ID < $this->versionSpecificTypes[$returnType]) {
                continue;
            }

            if (isset($this->scalarTypes[$returnType]) && false === $this->configuration['scalar_types']) {
                continue;
            }

            if (1 !== Preg::match($this->classRegex, $returnType, $matches)) {
                continue;
            }

            if (isset($matches['array'])) {
                $returnType = 'array';
            }

            $startIndex = $tokens->getNextTokenOfKind($index, ['{', ';']);

            if ($this->hasReturnTypeHint($tokens, $startIndex)) {
                continue;
            }

            $this->fixFunctionDefinition($tokens, $startIndex, $isNullable, $returnType);
        }
    }
{@inheritdoc}