> * @psalm-return array */ public static function getFields(CreateStatement $statement): array { if (empty($statement->fields) || ! is_array($statement->fields) || ! $statement->options->has('TABLE')) { return []; } $ret = []; foreach ($statement->fields as $field) { // Skipping keys. if (empty($field->type)) { continue; } $ret[$field->name] = [ 'type' => $field->type->name, 'timestamp_not_null' => false, ]; if (! $field->options) { continue; } if ($field->type->name === 'TIMESTAMP') { if ($field->options->has('NOT NULL')) { $ret[$field->name]['timestamp_not_null'] = true; } } $option = $field->options->get('DEFAULT'); if ($option !== '') { $ret[$field->name]['default_value'] = $option; if ($option === 'CURRENT_TIMESTAMP') { $ret[$field->name]['default_current_timestamp'] = true; } } if ($field->options->get('ON UPDATE') === 'CURRENT_TIMESTAMP') { $ret[$field->name]['on_update_current_timestamp'] = true; } $option = $field->options->get('AS'); if ($option === '') { continue; } $ret[$field->name]['expr'] = $option; } return $ret; } }