Sorien / silex-idea-plugin

Idea plugin for Silex Framework - plugin is not compatible with PHPStorm 2016.2
MIT License
26 stars 8 forks source link

Completion for subclasses of Pimple #2

Closed CarsonF closed 9 years ago

CarsonF commented 9 years ago

I sub-class Application for each of my projects and register my service providers there (basically same as Silex). Completion isn't provided for these though.

Doesn't work:

$container = new My\Application();
$container['console']->run();

Works:

/** @var Pimple $container */
$container = new My\Application();
$container['console']->run();

Thank you so much for working on this!!

Sorien commented 9 years ago
class MyApplication extends Silex\Application {
}

$app = new MyApplication();
$app['<caret>'] // works without any problem

$app->run(); 

but there is limitation, only first inherited child is resolved as Pimple container and so example below is not working...

class MyApplication extends Silex\Application {
}

class MySubApplication extends MyApplication {
}

$app = new MySubApplication();
$app[''] = true;

can you show me your Application inheritence tree, i'll try to solve it or create settings for it...

CarsonF commented 9 years ago

Is the first inherited child resolution limitation from your plugin or IDEA's API?

I have a couple cases of more than one level of inheritance. For example:

namespace Silex {
    class Application extends \Pimple { }
}

namespace CarsonF\Common {
   use Silex\Application as ApplicationBase;
   class Application extends ApplicationBase { }
}

namespace CarsonF\ProjectA {
   use CarsonF\Common\Application as ApplicationBase;
   class Application extends ApplicationBase { }
}

Is it possible the use as is throwing it off?

Sorien commented 9 years ago

its my plugin limitation ... inheritance should be resolved inside php extension, i just need to iterate over whole inheritance tree (it should be possible but it can have some performance impact) ... i'll look at it tomorow

CarsonF commented 9 years ago

Cool! Maybe the classes can be cached?

Sorien commented 9 years ago

should be solved, please check ver. 0.9.2 https://github.com/Sorien/silex-idea-plugin/releases/tag/0.9.2 (now i'm checking to the depth of 5 in inheritance tree)

CarsonF commented 9 years ago

Version 0.9.4 fixed it!