src/Common/Model/Base.php
protected function describeFieldsGuessType(&$oField, $sType)
    {
        preg_match('/^(.*?)(\((.+?)\)(.*))?$/', $sType, $aMatches);

        $sType       = ArrayHelper::getFromArray(1, $aMatches, 'text');
        $sTypeConfig = trim(ArrayHelper::getFromArray(3, $aMatches));
        $iLength     = is_numeric($sTypeConfig) ? (int) $sTypeConfig : null;

        switch ($sType) {

            /**
             * Numeric
             */
            case 'int':
                $oField->type = 'number';
                break;

            /**
             * Boolean
             * Nails convention uses tinyint(1) as a boolean; if not (1) then treat as integer
             */
            case 'tinyint':
            case 'bool':
            case 'boolean':
                $oField->type = $iLength == 1 ? 'boolean' : 'number';
                break;

            /**
             * String
             */
            case 'varchar':
                $oField->type       = 'text';
                $oField->max_length = $iLength ?: null;
                break;
            case 'tinytext':
            case 'text':
            case 'mediumtext':
            case 'longtext':
                $oField->type = 'textarea';
                break;

            /**
             * Date and time
             */
            case 'date':
                $oField->type = 'date';
                break;
            case 'datetime':
                $oField->type = 'datetime';
                break;
            case 'time':
                $oField->type = 'time';
                break;

            /**
             * ENUM
             */
            case 'enum':
                $oField->type    = 'dropdown';
                $oField->class   = 'select2';
                $aOptions        = explode("','", substr($sTypeConfig, 1, -1));
                $aLabels         = array_map('strtolower', $aOptions);
                $aLabels         = array_map([$this, 'describeFieldsPrepareLabel'], $aLabels);
                $oField->options = array_combine($aOptions, $aLabels);
                break;

            /**
             * Default to basic string
             */
            default:
                $oField->type       = 'text';
                $oField->max_length = $iLength ?: null;
                break;
        }
    }
protected function describeFieldsGuessType(&$oField, $sType)
    {
        preg_match('/^(.*?)(\((.+?)\)(.*))?$/', $sType, $aMatches);

        $sType       = ArrayHelper::getFromArray(1, $aMatches, 'text');
        $sTypeConfig = trim(ArrayHelper::getFromArray(3, $aMatches));
        $iLength     = is_numeric($sTypeConfig) ? (int) $sTypeConfig : null;

        switch ($sType) {

            /**
             * Numeric
             */
            case 'int':
                $oField->type = 'number';
                break;

            /**
             * Boolean
             * Nails convention uses tinyint(1) as a boolean; if not (1) then treat as integer
             */
            case 'tinyint':
            case 'bool':
            case 'boolean':
                $oField->type = $iLength == 1 ? 'boolean' : 'number';
                break;

            /**
             * String
             */
            case 'varchar':
                $oField->type       = 'text';
                $oField->max_length = $iLength ?: null;
                break;
            case 'tinytext':
            case 'text':
            case 'mediumtext':
            case 'longtext':
                $oField->type = 'textarea';
                break;

            /**
             * Date and time
             */
            case 'date':
                $oField->type = 'date';
                break;
            case 'datetime':
                $oField->type = 'datetime';
                break;
            case 'time':
                $oField->type = 'time';
                break;

            /**
             * ENUM
             */
            case 'enum':
                $oField->type    = 'dropdown';
                $oField->class   = 'select2';
                $aOptions        = explode("','", substr($sTypeConfig, 1, -1));
                $aLabels         = array_map('strtolower', $aOptions);
                $aLabels         = array_map([$this, 'describeFieldsPrepareLabel'], $aLabels);
                $oField->options = array_combine($aOptions, $aLabels);
                break;

            /**
             * Default to basic string
             */
            default:
                $oField->type       = 'text';
                $oField->max_length = $iLength ?: null;
                break;
        }
    }
protected function describeFieldsGuessType ( & $ oField , $ sType ) { preg_match ( '/^(.*?)(\((.+?)\)(.*))?$/' , $ sType , $ aMatches ) ; $ sType = ArrayHelper :: getFromArray ( 1 , $ aMatches , 'text' ) ; $ sTypeConfig = trim ( ArrayHelper :: getFromArray ( 3 , $ aMatches ) ) ; $ iLength = is_numeric ( $ sTypeConfig ) ? ( int ) $ sTypeConfig : null ; switch ( $ sType ) { /**
             * Numeric
             */ case 'int' : $ oField -> type = 'number' ; break ; /**
             * Boolean
             * Nails convention uses tinyint(1) as a boolean; if not (1) then treat as integer
             */ case 'tinyint' : case 'bool' : case 'boolean' : $ oField -> type = $ iLength == 1 ? 'boolean' : 'number' ; break ; /**
             * String
             */ case 'varchar' : $ oField -> type = 'text' ; $ oField -> max_length = $ iLength ? : null ; break ; case 'tinytext' : case 'text' : case 'mediumtext' : case 'longtext' : $ oField -> type = 'textarea' ; break ; /**
             * Date and time
             */ case 'date' : $ oField -> type = 'date' ; break ; case 'datetime' : $ oField -> type = 'datetime' ; break ; case 'time' : $ oField -> type = 'time' ; break ; /**
             * ENUM
             */ case 'enum' : $ oField -> type = 'dropdown' ; $ oField -> class = 'select2' ; $ aOptions = explode ( "','" , substr ( $ sTypeConfig , 1 , - 1 ) ) ; $ aLabels = array_map ( 'strtolower' , $ aOptions ) ; $ aLabels = array_map ( [ $ this , 'describeFieldsPrepareLabel' ] , $ aLabels ) ; $ oField -> options = array_combine ( $ aOptions , $ aLabels ) ; break ; /**
             * Default to basic string
             */ default : $ oField -> type = 'text' ; $ oField -> max_length = $ iLength ? : null ; break ; } }
Guesses the field's type and sets it accordingly

@param \stdClass $oField The field object
@param string    $sType  The database type
Guesses the field s type and sets it accordingly