Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import use statements are not taken into account when checking names against lists #1291

Closed
ihor-sviziev opened this issue Jul 29, 2021 · 5 comments
Labels
Milestone

Comments

@ihor-sviziev
Copy link

On the PHPCompatibility develop branch (I ran on 335cd6b) the following class fails with an error. Looks like it's not processing correctly import my own "use".

My test code looks like this:

<?php

declare(strict_types=1);

use My\Own\Namespace\Attribute;

class Test
{
    /**
     * @var Attribute
     */
    private $myAttribute;

    public function __construct(Attribute $myAttribute)
    {
        $this->myAttribute = $myAttribute;
    }

    public function execute()
    {
        //my code here...
    }
}

How I tested:

./vendor/bin/phpcs -p --colors --extensions=php --standard=PHPCompatibility --runtime-set testVersion 7.3-7.4 test/
E 1 / 1 (100%)



FILE: /var/www/html/test/test.php
----------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------------------------
 14 | ERROR | The built-in class Attribute is not present in PHP version 7.4 or earlier
----------------------------------------------------------------------------------------

Time: 45ms; Memory: 12MB
@jrfnl
Copy link
Member

jrfnl commented Jul 29, 2021

@ihor-sviziev Thanks for reporting this. This is actually a known issue. The intention is to solve this somewhere in the 10.x series, but the priority is now first on getting 10.0.0 out of the door. It is on my radar however.

@jrfnl jrfnl added the bug label Jul 29, 2021
@jrfnl jrfnl changed the title [False positive] The built-in class Attribute is not present in PHP version 7.4 or earlier Import use statements are not taken into account when checking names against lists Jul 29, 2021
@rdss-sknott
Copy link
Contributor

I wrote an pull request before i found this issue. Linking it for your convenience #1695

@jrfnl
Copy link
Member

jrfnl commented Apr 30, 2024

Fixed via #1695

@jrfnl jrfnl closed this as completed Apr 30, 2024
@ihor-sviziev
Copy link
Author

@jrfnl if I got right, it will be added to 10.0. When it's planned to be released?

@jrfnl
Copy link
Member

jrfnl commented May 1, 2024

@ihor-sviziev When it's ready 😔 (see various other discussions about this in the issues)

In the mean time, feel free to use the develop branch, it's pretty stable, but not all sniffs have been updated yet for the humongous amount of new PHP syntaxes which have been added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants