@SuppressWarnings(PHPMD.StaticAccess)
@param ClassMetadataBuilder $builder

@see https://stackoverflow.com/a/1076755/543455
495466
public static function metaForIpAddress(ClassMetadataBuilder $builder): void
    {
        $fieldBuilder = new FieldBuilder(
            $builder,
            [
                'fieldName' => IpAddressFieldInterface::PROP_IP_ADDRESS,
                'type'      => Type::STRING,
                'default'   => IpAddressFieldInterface::DEFAULT_IP_ADDRESS,
            ]
        );
        $fieldBuilder
            ->columnName(MappingHelper::getColumnNameForField(IpAddressFieldInterface::PROP_IP_ADDRESS))
            ->nullable(true)
            ->unique(false)
            ->length(45)
            ->build();
    }
986728
public static function metaForTemplateEntities(
        ClassMetadataBuilder $builder
    ): void {
        $manyToManyBuilder = $builder->createManyToMany(
            TemplateEntity::getDoctrineStaticMeta()->getPlural(),
            TemplateEntity::class
        );
        $manyToManyBuilder->mappedBy(self::getDoctrineStaticMeta()->getPlural());
        $fromTableName = Inflector::tableize(TemplateEntity::getDoctrineStaticMeta()->getPlural());
        $toTableName   = Inflector::tableize(self::getDoctrineStaticMeta()->getPlural());
        $manyToManyBuilder->setJoinTable($fromTableName . '_to_' . $toTableName);
        $manyToManyBuilder->addJoinColumn(
            Inflector::tableize(self::getDoctrineStaticMeta()->getSingular() . '_' . static::PROP_ID),
            static::PROP_ID,
            true
        );
        $manyToManyBuilder->addInverseJoinColumn(
            Inflector::tableize(
                TemplateEntity::getDoctrineStaticMeta()->getSingular()
            ) . '_' . TemplateEntity::PROP_ID,
            TemplateEntity::PROP_ID,
            true
        );
        $manyToManyBuilder->fetchExtraLazy();
        $manyToManyBuilder->build();
    }
200115
protected function buildSubmitAction(FormBuilderInterface $builder): void
    {
        $defaults = [
            'form_type' => SubmitType::class,
            'label' => 'sidus.datagrid.submit.label',
            'attr' => [
                'class' => 'btn-primary',
            ],
        ];
        $options = array_merge($defaults, $this->getSubmitButton());
        $type = $options['form_type'];
        unset($options['form_type']);
        $builder->add('filterSubmitButton', $type, $options);
    }
1097292
public function prepare($builder = null)
    {
        // NOTE: because the same ActiveQuery may be used to build different SQL statements
        // (e.g. by ActiveDataProvider, one for count query, the other for row data query,
        // it is important to make sure the same ActiveQuery can be used to build SQL statements
        // multiple times.
        if (!empty($this->joinWith)) {
            $this->buildJoinWith();
            $this->joinWith = null;
        }

        return $this;
    }
1268616
public static function metaForTemplateEntity(
        ClassMetadataBuilder $builder
    ): void {
        $builder->addOwningOneToOne(
            TemplateEntity::getDoctrineStaticMeta()->getSingular(),
            TemplateEntity::class,
            self::getDoctrineStaticMeta()->getSingular()
        );
    }
957159
protected function convertToMappingArray(ClassMetadataBuilder $builder)
    {
        $metadata = $builder->getClassMetadata();

        return $metadata->getFieldMapping($this->name);
    }
401175
public static function setSimpleDecimalFields(
        array $fields,
        ClassMetadataBuilder $builder,
        $default = null
    ): void {
        if (null !== $default && !\is_string($default)) {
            throw new \InvalidArgumentException(
                'Invalid default value ' . $default
                . ' with type ' . self::getType($default)
            );
        }
        if (null !== $default && !is_numeric($default)) {
            throw new \InvalidArgumentException(
                'Invalid default value ' . $default
                . ', even though it is a string, it must be numeric '
            );
        }
        foreach ($fields as $field) {
            $fieldBuilder = new FieldBuilder(
                $builder,
                [
                    'fieldName' => $field,
                    'type'      => Type::DECIMAL,
                    'default'   => (string)(float)$default,
                ]
            );
            $fieldBuilder
                ->columnName(self::getColumnNameForField($field))
                ->nullable(null === $default)
                ->precision(Database::MAX_DECIMAL_PRECISION)
                ->scale(Database::MAX_DECIMAL_SCALE)
                ->build();
        }
    }
102048
protected function getAssociationBuilder(ClassMetadataBuilder $builder, array $source)
    {
        return new $this->relations[$source['type']](
            $builder,
            $this->namingStrategy,
            $this->name,
            $source['targetEntity']
        );
    }
848058
protected function addWithDecryptKey(Builder $builder)
    {
        $builder->macro('withDecryptKey', function (Builder $builder, $decryptKey) {
            $model = $builder->getModel();
            $encryptedFields = $model::getEncryptedFields();
            if (!empty($encryptedFields)) {
                $builder->setEncryptionModel($model);

                /** @var DatabaseEncryptionServiceInterface $encryptionService */
                $encryptionService = $model::getEncryptionService();
                foreach ($encryptedFields as $encryptedField) {
                    $decryptStmt = $encryptionService->getDecryptExpression($encryptedField, $decryptKey);
                    $builder->addEncryptionSelect([
                        'column' => $encryptedField,
                        'select' => DB::raw("$decryptStmt as $encryptedField")
                    ]);
                }
            }
            return $builder;
        });
    }
33604
public function apply(Builder $builder, Model $model)
    {
        $column = $model->getQualifiedActiveColumn();

        $builder->where($column, true);

        $this->addWithInactive($builder);
    }
353933
protected function instantiationOptions(SchemaBuilder $builder)
    {
        if ($this->getInstantiator() != DocumentInstantiator::class) {
            //Unable to define options for non default inheritance based instantiator
            return null;
        }

        //Let's define a way how to separate one model from another based on given fields
        $helper = new InheritanceHelper($this, $builder->getSchemas());

        return $helper->makeDefinition();
    }
626470
protected function addUndoAccept(Builder $builder): void
    {
        $builder->macro('undoAccept', function (Builder $builder) {
            return $builder->update(['accepted_at' => null]);
        });
    }
750677
private function beforeGet(Builder $builder): void {
    $this->remapBuilderColumns($builder);
    $this->remapWheres($builder);
  }
1184390
public static function metaForTemplateEntity(
        ClassMetadataBuilder $builder
    ): void {
        $manyToOne = $builder->createManyToOne(
            TemplateEntity::getDoctrineStaticMeta()->getSingular(),
            TemplateEntity::class
        );
        $manyToOne
            ->inversedBy(self::getDoctrineStaticMeta()->getPlural())
            ->addJoinColumn(
                Inflector::tableize(
                    TemplateEntity::getDoctrineStaticMeta()->getSingular()
                ) . '_' . IdFieldInterface::PROP_ID,
                IdFieldInterface::PROP_ID,
                true
            )->build();

    }
676242
protected function createAssociation(ClassMetadataBuilder $builder, $relation, $entity)
    {
        return $this->builder->createManyToMany($relation, $entity);
    }
1052264
public function apply(Builder $builder)
    {
        $this->builder = $builder;

        foreach ($this->filters() as $name => $value) {
            if (! method_exists($this, $name)) {
                continue;
            }

            if (is_array($value) or trim($value)) {
                $this->$name($value);
            } else {
                $this->$name();
            }
        }

        return $this->builder;
    }
357030
public function addBuilder(ManagerBuilder $builder)
    {
        $builderName = (string) $builder->getName();
        if ($builderName === '') {
            throw new \RuntimeException('Only named manager builders allowed');
        }

        if (array_key_exists($builderName, $this->builders)) {
            throw new \RuntimeException(sprintf('"%s" manager builder is already registered', $builderName));
        }

        $this->builders[$builderName] = $builder;
    }