8000 `SlevomatCodingStandard.Namespaces.UnusedUses` cannot handle properties with (nullable) intersection types · Issue #1639 · slevomat/coding-standard · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
SlevomatCodingStandard.Namespaces.UnusedUses cannot handle properties with (nullable) intersection types #1639
Open
@kapersoft

Description

@kapersoft

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

Rule config:

<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
    <properties>
        <property name="searchAnnotations" value="true"/>
    </properties>
</rule>

I am using squizlabs/php_codesniffer@3.7.2 and slevomat/coding-standard@8.14.1

Does any have any ideas how to fix this?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0