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

Does not find service with backslash in name

Philipp91 opened this issue · comments

My service of class \Some\Namespace\X is defined as sth like
$container[X::class] = function ($c) { return new X(); }
and the getter $container[X::class] works as expected during runtime, but there is no auto completion in the IDE and it falsely reports methods that could not be found.

Equally, $container["Some\\Namespace\\X"] does not work, but $container["Some\Namespace\X"] does (however it does not run for certain namespace names, when stuff gets actually escaped) and also $container['Some\Namespace\X'] works. It seems like the plugin only gets the string value from the code but does not handle the escaped backslashes.

hi, pls recheck with this version http://silex.sorien.sk/download/master all your issues should be fixed with last commits

Hi, I checked with that version (0.9.8-dev), but it still does not work. Same problem as before when using "Something\\Else" as the name of a service. Registering the service like that and calling it as "Something\Else" still makes the resolution work, but the program doesn't run then.

pls try it again ... there was problem that Travis did not deploy proper version.

Thank you for responding so quickly! I indeed got a newer version now (10:55 today instead of mid-March) and it works a bit more, but not fully yet:
$container["Something\\Else"] now works as expected, but the equivalent $somevar = "Something\\Else"; $container[$somevar] doesn't work and neither do $container[self::SOME_STATIC] or $container[\Something\Else::class]. So it only works for string literals that are directly there.

are you sure that ::class and static is not working?

image

image

pimple.json

[
    {
        "name": "\\foo\\faa\\Test",
        "type": "class",
        "value": "foo\\faa\\Test"
    }
]

$container[$somevar] is a bit problematic to implement i'll look at it a bit more but i think there is no extension point to do it.

I double-checked. ::class and a static variable are only working together if you use the former for service registration and the latter for retrieval.

I replicated your example. It doesn't run because Test::test != Test::class, but that's easily fixed (just remove the preceding backslash from Test::test). If I use Test::test for both registration and retrieval, it works. But whenever I use const TEST = Test::class; or $app[Test::class], it stops working, so the ::class is not recognized properly.

oh i see now it should be better ... but its not possible to resolve const TEST = Test::class; with current api

Great! Now it works, thank you so much! Resolving constants that depend on ::class is probably not necessary for anyone, neither is resolving the local variables. Those would be rare cases in framework code, where you could simply ignore the warnings.