Vscode-intelephense: Symbol is decared but not used

Created on 20 Feb 2019  路  7Comments  路  Source: bmewburn/vscode-intelephense

It is really nice that intelephense now tries to tell you symbols that are not used(I find it great)

but the problem is that if symbol is used in dockblock then it still tells that this symbol is not used even tho it is used

resolved in 1.0.3

Most helpful comment

Same for

$lastname = "Doe";
$this->set(compact("lastname"));

Symbol '$lastname' is declared but not used

All 7 comments

@mikk150 Do you actually use the symbol in the definition of whatever you鈥檙e doc-blocking though?

Given this:

use Foo;

class Bar
{
    /**
     * @param Foo $foo
     */
    public static function qux($foo)
    {
        //
    }
}

I鈥檇 still expect Foo to be flagged as un-used because鈥攅ven though you鈥檝e referenced it in the docblock鈥攜ou鈥檝e not actually used it in the class or method itself.

The reason being, I could add _anything_ to a docblock, but it doesn鈥檛 actually make it so:

use Foo;

class Bar
{
    /**
     * @param Foo $foo
     */
    public static function qux(DefinitelyNotFoo $foo)
    {
        //
    }
}

Same for

$lastname = "Doe";
$this->set(compact("lastname"));

Symbol '$lastname' is declared but not used

@martinbean yes and no

use FooInterface;

class Bar
{
    /**
     * @return FooInterface
     */
    public static function qux()
    {
        return $this->someMethodThatReturnsFoo();
    }
}

that someMethodThatReturnsFoo could be method from another class or whatever

@mstroink that is something even I would not expect working because yes, it is used, no you shall never use it

Same for

$lastname = "Doe";
$this->set(compact("lastname"));

Symbol '$lastname' is declared but not used

Can we have an option to disable not used check? Thanks

I agree with @martinbean example in that it's unused in the executable code. Though considering acting on the unused symbol declaration by removing it could break intellisense and generated docs I think it shouldnt be reported as unused. @mstroink in the next release if a compact call is present in the variable scope then it will be assumed all variables are used. @anothergituser #204

Reopen :)
screenshot from 2019-02-28 18-07-51
if I remove that |null then it works

@mikk150 fixed in 1.0.5

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  3Comments

ghnp5 picture ghnp5  路  3Comments

superadmini picture superadmini  路  4Comments

9brada6 picture 9brada6  路  3Comments

swashata picture swashata  路  3Comments