marlonfan / coc-phpls

🐭 php language server for coc.nvim
MIT License
211 stars 17 forks source link

Symbol is declared but not used when symbol is first argument of a function declaration #79

Closed esetnik closed 4 years ago

esetnik commented 4 years ago

Describe the bug When a function defines multiple arguments but does not use all of them, a warning is generated "Symbol is declared but not used". Functions which are called by third-party code do not have control over their signature and must take parameters in a specific order even if they don't use them internally. So this should not be a warning or there should be some way to turn off the warning.

Other linters like eslint allow rules for ignoring this rule when a specific matching rule exists. E.g. renaming $request to $_request would silence the warning.

To Reproduce Steps to reproduce the behavior:

<?php

namespace Prodigy\Controller;

use Slim\Http\Response as Response;
use Slim\Http\ServerRequest as Request;

class StatusController
{
    protected $db;

    public function __construct(\Illuminate\Database\Capsule\Manager $db, \Monolog\Logger $logger)
    {
        $this->db = $db;
        $this->logger = $logger;
    }

    public function getStatusRequest(Request $request, Response $response)
    {
        $data = ['status' => 'OK'];
        $response = $response->withJson($data);
        return $response;
    }
}

Expected behavior No error message

Screenshots image

Desktop (please complete the following information):

Additional context

yaegassy commented 4 years ago

Hi, Add this setting to coc-settings.json and give it a try.

"intelephense.diagnostics.unusedSymbols": false

esetnik commented 4 years ago

Hi, Add this setting to coc-settings.json and give it a try.

"intelephense.diagnostics.unusedSymbols": false

But I don't want to disable all of the unused symbol diagnostics, only this particular case where it's an incorrect error. In this case I can't do anything about the warning so I'm just stuck with it.

yaegassy commented 4 years ago

coc-phpls uses the Language Server's intelephense.

This problem has been considered to be addressed in intelephense itself, but it has not yet been implemented.

Ref: https://github.com/bmewburn/vscode-intelephense/issues/568