Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Emulative.php

function Emulative::__construct

Parameters

PhpVersion|null $phpVersion PHP version to emulate. Defaults to newest supported.:

File

vendor/nikic/php-parser/lib/PhpParser/Lexer/Emulative.php, line 36

Class

Emulative

Namespace

PhpParser\Lexer

Code

public function __construct(?PhpVersion $phpVersion = null) {
    $this->targetPhpVersion = $phpVersion ?? PhpVersion::getNewestSupported();
    $this->hostPhpVersion = PhpVersion::getHostVersion();
    $emulators = [
        new MatchTokenEmulator(),
        new NullsafeTokenEmulator(),
        new AttributeEmulator(),
        new EnumTokenEmulator(),
        new ReadonlyTokenEmulator(),
        new ExplicitOctalEmulator(),
        new ReadonlyFunctionTokenEmulator(),
        new PropertyTokenEmulator(),
        new AsymmetricVisibilityTokenEmulator(),
    ];
    // Collect emulators that are relevant for the PHP version we're running
    // and the PHP version we're targeting for emulation.
    foreach ($emulators as $emulator) {
        $emulatorPhpVersion = $emulator->getPhpVersion();
        if ($this->isForwardEmulationNeeded($emulatorPhpVersion)) {
            $this->emulators[] = $emulator;
        }
        elseif ($this->isReverseEmulationNeeded($emulatorPhpVersion)) {
            $this->emulators[] = new ReverseEmulator($emulator);
        }
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal