SlevomatCodingStandard.Namespaces.UnusedUses thinks the imports are unused when property contains (nullable) intersection types.
This code:
<?php
namespace App;
use Symfony\Component\Cache\Adapter\AdapterInterface;
use Symfony\Contracts\Cache\CacheInterface;
class Example
{
public (AdapterInterface&CacheInterface)|null $cache = null;
}
Results in the following output:
FILE: example.php
-------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
-------------------------------------------------------------------------------------------------
5 | ERROR | [x] Type Symfony\Component\Cache\Adapter\AdapterInterface is not used in this file.
6 | ERROR | [x] Type Symfony\Contracts\Cache\CacheInterface is not used in this file.
-------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------
Time: 16ms; Memory: 8MB
SlevomatCodingStandard.Namespaces.UnusedUses
thinks the imports are unused when property contains (nullable) intersection types.This code:
Results in the following output:
Rule config:
I am using
squizlabs/php_codesniffer@3.7.2
andslevomat/coding-standard@8.14.1
Does any have any ideas how to fix this?