Sorien / silex-idea-plugin

Idea plugin for Silex Framework - plugin is not compatible with PHPStorm 2016.2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug resolving services from app variable set from method

CarsonF opened this issue · comments

$app = $this->getApp();
$app['foo'];

The IDE has $app resolved, but won't do completion for foo.

This works though:

$app = new Application();
$app['foo'];

so I know everything else is hooked up right.

(This is with 0.9.6)

hmm weird

class Test {

    public function test() {
        return new \Silex\Application();
    }

    public function foo() {
        $app = $this->test();
        $app['<caret>'] // autocomplete is working 
    }
}

^ works for you? It doesn't for me...

And yes the service exists, and autocomplete is working elsewhere with it

pls install https://plugins.jetbrains.com/plugin/227?pr=phpStorm, assign it to some variable and show me its signature

plugin

Ah it's says class.method[foo] instead of Application[foo]

#S#M#C\GMO\CC\Test\DbTestCase.getApp[foo]

I typed it manually, the S is actually your special char.

Also I'm using IntelliJ IDEA 14.1.3 Build #IU-141.1010, built on May 12, 2015. I doubt that's the issue, but maybe.

ok it's all i need, i'll create fix tomorrow ... got to bed, it's like midnight here

Goodnight man, great work today! :)

pls try this one silex-plugin-0.9.7. ... i'm not able to create example with type signature #S#M#C but it could help ...

Hmmm no joy. Signature does seem to change between previous and #S#Vapp[foo] but type isn't resolved.

hmm, i was hoping that it will help, maybe you could create some minimal example

I'll see if I can narrow it down more

i'm reading it again and code i posted doesn't work for you? #11 (comment)

and you said that you are using IntelliJ Idea, can you give me PHP plugin version

The method is defined in a trait. That seems to be the difference/problem.

thanks, last commit should fix it ;) ... if you want to try 0.9.7.2

Hmmm not yet

are you sure? it solves something like this for me

trait TestT {
    public function test() {
        return new \Silex\Application();
    }
}

class Test {

    use TestT;

    public function foo() {
        $a = $this->test();
        $a = $a[''];
    }
}

You're right that does work. Here's what doesn't work for me (and almost the actual code in use)

trait TestTrait {

    private $app;

    protected function getApp() {
        if (!$this->app) {
            $this->app = $this->createApp();
        }
        return $this->app;
    }

    protected function createApp() {
        return new Application();
    }
}

class Test {

    use TestTrait;

    public function foo() {
        $app = $this->getApp();
        $asdf = $app['foo'];
    }
}

I'm not sure why that makes a difference but it does

Ugh ok if I type hint the $app variable it works

/** @var Application */
private $app;

But even without that comment on the variable, the quick documentation for getApp says it's returning an Application object and app methods are auto-completed as well.

its because it's returning type like #P#C\TestTrait.app|\Silex\Application|? and phpIndex.getClassesByFQN cant find phpclass according that signature

Does phpIndex.getClassesByFQN work for \Silex\Application|\Another\Valid\Class?
I mean is it just the first (\TestTrait.app) and third (?) type/signature-part/etc that are throwing it off?

don't think so, but I can iterate over returned types commit 1e9d753

if you find some free time can you look at version 0.9.7 https://github.com/Sorien/silex-idea-plugin/releases/tag/0.9.7 should solve this problem and adds experimental support for sub containers

Yes it does! Beautiful!