ReverseEmulator.php 1013 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php declare(strict_types=1);
  2. namespace PhpParser\Lexer\TokenEmulator;
  3. use PhpParser\PhpVersion;
  4. /**
  5. * Reverses emulation direction of the inner emulator.
  6. */
  7. final class ReverseEmulator extends TokenEmulator {
  8. /** @var TokenEmulator Inner emulator */
  9. private TokenEmulator $emulator;
  10. public function __construct(TokenEmulator $emulator) {
  11. $this->emulator = $emulator;
  12. }
  13. public function getPhpVersion(): PhpVersion {
  14. return $this->emulator->getPhpVersion();
  15. }
  16. public function isEmulationNeeded(string $code): bool {
  17. return $this->emulator->isEmulationNeeded($code);
  18. }
  19. public function emulate(string $code, array $tokens): array {
  20. return $this->emulator->reverseEmulate($code, $tokens);
  21. }
  22. public function reverseEmulate(string $code, array $tokens): array {
  23. return $this->emulator->emulate($code, $tokens);
  24. }
  25. public function preprocessCode(string $code, array &$patches): string {
  26. return $code;
  27. }
  28. }