framework/console/controllers/MigrateController.php
protected function parseFields()
    {
        $fields = [];
        $foreignKeys = [];

        foreach ($this->fields as $index => $field) {
            $chunks = preg_split('/\s?:\s?/', $field, null);
            $property = array_shift($chunks);

            foreach ($chunks as $i => &$chunk) {
                if (strncmp($chunk, 'foreignKey', 10) === 0) {
                    preg_match('/foreignKey\((\w*)\s?(\w*)\)/', $chunk, $matches);
                    $foreignKeys[$property] = [
                        'table' => isset($matches[1])
                            ? $matches[1]
                            : preg_replace('/_id$/', '', $property),
                        'column' => !empty($matches[2])
                            ? $matches[2]
                            : null,
                    ];

                    unset($chunks[$i]);
                    continue;
                }

                if (!preg_match('/^(.+?)\(([^(]+)\)$/', $chunk)) {
                    $chunk .= '()';
                }
            }
            $fields[] = [
                'property' => $property,
                'decorators' => implode('->', $chunks),
            ];
        }

        return [
            'fields' => $fields,
            'foreignKeys' => $foreignKeys,
        ];
    }
protected function parseFields()
    {
        $fields = [];
        $foreignKeys = [];

        foreach ($this->fields as $index => $field) {
            $chunks = preg_split('/\s?:\s?/', $field, null);
            $property = array_shift($chunks);

            foreach ($chunks as $i => &$chunk) {
                if (strncmp($chunk, 'foreignKey', 10) === 0) {
                    preg_match('/foreignKey\((\w*)\s?(\w*)\)/', $chunk, $matches);
                    $foreignKeys[$property] = [
                        'table' => isset($matches[1])
                            ? $matches[1]
                            : preg_replace('/_id$/', '', $property),
                        'column' => !empty($matches[2])
                            ? $matches[2]
                            : null,
                    ];

                    unset($chunks[$i]);
                    continue;
                }

                if (!preg_match('/^(.+?)\(([^(]+)\)$/', $chunk)) {
                    $chunk .= '()';
                }
            }
            $fields[] = [
                'property' => $property,
                'decorators' => implode('->', $chunks),
            ];
        }

        return [
            'fields' => $fields,
            'foreignKeys' => $foreignKeys,
        ];
    }
protected function parseFields ( ) { $ fields = [ ] ; $ foreignKeys = [ ] ; foreach ( $ this -> fields as $ index => $ field ) { $ chunks = preg_split ( '/\s?:\s?/' , $ field , null ) ; $ property = array_shift ( $ chunks ) ; foreach ( $ chunks as $ i => & $ chunk ) { if ( strncmp ( $ chunk , 'foreignKey' , 10 ) === 0 ) { preg_match ( '/foreignKey\((\w*)\s?(\w*)\)/' , $ chunk , $ matches ) ; $ foreignKeys [ $ property ] = [ 'table' => isset ( $ matches [ 1 ] ) ? $ matches [ 1 ] : preg_replace ( '/_id$/' , '' , $ property ) , 'column' => ! empty ( $ matches [ 2 ] ) ? $ matches [ 2 ] : null , ] ; unset ( $ chunks [ $ i ] ) ; continue ; } if ( ! preg_match ( '/^(.+?)\(([^(]+)\)$/' , $ chunk ) ) { $ chunk .= '()' ; } } $ fields [ ] = [ 'property' => $ property , 'decorators' => implode ( '->' , $ chunks ) , ] ; } return [ 'fields' => $ fields , 'foreignKeys' => $ foreignKeys , ] ; }
Parse the command line migration fields.
@return array parse result with following fields:

- fields: array, parsed fields
- foreignKeys: array, detected foreign keys

@since 2.0.7
Parse the command line migration fields . @return array parse result with following fields :