src/CodeGeneration/CodeHelper.php
public function replaceTypeHintsInFile(
        string $filePath,
        string $type,
        string $dbalType,
        bool $isNullable
    ): void {
        $contents = \ts\file_get_contents($filePath);

        $search = [
            ': string;',
            '(string $',
            ': string {',
            '@var string',
            '@return string',
            '@param string',

        ];

        $replaceNormal   = [
            ": $type;",
            "($type $",
            ": $type {",
            "@var $type",
            "@return $type",
            "@param $type",
        ];
        $replaceNullable = [
            ": ?$type;",
            "(?$type $",
            ": ?$type {",
            "@var $type|null",
            "@return $type|null",
            "@param $type|null",
        ];
        $replaceRemove   = [
            ';',
            '($',
            ' {',
            '',
            '',
            '',
        ];

        $replace = $replaceNormal;

        if (\in_array($dbalType, MappingHelper::MIXED_TYPES, true)) {
            $replace = $replaceRemove;
        } elseif ($isNullable) {
            $replace = $replaceNullable;
        }

        $contents = \str_replace(
            $search,
            $replace,
            $contents
        );

        \file_put_contents($filePath, $contents);
    }
public function replaceTypeHintsInFile(
        string $filePath,
        string $type,
        string $dbalType,
        bool $isNullable
    ): void {
        $contents = \ts\file_get_contents($filePath);

        $search = [
            ': string;',
            '(string $',
            ': string {',
            '@var string',
            '@return string',
            '@param string',

        ];

        $replaceNormal   = [
            ": $type;",
            "($type $",
            ": $type {",
            "@var $type",
            "@return $type",
            "@param $type",
        ];
        $replaceNullable = [
            ": ?$type;",
            "(?$type $",
            ": ?$type {",
            "@var $type|null",
            "@return $type|null",
            "@param $type|null",
        ];
        $replaceRemove   = [
            ';',
            '($',
            ' {',
            '',
            '',
            '',
        ];

        $replace = $replaceNormal;

        if (\in_array($dbalType, MappingHelper::MIXED_TYPES, true)) {
            $replace = $replaceRemove;
        } elseif ($isNullable) {
            $replace = $replaceNullable;
        }

        $contents = \str_replace(
            $search,
            $replace,
            $contents
        );

        \file_put_contents($filePath, $contents);
    }
public function replaceTypeHintsInFile ( string $ filePath , string $ type , string $ dbalType , bool $ isNullable ) : void { $ contents = \ ts \ file_get_contents ( $ filePath ) ; $ search = [ ': string;' , '(string $' , ': string {' , '@var string' , '@return string' , '@param string' , ] ; $ replaceNormal = [ ": $type;" , "($type $" , ": $type {" , "@var $type" , "@return $type" , "@param $type" , ] ; $ replaceNullable = [ ": ?$type;" , "(?$type $" , ": ?$type {" , "@var $type|null" , "@return $type|null" , "@param $type|null" , ] ; $ replaceRemove = [ ';' , '($' , ' {' , '' , '' , '' , ] ; $ replace = $ replaceNormal ; if ( \ in_array ( $ dbalType , MappingHelper :: MIXED_TYPES , true ) ) { $ replace = $ replaceRemove ; } elseif ( $ isNullable ) { $ replace = $ replaceNullable ; } $ contents = \ str_replace ( $ search , $ replace , $ contents ) ; \ file_put_contents ( $ filePath , $ contents ) ; }
We use the string type hint as our default in templates

This method will then replace those with the updated type

@param string $filePath
@param string $type
@param string $dbalType
@param bool   $isNullable
We use the string type hint as our default in templates