Created
April 10, 2017 14:42
-
-
Save Haehnchen/aea3ac2d10cc709227815436de1e2ba2 to your computer and use it in GitHub Desktop.
Class Service Locator: https://twitter.com/benjamincremer/status/851434756617142272
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"registrar": [ | |
{ | |
"provider": "class", | |
"language": "php", | |
"signatures": [ | |
{ | |
"class": "FooClass", | |
"method": "foo", | |
"type": "type" | |
} | |
] | |
} | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class FooClass | |
{ | |
public function foo($foo) | |
{ | |
} | |
} | |
(new FooClass())->foo(DateTime::class)->getTimestamp(); |
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
Work's like a charm. Thanks a lot!
Enjoy return type autocompletion for your ServiceLocator