dense-analysis / dense-analysis/ale
phpcbf empties my file on save
- Dominant language
- Vim Script
- Stars
- 14k
- Forks
- 1.5k
- Avg merge
- 17h 49m
- Merged PRs (30d)
- 1
Description
Hi,
I'm having a weird phenomenon when saving a specific file
Ale version : abcefe7a
## Information
**VIM version**
VIM - Vi IMproved 8.1 (2018 May 18, compiled Mar 27 2019 09:51:18)
Included patches: 1-1057
Operating System: Linux Mint 18.2 Sonya
## What went wrong
Like in #1408, the phpcbf output replaces my whole file.
Other php file in the same project aren't affected
The content of the file is the following and is called `SettingsReader.php` :
```
database($siteId);
return $config['password'];
}
/**
* @param string $siteId
* @return array
*/
public function database($siteId) {
$app_root = DRUPAL_ROOT;
$site_path = 'sites' . DIRECTORY_SEPARATOR . $siteId;
if (!file_exists($site_path . '/settings.php')) {
throw new \RuntimeException("No settings file found in « {$site_path} . '/settings.php' »");
}
require DRUPAL_ROOT . DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . $siteId . '/settings.php';
if (empty($databases['default']['default'])) {
throw new \RuntimeException("No \$databases[default][default] configuration found in « $site_path » ");
}
return $databases['default']['default'];
}
}
```
## Reproducing the bug
1. Open the file
2. Save it
The result is this :
```
No fixable errors were found
Time: 44ms; Memory: 6MB
```
### :ALEInfo
```
Current Filetype: php
Available Linters: ['langserver', 'phan', 'php', 'phpcs', 'phpmd', 'phpstan', 'psalm']
Enabled Linters: ['phpcs', 'phpstan']
Suggested Fixers:
'php_cs_fixer' - Fix PHP files with php-cs-fixer.
'phpcbf' - Fix PHP files with phpcbf.
'remove_trailing_lines' - Remove all blank lines at the end of a file.
'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.
Linter Variables:
let g:ale_php_phpcs_executable = 'phpcs'
let g:ale_php_phpcs_options = ''
let g:ale_php_phpcs_standard = ''
let g:ale_php_phpcs_use_global = 0
let g:ale_php_phpstan_configuration = 'phpstan.neon'
let g:ale_php_phpstan_executable = 'vendor/bin/phpstan'
let g:ale_php_phpstan_level = 7
Global Variables:
let g:ale_cache_executable_check_failures = v:null
let g:ale_change_sign_column_color = 0
let g:ale_command_wrapper = ''
let g:ale_completion_delay = 100
let g:ale_completion_enabled = 1
let g:ale_completion_max_suggestions = 50
let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_format = '%code: %%s'
let g:ale_echo_msg_info_str = 'Info'
let g:ale_echo_msg_warning_str = 'Warning'
let g:ale_enabled = 1
let g:ale_fix_on_save = 1
let g:ale_fixers = {'php': ['phpcbf']}
let g:ale_history_enabled = 1
let g:ale_history_log_output = 1
let g:ale_keep_list_window_open = 0
let g:ale_lint_delay = 200
let g:ale_lint_on_enter = 1
let g:ale_lint_on_filetype_changed = 1
let g:ale_lint_on_insert_leave = 0
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'always'
let g:ale_linter_aliases = {}
let g:ale_linters = {'php': ['phpcs', 'phpstan']}
let g:ale_linters_explicit = 0
let g:ale_list_vertical = 0
let g:ale_list_window_size = 10
let g:ale_loclist_msg_format = '%code: %%s'
let g:ale_lsp_root = {}
let g:ale_max_buffer_history_size = 20
let g:ale_max_signs = -1
let g:ale_maximum_file_size = v:null
let g:ale_open_list = 0
let g:ale_pattern_options = v:null
let g:ale_pattern_options_enabled = v:null
let g:ale_set_balloons = 0
let g:ale_set_highlights = 1
let g:ale_set_loclist = 1
let g:ale_set_quickfix = 0
let g:ale_set_signs = 1
let g:ale_sign_column_always = 1
let g:ale_sign_error = ''
let g:ale_sign_info = ''
let g:ale_sign_offset = 1000000
let g:ale_sign_style_error = ''
let g:ale_sign_style_warning = ''
let g:ale_sign_warning = ''
let g:ale_statusline_format = v:null
let g:ale_type_map = {}
let g:ale_use_global_executables = v:null
let g:ale_virtualtext_cursor = 0
let g:ale_warn_about_trailing_blank_lines = 1
let g:ale_warn_about_trailing_whitespace = 1
Command History:
```
Contributor guide
Assessment
This issue has not been assessed yet.