private function PhpDumper::getNextVariableName

Returns the next name to use

Return value

string

2 calls to PhpDumper::getNextVariableName()
PhpDumper::addServiceInlinedDefinitions in drupal/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
Generates the inline definition of a service.
PhpDumper::addServiceLocalTempVariables in drupal/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
Generates Service local temp variables.

File

drupal/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php, line 1264

Class

PhpDumper
PhpDumper dumps a service container as a PHP class.

Namespace

Symfony\Component\DependencyInjection\Dumper

Code

private function getNextVariableName() {
  $firstChars = self::FIRST_CHARS;
  $firstCharsLength = strlen($firstChars);
  $nonFirstChars = self::NON_FIRST_CHARS;
  $nonFirstCharsLength = strlen($nonFirstChars);
  while (true) {
    $name = '';
    $i = $this->variableCount;
    if ('' === $name) {
      $name .= $firstChars[$i % $firstCharsLength];
      $i = intval($i / $firstCharsLength);
    }
    while ($i > 0) {
      $i -= 1;
      $name .= $nonFirstChars[$i % $nonFirstCharsLength];
      $i = intval($i / $nonFirstCharsLength);
    }
    $this->variableCount += 1;

    // check that the name is not reserved
    if (in_array($name, $this->reservedVariables, true)) {
      continue;
    }
    return $name;
  }
}