src/CodeGeneration/Generator/Field/FieldGenerator.php
protected function setupClassProperties(
        string $fieldFqn,
        string $fieldType,
        ?string $phpType,
        $defaultValue,
        bool $isUnique
    ): void {
        $this->isArchetype = false;
        $this->fieldType   = \strtolower($fieldType);
        if (true !== \in_array($this->fieldType, MappingHelper::COMMON_TYPES, true)) {
            $this->isArchetype = true;
            $this->fieldType   = $fieldType;
        }
        $this->phpType      = $phpType ?? $this->getPhpTypeForDbalType();
        $this->defaultValue = $this->typeHelper->normaliseValueToType($defaultValue, $this->phpType);

        if (null !== $this->defaultValue) {
            $defaultValueType = $this->typeHelper->getType($this->defaultValue);
            if ($defaultValueType !== $this->phpType) {
                throw new \InvalidArgumentException(
                    'default value ' .
                    $this->defaultValue .
                    ' has the type: ' .
                    $defaultValueType
                    .
                    ' whereas the phpType for this field has been set as ' .
                    $this->phpType .
                    ', these do not match up'
                );
            }
        }
        $this->isNullable = (null === $defaultValue);
        $this->isUnique   = $isUnique;

        if (\substr($fieldFqn, -\strlen(self::FIELD_TRAIT_SUFFIX)) === self::FIELD_TRAIT_SUFFIX) {
            $fieldFqn = \substr($fieldFqn, 0, -\strlen(self::FIELD_TRAIT_SUFFIX));
        }
        $this->fieldFqn = $fieldFqn;

        list($className, $traitNamespace, $traitSubDirectories) = $this->parseFullyQualifiedName(
            $this->fieldFqn,
            $this->srcSubFolderName
        );
        $this->className = $className;
        list(, $interfaceNamespace, $interfaceSubDirectories) = $this->parseFullyQualifiedName(
            \str_replace('Traits', 'Interfaces', $this->fieldFqn),
            $this->srcSubFolderName
        );

        $this->fieldsPath = $this->pathHelper->resolvePath(
            $this->pathToProjectRoot . '/' . \implode('/', $traitSubDirectories)
        );

        $this->fieldsInterfacePath = $this->pathHelper->resolvePath(
            $this->pathToProjectRoot . '/' . \implode('/', $interfaceSubDirectories)
        );

        $this->traitNamespace     = $traitNamespace;
        $this->interfaceNamespace = $interfaceNamespace;
    }
protected function setupClassProperties(
        string $fieldFqn,
        string $fieldType,
        ?string $phpType,
        $defaultValue,
        bool $isUnique
    ): void {
        $this->isArchetype = false;
        $this->fieldType   = \strtolower($fieldType);
        if (true !== \in_array($this->fieldType, MappingHelper::COMMON_TYPES, true)) {
            $this->isArchetype = true;
            $this->fieldType   = $fieldType;
        }
        $this->phpType      = $phpType ?? $this->getPhpTypeForDbalType();
        $this->defaultValue = $this->typeHelper->normaliseValueToType($defaultValue, $this->phpType);

        if (null !== $this->defaultValue) {
            $defaultValueType = $this->typeHelper->getType($this->defaultValue);
            if ($defaultValueType !== $this->phpType) {
                throw new \InvalidArgumentException(
                    'default value ' .
                    $this->defaultValue .
                    ' has the type: ' .
                    $defaultValueType
                    .
                    ' whereas the phpType for this field has been set as ' .
                    $this->phpType .
                    ', these do not match up'
                );
            }
        }
        $this->isNullable = (null === $defaultValue);
        $this->isUnique   = $isUnique;

        if (\substr($fieldFqn, -\strlen(self::FIELD_TRAIT_SUFFIX)) === self::FIELD_TRAIT_SUFFIX) {
            $fieldFqn = \substr($fieldFqn, 0, -\strlen(self::FIELD_TRAIT_SUFFIX));
        }
        $this->fieldFqn = $fieldFqn;

        list($className, $traitNamespace, $traitSubDirectories) = $this->parseFullyQualifiedName(
            $this->fieldFqn,
            $this->srcSubFolderName
        );
        $this->className = $className;
        list(, $interfaceNamespace, $interfaceSubDirectories) = $this->parseFullyQualifiedName(
            \str_replace('Traits', 'Interfaces', $this->fieldFqn),
            $this->srcSubFolderName
        );

        $this->fieldsPath = $this->pathHelper->resolvePath(
            $this->pathToProjectRoot . '/' . \implode('/', $traitSubDirectories)
        );

        $this->fieldsInterfacePath = $this->pathHelper->resolvePath(
            $this->pathToProjectRoot . '/' . \implode('/', $interfaceSubDirectories)
        );

        $this->traitNamespace     = $traitNamespace;
        $this->interfaceNamespace = $interfaceNamespace;
    }
protected function setupClassProperties ( string $ fieldFqn , string $ fieldType , ? string $ phpType , $ defaultValue , bool $ isUnique ) : void { $ this -> isArchetype = false ; $ this -> fieldType = \ strtolower ( $ fieldType ) ; if ( true !== \ in_array ( $ this -> fieldType , MappingHelper :: COMMON_TYPES , true ) ) { $ this -> isArchetype = true ; $ this -> fieldType = $ fieldType ; } $ this -> phpType = $ phpType ?? $ this -> getPhpTypeForDbalType ( ) ; $ this -> defaultValue = $ this -> typeHelper -> normaliseValueToType ( $ defaultValue , $ this -> phpType ) ; if ( null !== $ this -> defaultValue ) { $ defaultValueType = $ this -> typeHelper -> getType ( $ this -> defaultValue ) ; if ( $ defaultValueType !== $ this -> phpType ) { throw new \ InvalidArgumentException ( 'default value ' . $ this -> defaultValue . ' has the type: ' . $ defaultValueType . ' whereas the phpType for this field has been set as ' . $ this -> phpType . ', these do not match up' ) ; } } $ this -> isNullable = ( null === $ defaultValue ) ; $ this -> isUnique = $ isUnique ; if ( \ substr ( $ fieldFqn , - \ strlen ( self :: FIELD_TRAIT_SUFFIX ) ) === self :: FIELD_TRAIT_SUFFIX ) { $ fieldFqn = \ substr ( $ fieldFqn , 0 , - \ strlen ( self :: FIELD_TRAIT_SUFFIX ) ) ; } $ this -> fieldFqn = $ fieldFqn ; list ( $ className , $ traitNamespace , $ traitSubDirectories ) = $ this -> parseFullyQualifiedName ( $ this -> fieldFqn , $ this -> srcSubFolderName ) ; $ this -> className = $ className ; list ( , $ interfaceNamespace , $ interfaceSubDirectories ) = $ this -> parseFullyQualifiedName ( \ str_replace ( 'Traits' , 'Interfaces' , $ this -> fieldFqn ) , $ this -> srcSubFolderName ) ; $ this -> fieldsPath = $ this -> pathHelper -> resolvePath ( $ this -> pathToProjectRoot . '/' . \ implode ( '/' , $ traitSubDirectories ) ) ; $ this -> fieldsInterfacePath = $ this -> pathHelper -> resolvePath ( $ this -> pathToProjectRoot . '/' . \ implode ( '/' , $ interfaceSubDirectories ) ) ; $ this -> traitNamespace = $ traitNamespace ; $ this -> interfaceNamespace = $ interfaceNamespace ; }
Defining the properties for the field to be generated

@param string      $fieldFqn
@param string      $fieldType
@param null|string $phpType
@param mixed       $defaultValue
@param bool        $isUnique

@throws DoctrineStaticMetaException
@SuppressWarnings(PHPMD.StaticAccess)
@SuppressWarnings(PHPMD.BooleanArgumentFlag)
Defining the properties for the field to be generated