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

"Missing service" warning on service names with capital letters #537

Closed
marcverney opened this issue Jun 29, 2015 · 1 comment
Closed

"Missing service" warning on service names with capital letters #537

marcverney opened this issue Jun 29, 2015 · 1 comment

Comments

@marcverney
Copy link

Hi,

I get "Missing service" warnings in PHPStorm when using service names containing capital letters, even though the case correspond to the one used in the services.yml file. The problem looks similar to a previously reported issue concerning YML parameters.

Example:

# src/Acme/ExtranetBundle/Resources/config/services.yml
acme_extranet.myFriends:
    class: Acme\ExtranetBundle\Services\MyFriends\MyFriendsService
    arguments: [ @service_container ]

The service name gets lowercased in the xml container file (see @stof's comment in the above mentioned related issue)

<!-- app/cache/dev/appDevDebugProjectContainer.xml -->
<service id="acme_extranet.myfriends" class="Acme\ExtranetBundle\Services\MyFriends\MyFriendsService">
  <argument type="service" id="service_container"/>
</service>

In my Controller, the "correctly cased" service is marked as missing by PHPStorm:

// src/Acme/ExtranetBundle/Controller/MyController.php
$listFriends = $this->get('acme_extranet.myFriends'); // missing service warning

If I change the F for an f, the warning disappears.

Thanks, by the way, for a great plugin!

Using:
PHPStorm 8.0.3
Symfony2 Plugin 0.11.93

@marcverney marcverney changed the title "Missing service" warning on services names with capital letters "Missing service" warning on service names with capital letters Jun 29, 2015
@stof
Copy link
Contributor

stof commented Jul 23, 2015

the plugin should be aware that service ids are lowercased and so that the service is not missing.

However, I also suggest adding a warning saying that it is better to use the lowercase id to access the service: it is faster (especially in recent Symfony version as additional optimizations have been done for the normal code path so that using the real id does not have any overhead associated to the case-insensitivity support)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants