Iterates over transformers

@return string See RESULT_XXX constants in the interface
504020
private function processTransformers(StreamMetaData $metadata): string
    {
        $overallResult = self::RESULT_ABSTAIN;
        if ($this->transformers instanceof Closure) {
            $delayedTransformers = $this->transformers;
            $this->transformers  = $delayedTransformers();
        }
        foreach ($this->transformers as $transformer) {
            $transformationResult = $transformer->transform($metadata);
            if ($overallResult === self::RESULT_ABSTAIN && $transformationResult === self::RESULT_TRANSFORMED) {
                $overallResult = self::RESULT_TRANSFORMED;
            }
            // transformer reported about termination, next transformers will be skipped
            if ($transformationResult === self::RESULT_ABORTED) {
                $overallResult = self::RESULT_ABORTED;
                break;
            }
        }

        return $overallResult;
    }
154901
protected function parseTitle()
    {
        if (($registeredName = array_search($this->className, $this->defaultContextSettings)) !== false) {
            return $registeredName;
        } elseif (preg_match('/\\\\([^\\\\]*)Helper$/', $this->className, $matches)) {
            return $matches[1];
        }

        return $this->className;
    }
50533
private function tpl(): string
    {
        if (interface_exists($this->type)) {
            return self::$testing
                ? 'Argument %s passed to x must be an array of objects implementing interface %s, %s given for key %s'
                : 'Argument %s passed to %s must be an array of objects implementing interface %s, %s given for key %s, called in %s on line %s';
        }

        if (class_exists($this->type)) {
            return self::$testing
                ? 'Argument %s passed to x must be an array of %s instances, %s given for key %s'
                : 'Argument %s passed to %s must be an array of %s instances, %s given for key %s, called in %s on line %s';
        }

        return self::$testing
            ? 'Argument %s passed to x must be an array of %s values, %s given for key %s'
            : 'Argument %s passed to %s must be an array of %s values, %s given for key %s, called in %s on line %s';
    }
759037
public function getIterator()
    {
        $this->reset();

        foreach ($this->iterator as $key => $value) {
            $this->position++;
            yield $key => $value;
        }
    }
287896
public function ResultVariable()
    {
        $this->match(Lexer::T_IDENTIFIER);

        $resultVariable = $this->lexer->token['value'];

        // Defer ResultVariable validation
        $this->deferredResultVariables[] = [
            'expression'   => $resultVariable,
            'nestingLevel' => $this->nestingLevel,
            'token'        => $this->lexer->token,
        ];

        return $resultVariable;
    }
382901
final public static function values()
    {
        $class = get_called_class();

        if (!isset(self::$values[$class])) {
            self::$values[$class] = (new \ReflectionClass($class))->getConstants();
        }

        return self::$values[$class];
    }
580993
public static final function values() {
		$calledClass = get_called_class();

		// let's check the cache so we don't have to call reflection constantly
		if (empty(self::$cachedValues[$calledClass])) {
			$class = new \ReflectionClass($calledClass);
			self::$cachedValues[$calledClass] = $class->getConstants();
		}

		return self::$cachedValues[$calledClass];
	}
25447
public function getTransformer($value): Transformer
    {
        foreach ($this->getAllTransformers() as $transformer) {
            if ($transformer->canTransform($value)) {
                return $transformer;
            }
        }

        throw Untransformable::noTransformerFound($value);
    }
160919
protected function getTransformerFromClassProperty()
	{
		if (! isset($this->transformer) || ! $this->isTransformer($this->transformer)) {
			throw new \InvalidArgumentException('You cannot transform the entity without providing a valid Transformer. Verify your transformer extends ' . TransformerAbstract::class);
		}


		return (is_a($this->transformer, TransformerAbstract::class, true) && ! is_object($this->transformer)) ?
			new $this->transformer : $this->transformer;
	}
1356426
public function render() {
    $recursive_iter_iter = $this->getRecursiveIterator();

    $render = [];
    foreach ($recursive_iter_iter as $value) {
      $key = $recursive_iter_iter->key();
      $depth = $recursive_iter_iter->getDepth();

      $indent = str_repeat('  ', $depth);

      if (is_array($value)) {
        $render[] = "$indent'$key' => [";
      }
      else {
        // Quote the value if it's not an expression.
        // WTF, '£' is unicode???
        $first_char = mb_substr($value, 0, 1);
        if (!in_array($first_char, ['£', '\\', '['])) {
          $value = '"' . $value . '"';
        }

        $render[] = "$indent'$key' => $value,";

        if (!$recursive_iter_iter->hasNext() && $depth) {
          $indent = $depth ? str_repeat('  ', $recursive_iter_iter->getDepth() - 1) : '';

          $render[] = "$indent],";
        }
      }
    }

    return $render;
  }
148900
private function getOverridesIterator(): \Generator
    {
        try {
            $recursiveIterator = new \RecursiveIteratorIterator(
                new \RecursiveDirectoryIterator(
                    $this->getPathToOverridesDirectory(),
                    \RecursiveDirectoryIterator::SKIP_DOTS
                ),
                \RecursiveIteratorIterator::SELF_FIRST
            );
            foreach ($recursiveIterator as $fileInfo) {
                /**
                 * @var \SplFileInfo $fileInfo
                 */
                if ($fileInfo->isFile()) {
                    if (self::OVERRIDE_EXTENSION !== substr(
                        $fileInfo->getFilename(),
                        -strlen(self::OVERRIDE_EXTENSION)
                    )
                    ) {
                        continue;
                    }
                    yield $fileInfo->getPathname();
                }
            }
        } finally {
            $recursiveIterator = null;
            unset($recursiveIterator);
        }
    }
1064697
private function getConstants(): void
  {
    // If myTargetConfigFilename is not set return immediately.
    if (!isset($this->constantClassName)) return;

    $reflection = new \ReflectionClass($this->constantClassName);

    $constants = $reflection->getConstants();
    foreach ($constants as $name => $value)
    {
      if (!is_numeric($value)) $value = "'".$value."'";

      $this->replacePairs['@'.$name.'@'] = $value;
    }

    $this->io->text(sprintf('Read %d constants for substitution from <fso>%s</fso>',
                            sizeof($constants),
                            OutputFormatter::escape($reflection->getFileName())));
  }
458162
public function getDataSets() : \Iterator
    {
        $unprocessedBytes = '';
        foreach ($this->getContent() as $bytes) {
            $combinedBytes = $unprocessedBytes . $bytes;
            $patternStart = strpos($combinedBytes, '[');

            $dataProcessed = false;
            if ($patternStart !== false) {
                while (($nextPatternStart = strpos($combinedBytes, '[', $patternStart + 1)) !== false) {
                    $dataSet = substr($combinedBytes, $patternStart, $nextPatternStart - $patternStart);
                    yield $this->getDataSetFromString($dataSet);
                    $patternStart = $nextPatternStart;
                    $dataProcessed = true;
                    $unprocessedBytes = substr($combinedBytes, $nextPatternStart);
                }
            }
            if ($dataProcessed === false) {
                $unprocessedBytes = $combinedBytes;
            }
        }
        if (trim($unprocessedBytes) !== '') {
            yield $this->getDataSetFromString($unprocessedBytes);
        }
    }
226079
public function toArray()
	{
		$this->data = $this->transformer->transformBack($this->data);

		return $this->data;
	}
1117551
private static function extractConstants()
    {
        $oClass = new \ReflectionClass(get_called_class());
        $constants = $oClass->getConstants();
        unset(
            $constants['IS_IMPLICIT_ABSTRACT'],
            $constants['IS_EXPLICIT_ABSTRACT'],
            $constants['IS_FINAL']
        );

        return $constants;
    }
1173934
public function getTransformations()
    {
        $result = [];
        foreach ($this as $template) {
            foreach ($template as $transformation) {
                $result[] = $transformation;
            }
        }

        return $result;
    }
260033
private function getConstants()
    {
        if (empty($this->constants)) {
            try {
                $reflection      = new \ReflectionClass($this->getClassName());
                $this->constants = $reflection->getConstants();
            } catch (\ReflectionException $e) {
                $this->constants = [];
            }
        }

        return $this->constants;
    }