Inherit docsblocks using `@inheritDoc` tag.
@param ClassDoc $class
@see http://phpdoc.org/docs/latest/guides/inheritance.html
15359
protected function inheritDocs($class)
    {
        // inherit for properties
        foreach ($class->properties as $p) {
            if ($p->hasTag('inheritdoc') && ($inheritTag = $p->getFirstTag('inheritdoc')) !== null) {
                $inheritedProperty = $this->inheritPropertyRecursive($p, $class);
                if (!$inheritedProperty) {
                    $this->errors[] = [
                        'line' => $p->startLine,
                        'file' => $class->sourceFile,
                        'message' => "Method {$p->name} has no parent to inherit from in {$class->name}.",
                    ];
                    continue;
                }

                // set all properties that are empty.
                foreach (['shortDescription', 'type', 'types'] as $property) {
                    if (empty($p->$property) || is_string($p->$property) && trim($p->$property) === '') {
                        $p->$property = $inheritedProperty->$property;
                    }
                }
                // descriptions will be concatenated.
                $p->description = trim($p->description) . "\n\n"
                    . trim($inheritedProperty->description) . "\n\n"
                    . $inheritTag->getContent();

                $p->removeTag('inheritdoc');
            }
        }

        // inherit for methods
        foreach ($class->methods as $m) {
            if ($m->hasTag('inheritdoc') && ($inheritTag = $m->getFirstTag('inheritdoc')) !== null) {
                $inheritedMethod = $this->inheritMethodRecursive($m, $class);
                if (!$inheritedMethod) {
                    $this->errors[] = [
                        'line' => $m->startLine,
                        'file' => $class->sourceFile,
                        'message' => "Method {$m->name} has no parent to inherit from in {$class->name}.",
                    ];
                    continue;
                }
                // set all properties that are empty.
                foreach (['shortDescription', 'return', 'returnType', 'returnTypes', 'exceptions'] as $property) {
                    if (empty($m->$property) || is_string($m->$property) && trim($m->$property) === '') {
                        $m->$property = $inheritedMethod->$property;
                    }
                }
                // descriptions will be concatenated.
                $m->description = trim($m->description) . "\n\n"
                    . trim($inheritedMethod->description) . "\n\n"
                    . $inheritTag->getContent();

                foreach ($m->params as $i => $param) {
                    if (!isset($inheritedMethod->params[$i])) {
                        $this->errors[] = [
                            'line' => $m->startLine,
                            'file' => $class->sourceFile,
                            'message' => "Method param $i does not exist in parent method, @inheritdoc not possible in {$m->name} in {$class->name}.",
                        ];
                        continue;
                    }
                    if (empty($param->description) || trim($param->description) === '') {
                        $param->description = $inheritedMethod->params[$i]->description;
                    }
                    if (empty($param->type) || trim($param->type) === '') {
                        $param->type = $inheritedMethod->params[$i]->type;
                    }
                    if (empty($param->types)) {
                        $param->types = $inheritedMethod->params[$i]->types;
                    }
                }
                $m->removeTag('inheritdoc');
            }
        }
    }
391305
protected function addClasses(array $classes, FileDescriptor $fileDescriptor): void
    {
        foreach ($classes as $class) {
            $classDescriptor = $this->getBuilder()->buildDescriptor($class);
            if ($classDescriptor) {
                $classDescriptor->setLocation($fileDescriptor, $class->getLocation()->getLineNumber());
                if (count($classDescriptor->getTags()->get('package', new Collection())) === 0) {
                    $classDescriptor->getTags()->set(
                        'package',
                        $fileDescriptor->getTags()->get('package', new Collection())
                    );
                }

                $fileDescriptor->getClasses()->set(
                    (string) ($classDescriptor->getFullyQualifiedStructuralElementName()),
                    $classDescriptor
                );
            }
        }
    }
167160
final protected function defineClass(ClassDefinition $class)
    {
        $class->property($this->object)->asObject($this->getObjectType());
        $class->property($this->dataSource)->asObject(IObjectSet::class);

        $this->defineClassStructure($class);
    }
1104236
protected function generateEmbeddedPropertyDocBlock(array $embeddedClass)
    {
        $lines = array();
        $lines[] = $this->spaces . '/**';
        $lines[] = $this->spaces . ' * @var \\' . ltrim($embeddedClass['class'], '\\');

        if ($this->generateAnnotations) {
            $lines[] = $this->spaces . ' *';

            $embedded = array('class="' . $embeddedClass['class'] . '"');

            if (isset($fieldMapping['columnPrefix'])) {
                $embedded[] = 'columnPrefix=' . var_export($embeddedClass['columnPrefix'], true);
            }

            $lines[] = $this->spaces . ' * @' .
                $this->annotationsPrefix . 'Embedded(' . implode(', ', $embedded) . ')';
        }

        $lines[] = $this->spaces . ' */';

        return implode("\n", $lines);
    }
1148620
protected function _addNewDocBlock(File $file, $classIndex, array $annotations) {
		$tokens = $file->getTokens();

		foreach ($annotations as $key => $annotation) {
			if (is_string($annotation)) {
				continue;
			}
			$annotations[$key] = (string)$annotation;
		}

		$helper = new DocBlockHelper(new View());
		$annotationString = $helper->classDescription('', '', $annotations);
		if (PHP_EOL !== "\n") {
			$annotationString = str_replace("\n", PHP_EOL, $annotationString);
		}

		$fixer = $this->_getFixer($file);

		$docBlock = $annotationString . PHP_EOL;
		$fixer->replaceToken($classIndex, $docBlock . $tokens[$classIndex]['content']);

		$contents = $fixer->getContents();

		$this->_counter[static::COUNT_ADDED] = count($annotations);

		return $contents;
	}
480229
protected function define(ClassDefinition $class)
    {
        $class->property($this->name)->asString();

        $class->property($this->file)->asObject(File::class);
    }
331547
protected function normalizeDescription(DocBlock $phpdoc)
    {
        //Get the short + long description from the DocBlock
        $description = $phpdoc->getText();

        //Loop through parents/interfaces, to fill in {@inheritdoc}
        if (strpos($description, '{@inheritdoc}') !== false) {
            $inheritdoc = $this->getInheritDoc($this->method);
            $inheritDescription = $inheritdoc->getText();

            $description = str_replace('{@inheritdoc}', $inheritDescription, $description);
            $phpdoc->setText($description);

            $this->normalizeParams($inheritdoc);
            $this->normalizeReturn($inheritdoc);

            //Add the tags that are inherited
            $inheritTags = $inheritdoc->getTags();
            if ($inheritTags) {
                /** @var Tag $tag */
                foreach ($inheritTags as $tag) {
                    $tag->setDocBlock();
                    $phpdoc->appendTag($tag);
                }
            }
        }
    }
998674
public function postRemove(ClassMetadata $class, $document)
    {
        $class->invokeLifecycleCallbacks(Event::postRemove, $document, [new LifecycleEventArgs($document, $this->dm)]);
        $this->evm->dispatchEvent(Event::postRemove, new LifecycleEventArgs($document, $this->dm));
    }
491546
protected function assertValidDocBlock(File $phpCsFile, int $methodIndex): void
    {
        $docBlockEndIndex = $this->findRelatedDocBlock($phpCsFile, $methodIndex);
        if (!$docBlockEndIndex) {
            // Let another sniff take care of this
            return;
        }

        $tokens = $phpCsFile->getTokens();

        $docBlockStartIndex = $tokens[$docBlockEndIndex]['comment_opener'];

        for ($i = $docBlockStartIndex + 1; $i < $docBlockEndIndex; $i++) {
            if ($tokens[$i]['type'] !== 'T_DOC_COMMENT_TAG') {
                continue;
            }
            if (!in_array($tokens[$i]['content'], ['@param', '@return'], true)) {
                continue;
            }

            $classNameIndex = $i + 2;

            if ($tokens[$classNameIndex]['type'] !== 'T_DOC_COMMENT_STRING') {
                continue;
            }

            $content = $tokens[$classNameIndex]['content'];

            $spacePos = strpos($content, ' ');
            if ($spacePos) {
                $content = substr($content, 0, $spacePos);
            }
            if (substr($content, 0, 8) !== '\Spryker') {
                continue;
            }
            if (substr($content, -9) === 'Interface') {
                continue;
            }
            $pieces = explode('\\', $content);
            $lastPiece = array_pop($pieces);

            if (!$this->isRelevant($lastPiece)) {
                continue;
            }

            $error = 'Bridges should be annotated with interfaces only.';
            $phpCsFile->addError($error, $classNameIndex, 'WrongAnnotation');
        }
    }
1116623
private function persistNew(ClassMetadata $class, $document)
    {
        $this->lifecycleEventManager->prePersist($class, $document);

        $oid    = spl_object_hash($document);
        $upsert = false;
        $index  = $class->getIndex();

        if ($index) {
            $identifier = $class->createIdentifier($document);
            $upsert     = !$class->isEmbeddedDocument && !$identifier->isNull();

            if ($identifier->isNull()) {
                foreach ($identifier->getKeys() as $key) {
                    $property = $key->getPropertyMetadata();

                    if ($property->generator === null) {
                        throw new \InvalidArgumentException(sprintf(
                            '%s.%s uses NONE identifier generation strategy but no identifier was provided when persisting.',
                            get_class($document),
                            $property->name
                        ));
                    } else {
                        $property->generate($this->dm, $document);
                    }
                }

                //rebuild identifier with the generated values
                $identifier = $class->createIdentifier($document);

                $this->documentIdentifiers[$oid] = $identifier;
            }
        } else {
            // this is for embedded documents without identifiers
            $this->documentIdentifiers[$oid] = $oid;
        }

        $this->documentStates[$oid] = self::STATE_MANAGED;

        if ($upsert) {
            $this->scheduleForUpsert($class, $document);
        } else {
            $this->scheduleForInsert($class, $document);
        }
    }
1342358
private function setDocumentation($rClass, $className)
    {
        // Doc comment
        $doc = $rClass->getDocComment();
        $doc = str_replace(" * " . PHP_EOL, "<br>", $doc);

        // boldify the first line only if there is more than one line, otherwise too much bold
        if (substr_count($doc, '<br>') > 1) {
            $firstLineBreak = strpos($doc, "<br>");
            $doc = "<div class='apiFirstLine'>" . substr($doc, 0, $firstLineBreak) . "</div>" . substr($doc, $firstLineBreak + strlen("<br>"));
        }
        $doc = preg_replace("/(@package)[a-z _A-Z]*/", "", $doc);
        $doc = preg_replace("/(@method).*/", "", $doc);
        $doc = str_replace(array("\t", "\n", "/**", "*/", " * ", " *", "  ", "\t*", "  *  @package"), " ", $doc);

        // replace 'foo' and `bar` and "foobar" with code blocks... much magic
        $doc = preg_replace('/`(.*?)`/', '<code>$1</code>', $doc);
        $this->metadataArray[$className]['__documentation'] = $doc;
    }
663586
public function afterCompile(ClassType $class): void
	{
		$method = $class->getMethod('initialize');
		$method->addBody(sprintf('%s::bind($this->getService(?));', ReCaptchaBinding::class), [$this->prefix('provider')]);
		$method->addBody(sprintf('%s::bind($this->getService(?));', InvisibleReCaptchaBinding::class), [$this->prefix('provider')]);
	}
375213
protected void processClass(ClassDoc doc) {
        defaultProcess(doc, true);
        for ( MemberDoc member : doc.fields() ) {
            processMember(member);
        }
        for ( MemberDoc member : doc.constructors() ) {
            processMember(member);
        }
        for ( MemberDoc member : doc.methods() ) {
            processMember(member);
        }
        if ( doc instanceof AnnotationTypeDoc ) {
            for ( MemberDoc member : ((AnnotationTypeDoc)doc).elements() ) {
                processMember(member);
            }
        }
    }
1210713
private function cascadePostPersist(ClassMetadata $class, object $document) : void
    {
        foreach ($class->getEmbeddedFieldsMappings() as $mapping) {
            $value = $class->reflFields[$mapping['fieldName']]->getValue($document);
            if ($value === null) {
                continue;
            }
            $values = $mapping['type'] === ClassMetadata::ONE ? [$value] : $value;
            foreach ($values as $embeddedDocument) {
                $this->postPersist($this->dm->getClassMetadata(get_class($embeddedDocument)), $embeddedDocument);
            }
        }
    }
863249
protected function define(ClassDefinition $class)
    {
        $class->property($this->object)->asObject();

        $class->property($this->data)->nullable()->asObject();
    }
1224484
public void addClassDoc(ClassDoc classdoc) {
        if (classdoc == null) {
            return;
        }
        addClass(classdoc, allClasses);
        if (classdoc.isOrdinaryClass()) {
            addClass(classdoc, ordinaryClasses);
        } else if (classdoc.isException()) {
            addClass(classdoc, exceptions);
        } else if (classdoc.isEnum()) {
            addClass(classdoc, enums);
        } else if (classdoc.isAnnotationType()) {
            addClass(classdoc, annotationTypes);
        } else if (classdoc.isError()) {
            addClass(classdoc, errors);
        } else if (classdoc.isInterface()) {
            addClass(classdoc, interfaces);
        }
    }
343330
private function cascadePreRemove(ClassMetadata $class, $document)
    {
        $hasPreRemoveListeners = $this->evm->hasListeners(Events::preRemove);

        foreach ($class->fieldMappings as $mapping) {
            if (isset($mapping['embedded'])) {
                $value = $class->reflFields[$mapping['fieldName']]->getValue($document);
                if ($value === null) {
                    continue;
                }
                if ($mapping['type'] === 'one') {
                    $value = array($value);
                }
                foreach ($value as $entry) {
                    $entryClass = $this->dm->getClassMetadata(get_class($entry));
                    if ( ! empty($entryClass->lifecycleCallbacks[Events::preRemove])) {
                        $entryClass->invokeLifecycleCallbacks(Events::preRemove, $entry);
                    }
                    if ($hasPreRemoveListeners) {
                        $this->evm->dispatchEvent(Events::preRemove, new LifecycleEventArgs($entry, $this->dm));
                    }
                    $this->cascadePreRemove($entryClass, $entry);
                }
            }
        }
    }