This method may transform the supplied source and return a new replacement for it

@param StreamMetaData $metadata
@return string See RESULT_XXX constants in the interface
762830
public function transform(StreamMetaData $metadata): string
    {
        $totalTransformations = 0;
        $parsedSource         = new ReflectionFile($metadata->uri, $metadata->syntaxTree);

        // Check if we have some new aspects that weren't loaded yet
        $unloadedAspects = $this->aspectLoader->getUnloadedAspects();
        if (!empty($unloadedAspects)) {
            $this->loadAndRegisterAspects($unloadedAspects);
        }
        $advisors = $this->container->getByTag('advisor');

        $namespaces = $parsedSource->getFileNamespaces();

        foreach ($namespaces as $namespace) {
            $classes = $namespace->getClasses();
            foreach ($classes as $class) {
                // Skip interfaces and aspects
                if ($class->isInterface() || in_array(Aspect::class, $class->getInterfaceNames(), true)) {
                    continue;
                }
                $wasClassProcessed = $this->processSingleClass(
                    $advisors,
                    $metadata,
                    $class,
                    $parsedSource->isStrictMode()
                );
                $totalTransformations += (integer) $wasClassProcessed;
            }
            $wasFunctionsProcessed = $this->processFunctions($advisors, $metadata, $namespace);
            $totalTransformations += (integer) $wasFunctionsProcessed;
        }

        $result = ($totalTransformations > 0) ? self::RESULT_TRANSFORMED : self::RESULT_ABSTAIN;

        return $result;
    }
1139408
private function formatDynamicMetadata(DynamicMetadataInterface $metadata)
    {
        $info = null;
        switch ($metadata::getName()) {
            case SubjectArea::getName():
                $data = [];
                /* @var SubjectArea $metadata */
                foreach (['x', 'y', 'width', 'height'] as $property) {
                    $data[] = $property.':'.$metadata->$property;
                }
                $info = implode('|', $data);

                break;
        }

        return $info;
    }
785081
private function loadSearchMetadata(EntityMetadata $metadata)
    {
        if (false === $metadata->isSearchEnabled()) {
            return $metadata;
        }
        $clientKey = $metadata->search->getKey();
        $searchFactory = $this->driver->getSearchMetadataFactory($clientKey);

        $searchFactory->handleLoad($metadata);
        $searchFactory->handleValidate($metadata);
        return $metadata;
    }
1229593
private function getFieldsFromMetadata(ClassMetadataInfo $metadata)
    {
        $fields = (array) $metadata->getFieldNames();

        // Remove the primary key field if it's not managed manually
        if ($metadata->isIdGeneratorAuto()) {
            $fields = array_diff($fields, array($metadata->identifier));
        }

        return $fields;
    }
1088859
protected function onMetaReceived($metaData)
    {
        if (is_array($this->params)) {
            foreach ($this->params as $cName => $cMap) {
                if (is_array($cMap)) {
                    $cMeta = Utility::get($cMap, "{meta}");
                    if ($cMeta) {
                        $override = Utility::get($cMeta, "{override}", false);
                        if (isset($cMeta["{override}"])) {
                            unset($cMeta["{override}"]);
                        }
                        if ($override) {
                            $metaData["columns"][$cName] = $cMeta;
                        } else {
                            $metaData["columns"][$cName] = array_merge($metaData["columns"][$cName], $cMeta);
                        }
                    }
                }
            }
        }

        return $metaData;
    }
126554
private function sanitizeMetadatas($metadata = null)
    {
        if (!$metadata) {
            $metadata = $this->em->getMetadataFactory()->getAllMetadata();
        }
        usort($metadata, function ($a, $b) {
            /** @var ClassMetadata $a */
            /** @var ClassMetadata $b */
            return strcmp($a->getName(), $b->getName());
        });
        return $metadata;
    }
474131
private function getFieldsFromEntityMetadata(ClassMetadataInfo $metadata)
    {
        $fields = (array) $metadata->fieldNames;

        // Remove the primary key field if it's not managed manually
        if (!$metadata->isIdentifierNatural()) {
            $fields = array_diff($fields, $metadata->identifier);
        }

        return $fields;
    }
639898
private function getSupportedTypesForMetadata(PhoneMetadata $metadata)
    {
        $types = array();
        foreach (array_keys(PhoneNumberType::values()) as $type) {
            if ($type === PhoneNumberType::FIXED_LINE_OR_MOBILE || $type === PhoneNumberType::UNKNOWN) {
                // Never return FIXED_LINE_OR_MOBILE (it is a convenience type, and represents that a
                // particular number type can't be determined) or UNKNOWN (the non-type).
                continue;
            }

            if (self::descHasData($this->getNumberDescByType($metadata, $type))) {
                $types[] = $type;
            }
        }

        return $types;
    }
469994
private function mapTranslatable(ClassMetadata $metadata)
    {
        // In the case A -> B -> TranslatableInterface, B might not have mapping defined
        // as it is probably defined in A, so in that case, we just return.
        if (!isset($this->configs[$metadata->name])) {
            return;
        }

        $metadata->mapOneToMany([
            'fieldName'     => 'translations',
            'targetEntity'  => $this->configs[$metadata->name],
            'mappedBy'      => 'translatable',
            //'fetch'         => ClassMetadataInfo::FETCH_EXTRA_LAZY,
            'indexBy'       => 'locale',
            'cascade'       => ['persist', 'merge', 'refresh', 'remove', 'detach'],
            'orphanRemoval' => true,
        ]);

        $metadata->addEntityListener('preFlush', self::class, 'onTranslatablePreFlush');
    }
515688
protected function transformByMeta(string $meta, array $data, ...$parameters): array
    {
        $name = Str::singular($meta);
        $types = $this->options[$meta];

        if (empty($types)) {
            return $data;
        }

        foreach ($types as $type => $index) {
            if (is_array($type)) {
                continue;
            }

            $method = $name.Str::studly($type);

            if (method_exists($this, $method)) {
                $data = $this->{$method}($data, ...$parameters);
            }
        }

        return $data;
    }
111191
public function transform(StreamMetaData $metadata): string
    {
        $newExpressionFinder = new NodeFinderVisitor([Node\Expr\New_::class]);

        // TODO: move this logic into walkSyntaxTree(Visitor $nodeVistor) method
        $traverser = new NodeTraverser();
        $traverser->addVisitor($newExpressionFinder);
        $traverser->traverse($metadata->syntaxTree);

        /** @var Node\Expr\New_[] $newExpressions */
        $newExpressions = $newExpressionFinder->getFoundNodes();

        if (empty($newExpressions)) {
            return self::RESULT_ABSTAIN;
        }

        foreach ($newExpressions as $newExpressionNode) {
            $startPosition = $newExpressionNode->getAttribute('startTokenPos');

            $metadata->tokenStream[$startPosition][1] = '\\' . __CLASS__ . '::getInstance()->{';
            if ($metadata->tokenStream[$startPosition+1][0] === T_WHITESPACE) {
                unset($metadata->tokenStream[$startPosition+1]);
            }
            $isExplicitClass  = $newExpressionNode->class instanceof Node\Name;
            $endClassNamePos  = $newExpressionNode->class->getAttribute('endTokenPos');
            $expressionSuffix = $isExplicitClass ? '::class}' : '}';
            $metadata->tokenStream[$endClassNamePos][1] .= $expressionSuffix;
        }

        return self::RESULT_TRANSFORMED;
    }
474656
private function update(PropertyMetadata $propertyMetadata, array $metadata): PropertyMetadata
    {
        $metadataAccessors = [
            'description' => 'get',
            'readable' => 'is',
            'writable' => 'is',
            'writableLink' => 'is',
            'readableLink' => 'is',
            'required' => 'is',
            'identifier' => 'is',
            'iri' => 'get',
            'attributes' => 'get',
        ];

        foreach ($metadataAccessors as $metadataKey => $accessorPrefix) {
            if (null === $metadata[$metadataKey]) {
                continue;
            }

            $propertyMetadata = $propertyMetadata->{'with'.ucfirst($metadataKey)}($metadata[$metadataKey]);
        }

        if ($propertyMetadata->hasSubresource()) {
            return $propertyMetadata;
        }

        return $propertyMetadata->withSubresource($this->createSubresourceMetadata($metadata['subresource'], $propertyMetadata));
    }
208219
protected function onMetaReceived($metaData)
    {
        foreach ($this->params as $cName => $cParam) {
            $metaData["columns"][$cName] = array(
                "type" => "string",
            );
            $this->params[$cName]["formatString"] = Utility::get($cParam, "formatString", "{from} - {to}");
            $this->params[$cName]["decimals"] = Utility::get($cParam, "decimals", 0);
            $this->params[$cName]["thousandSeparator"] = Utility::get($cParam, "thousandSeparator", ",");
            $this->params[$cName]["decimalPoint"] = Utility::get($cParam, "decimalPoint", ".");
            $this->params[$cName]["prefix"] = Utility::get($cParam, "prefix", "");
            $this->params[$cName]["suffix"] = Utility::get($cParam, "suffix", "");
        }
        return $metaData;
    }
766709
protected function onMetaReceived($metaData)
    {
        foreach ($this->params as $cKey=>$cValue) {
            unset($cValue["exp"]);
            $metaData["columns"][$cKey] = $cValue;
        }
        return $metaData;
    }
75372
private function serialize(EntityMetadata $metadata)
    {
        switch ($this->serializer) {
            case self::SERIALIZER_PHP:
                return serialize($metadata);
            case self::SERIALIZER_IGBINARY:
                return igbinary_serialize($metadata);
            default:
                throw new RuntimeException('Unable to handle serialization of the metadata object');
        }
    }
80308
protected function serialize($input, ClassMetadata $metadata)
    {
        $output = [];
        foreach ($metadata->getFieldMappings() as $field) {
            $fieldObj = $this->em->getFieldManager()->get($field['fieldtype'], $field);
            $type = $fieldObj->getStorageType();
            $key = $field['fieldname'];

            // Hack … remove soon
            if (!isset($input[$key])) {
                continue;
            }
            if (Json::test($input[$key])) {
                $input[$key] = Json::parse($input[$key]);
            }
            $output[$key] = $type->convertToDatabaseValue($input[$key], $this->getPlatform());
        }

        return $output;
    }
744362
public function setMetadata(string $metadata): self
    {
        $this->isValidString($metadata, 1000);

        $this->metadata = $metadata;

        return $this;
    }