Skip to content

Instantly share code, notes, and snippets.

@Haehnchen
Created April 10, 2017 14:42
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Haehnchen/aea3ac2d10cc709227815436de1e2ba2 to your computer and use it in GitHub Desktop.
Save Haehnchen/aea3ac2d10cc709227815436de1e2ba2 to your computer and use it in GitHub Desktop.
{
"registrar": [
{
"provider": "class",
"language": "php",
"signatures": [
{
"class": "FooClass",
"method": "foo",
"type": "type"
}
]
}
]
}
<?php
class FooClass
{
public function foo($foo)
{
}
}
(new FooClass())->foo(DateTime::class)->getTimestamp();
@bcremer
Copy link

bcremer commented Apr 10, 2017

Work's like a charm. Thanks a lot!

{
  "registrar": [
    {
      "provider": "class",
      "language": "php",
      "signatures": [
        {
          "class": "Zend\\ServiceManager\\ServiceLocatorInterface",
          "method": "get",
          "type": "type"
        }
      ]
    }
  ]
}

Enjoy return type autocompletion for your ServiceLocator

@bcremer
Copy link

bcremer commented May 29, 2017

For future Reference.

This also works out-of-the-box without any plugins in PHPStorm when using the .phpstorm.meta.php file, see: https://confluence.jetbrains.com/display/PhpStorm/PhpStorm+Advanced+Metadata.

// file: .phpstorm.meta.php
namespace PHPSTORM_META
{
    use Interop\Container\ContainerInterface as InteropContainerInterface;

    override(InteropContainerInterface::get(0),
        map([
            '' => '@',
            'Application' => Zend\Mvc\ApplicationInterface::class,
            'HttpRouter' => Zend\Mvc\Router\Http\TreeRouteStack::class,
        ])
    );
}

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