1<?php declare(strict_types=1);
2
3namespace PhpParser\Lexer\TokenEmulator;
4
5use PhpParser\PhpVersion;
6use PhpParser\Token;
7
8/** @internal */
9abstract class TokenEmulator {
10    abstract public function getPhpVersion(): PhpVersion;
11
12    abstract public function isEmulationNeeded(string $code): bool;
13
14    /**
15     * @param Token[] $tokens Original tokens
16     * @return Token[] Modified Tokens
17     */
18    abstract public function emulate(string $code, array $tokens): array;
19
20    /**
21     * @param Token[] $tokens Original tokens
22     * @return Token[] Modified Tokens
23     */
24    abstract public function reverseEmulate(string $code, array $tokens): array;
25
26    /** @param array{int, string, string}[] $patches */
27    public function preprocessCode(string $code, array &$patches): string {
28        return $code;
29    }
30}
31