Skip to content

filereadable call to check config file swallows php-cs-fixer error #41

Open
@yriveiro

Description

@yriveiro

This block of code has a side effect that it's tricky to debug.

if exists('g:php_cs_fixer_config_file') && filereadable(g:php_cs_fixer_config_file)
    if g:php_cs_fixer_version == 1
        let g:php_cs_fixer_command = g:php_cs_fixer_command . ' --config-file=' . g:php_cs_fixer_config_file
    else
        let g:php_cs_fixer_command = g:php_cs_fixer_command . ' --config=' . g:php_cs_fixer_config_file
    endif
endif

filereadable check result in the omission of an php-cs-fixer error saying that the config file it's not readable. I was spend 30 minutes to understand why my phpcs config file did not run properly in vim but executing command line ran without any problem.

I realise that I must use an absolute path to the config file and not a relative one to work properly. In case a misconfiguration like this, an error saying that file can't be loaded would be nice.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions