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

Fix "Fix Imports" [GH-7546] #7549

Merged
merged 1 commit into from
Jul 7, 2024

Conversation

junichi11
Copy link
Member

Example:

<?php
namespace NS1;

class TestClass {}
class TestClass2TestClass {}
interface TestInterface {}
interface TestInterface2TestInterface {}
trait TestTrait {}
trait TestTrait2TestTrait {}
enum TestEnum {
    case Test;
}
enum TestEnum2TestEnum {
    case Test;
}

const CONSTANT = 1;
const CONSTANT2CONSTANT = 2;

function func(): void {}
function func2func(): void {}

namespace NS1\Sub1\Sub2\Sub3;

class TestClass {}
class TestClass2TestClass {}
interface TestInterface {}
interface TestInterface2TestInterface {}
trait TestTrait {}
trait TestTrait2TestTrait {}
enum TestEnum {
    case Test;
}
enum TestEnum2TestEnum {
    case Test;
}

const CONSTANT = 1;
const CONSTANT2CONSTANT = 2;

function func(): void {}
function func2func(): void {}
namespace Test;

class GH7546 { // Fix Imports here
    private TestClass $testClass1;
    private NS1\Sub1\TestClass $testClass2;
    private TestInterface $testInterface;
    private \NS1\Sub1\Sub2\Sub3\TestInterface $testInterface2;

    public const CONSTANT = TestEnum::Test;
    public const int CONSTANT2 = CONSTANT;

    use TestTrait;

    public function test(): void {
        func();
    }
}

Before:

nb-php-gh-7546-before

After:

nb-php-gh-7546-after

- apache#7546
- Compare segments of namespace names to avoid adding incorrect items
- Add a unit test
@junichi11 junichi11 added the PHP [ci] enable extra PHP tests (php/php.editor) label Jul 6, 2024
@junichi11 junichi11 added this to the NB23 milestone Jul 6, 2024
@junichi11 junichi11 linked an issue Jul 6, 2024 that may be closed by this pull request
@junichi11 junichi11 requested a review from tmysik July 6, 2024 22:20
Copy link
Member

@tmysik tmysik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@junichi11 junichi11 merged commit 94a916c into apache:master Jul 7, 2024
33 checks passed
@junichi11 junichi11 deleted the php-gh-7546-fix-imports-issue branch July 7, 2024 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PHP [ci] enable extra PHP tests (php/php.editor)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix imports proposes incorrect class (name mismatch)
2 participants