coding-standard
coding-standard copied to clipboard
`SlevomatCodingStandard.Namespaces.UnusedUses` not supporting docblocks or inline comments
Take phpcs.xml of
<?xml version="1.0"?>
<ruleset name="foobar">
<description>foo</description>
<exclude-pattern>./vendor/*</exclude-pattern>
<exclude-pattern>*/thirdparty/*</exclude-pattern>
<arg value="p"/>
<arg name="colors"/>
<arg name="parallel" value="10"/>
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
<properties>
<property name="searchAnnotations" type="bool" value="true"/>
<property name="ignoredAnnotations" type="array">
<element value="@config"/>
<element value="@dataProvider"/>
</property>
</properties>
</rule>
</ruleset>
And a file of
<?php
namespace App\Thing;
use App\Foo\Bar;
use App\Long\Path\Item;
use App\Long\Path\OtherItem;
/**
* Blah blah @see Item::function()
*/
class MyClass
{
/**
* Lorem ipsum @see Bar::fizz()
*/
public function doSomething(): bool
{
/** @see OtherItem::otherMethod() */
return false;
}
}
I am getting the following output...
FOUND 1 ERROR AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------------------------------------------
5 | ERROR | [x] Type App\Foo\Bar is not used in this file.
| | (SlevomatCodingStandard.Namespaces.UnusedUses.UnusedUse)
6 | ERROR | [x] App\Long\Path\Item is not used in this file.
| | (SlevomatCodingStandard.Namespaces.UnusedUses.UnusedUse)
10| ERROR | [x] App\Long\Path\OtherItem is not used in this file.
| | (SlevomatCodingStandard.Namespaces.UnusedUses.UnusedUse)
Shouldn't those be caught by the searchAnnotations = true ?