Bug, Zend Studio 10.6 incorrectly resolves trait "use".

General discussion on Zend Studio
Post Reply
jameskp
Posts: 73
Joined: Fri May 11, 2012 11:55 am

Bug, Zend Studio 10.6 incorrectly resolves trait "use".

Post by jameskp » Sat Mar 15, 2014 8:34 am

In PHP there are three completely separate meanings to the "use" token. To declare aliases, to import traits into a class, and to import variables in closures:

Code: Select all

// #1 To declare aliases.
use Foo\Bar;

// #2 To import traits.
class Baz {
    use TraitName;
}

// #3 To import variables in closures.
$f = function () use ($a, $b, $c) { ... };
The tricky part is that class names in use #1 are always absolute, but trait names in use #2 are always *relative*.

Zend Studio correctly autocompletes case #1 as absolute, but incorrectly autocompletes #2 as absolute, immediately producing an invalid name in the statement (which ironically, Zend Studio itself discovers and produces a warning about after you save):

Code: Select all

namespace Foo {
    trait Hello {}
}

namespace Bar {
    trait World {}

    class Test {
        // I typed "Hello".
        // Autocompleted to "Foo\Hello" (incorrect, resolves to \Bar\Foo\Hello).
        // Correct: "\Foo\Hello" (or just "Hello" + a second "use Foo\Hello;" inserted *outside* the class).

        use Foo\Hello;

        // I typed "World".
        // Autocompleted to "Bar\World" (incorrect, resolves to \Bar\Bar\World).
        // Correct: "World".

        use Bar\World;
    }
}

jameskp
Posts: 73
Joined: Fri May 11, 2012 11:55 am

Re: Bug, Zend Studio 10.6 incorrectly resolves trait "use".

Post by jameskp » Sat Mar 15, 2014 8:40 am

I'd like to quickly point out, this is not a regression in 10.6 specifically, that bug was around for a long time. I'm just now reporting it as I see it's still there. Still annoying though. I use traits a lot! :)

User avatar
natalia_b_zend
Posts: 366
Joined: Wed Jan 25, 2012 5:51 pm

Re: Bug, Zend Studio 10.6 incorrectly resolves trait "use".

Post by natalia_b_zend » Tue Mar 18, 2014 10:35 am

Thank you for this report! We'll fix it.
Natalia Bartol
Zend Studio Team

Post Reply