Carloscito
Carloscito

Reputation: 373

SublimeText and php-cs errors

I install SublimeLinter and PHP-cs with PHP-cs Fixer and I'm getting some warning and some errors, but I want to ignore them.

 2:1    error          phpcs: error        Missing file doc comment
11:1    error          phpcs: error        Missing doc comment for class ProductController
13:12   error          phpcs: error        Missing doc comment for function __construct()
18:12   error          phpcs: error        Missing doc comment for function index()
23:12   error          phpcs: error        Missing doc comment for function show()
28:12   error          phpcs: error        Missing doc comment for function create()
34:12   error          phpcs: error        Missing doc comment for function store()
71:90   warning        phpcs: warning      Line exceeds 85 characters; contains 90 characters
84:12   error          phpcs: error        Missing doc comment for function edit()
89:94   warning        phpcs: warning      Line exceeds 85 characters; contains 94 characters
91:12   error          phpcs: error        Missing doc comment for function update()
93:16   error          phpcs: error        Opening parenthesis of a multi-line function call must be the last content on the line
102:10   error          phpcs: error        Closing parenthesis of a multi-line function call must be on a line by itself
125:90   warning        phpcs: warning      Line exceeds 85 characters; contains 90 characters
136:12   error          phpcs: error        Missing doc comment for function destroy()

I try with some exclude sniffs but nothing happens, and it is annoying. Exist any solution for it?

Maybe 93:16 and 102:10 get auto indent, but with ignore it is ok.

My .phpcsfixer

<?php

return PhpCsFixer\Config::create()
->setRules(
    [
        '@PSR2' => true,
        'array_syntax' => ['syntax' => 'short'],
        'no_unused_imports' => true
    ]
);

and my Linter configuration

"linters": {
    "phpcs": {
        "@disable": true,
        "args": [],
        "excludes": [
            "*.blade.php"
        ],
        "standard": ""
    }
},

Thanks all.

Upvotes: 1

Views: 1623

Answers (2)

Arunprabakaran M
Arunprabakaran M

Reputation: 129

Here's the fix that worked for me under Preferences > Package Settings > Sublime Linter > Settings:

// SublimeLinter Settings - User

{
    "linters": {
        "phpcs":{
            "executable": "${folder}\\vendor\\bin\\phpcs.bat"
        }
    }
}

refer: https://github.com/SublimeLinter/SublimeLinter-phpcs/issues/36

Upvotes: 1

Lost
Lost

Reputation: 109

There is 2 solutions to solve your issue.

1. Change the code standard

The installed coding standards are PSR2, Zend, Squiz, PSR1, PEAR and MySource

The file comment is a part of PEAR code standard, your can pick other code standards.

Eg:

"linters": {
    "phpcs": {
        "args": "--standard=PSR2",
    }
},

2. Build your own ruleset

This option may too advanced for beginner, as a suggestion, use solution 1.

If you decide to build your own ruleset, please refer to official documentation


References

Disable PHPDoc sniffing #1866

Upvotes: 1

Related Questions