<commit_before><?php

declare(strict_types=1);

namespace Roave\BetterReflection\SourceLocator\Type\AutoloadSourceLocator;

use LogicException;
use function stat;
use function stream_wrapper_register;
use function stream_wrapper_restore;
use function stream_wrapper_unregister;
use const STREAM_URL_STAT_QUIET;

/**
 * This class will operate as a stream wrapper, intercepting any access to a file while
 * in operation.
 *
 * @internal DO NOT USE: this is an implementation detail of
 *           the {@see \Roave\BetterReflection\SourceLocator\Type\AutoloadSourceLocator}
 *
 * phpcs:disable SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
 * phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
 * phpcs:disable Squiz.NamingConventions.ValidVariableName.NotCamelCaps
 */
final class FileReadTrapStreamWrapper
{
    private const DEFAULT_STREAM_WRAPPER_PROTOCOLS = [
        'file',
        'phar',
    ];

    /** @var string[]|null */
    private static ?array $registeredStreamWrapperProtocols;

    /**
     * Read this property to determine the last file on which reads were attempted
     *
     * @psalm-readonly
     * @psalm-allow-private-mutation
     */
    public static ?string $autoloadLocatedFile;

    /**
     * @param callable() : ExecutedMethodReturnType $executeMeWithinStreamWrapperOverride
     * @param string[]                              $streamWrapperProtocols
     *<commit_msg>FileReadTrapStreamWrapper::$autoloadLocatedFile has to be initialized before access<commit_after><?php

declare(strict_types=1);

namespace Roave\BetterReflection\SourceLocator\Type\AutoloadSourceLocator;

use LogicException;
use function stat;
use function stream_wrapper_register;
use function stream_wrapper_restore;
use function stream_wrapper_unregister;
use const STREAM_URL_STAT_QUIET;

/**
 * This class will operate as a stream wrapper, intercepting any access to a file while
 * in operation.
 *
 * @internal DO NOT USE: this is an implementation detail of
 *           the {@see \Roave\BetterReflection\SourceLocator\Type\AutoloadSourceLocator}
 *
 * phpcs:disable SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
 * phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
 * phpcs:disable Squiz.NamingConventions.ValidVariableName.NotCamelCaps
 */
final class FileReadTrapStreamWrapper
{
    private const DEFAULT_STREAM_WRAPPER_PROTOCOLS = [
        'file',
        'phar',
    ];

    /** @var string[]|null */
    private static ?array $registeredStreamWrapperProtocols;

    /**
     * Read this property to determine the last file on which reads were attempted
     *
     * @psalm-readonly
     * @psalm-allow-private-mutation
     */
    public static ?string $autoloadLocatedFile = null;

    /**
     * @param callable() : ExecutedMethodReturnType $executeMeWithinStreamWrapperOverride
     * @param string[]                              $streamWrapperProtocols
     *
{'fraction_non_alphanumeric': 0.07845789651673994, 'fraction_numerical': 0.0013527223537368955, 'mean_word_length': 3.9547738693467336, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3874827', 'n_tokens_mistral': 865, 'n_tokens_neox': 841, 'n_words': 201}