{"action":"created","issue":{"url":"https://api.github.com/repos/container-interop/service-provider/issues/5","repository_url":"https://api.github.com/repos/container-interop/service-provider","labels_url":"https://api.github.com/repos/container-interop/service-provider/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/container-interop/service-provider/issues/5/comments","events_url":"https://api.github.com/repos/container-interop/service-provider/issues/5/events","html_url":"https://github.com/container-interop/service-provider/issues/5","id":135553132,"number":5,"title":"Static Methods on Service Container Too Restrictive","user":{"login":"dragoonis","id":146321,"avatar_url":"https://avatars.githubusercontent.com/u/146321?v=3","gravatar_id":"","url":"https://api.github.com/users/dragoonis","html_url":"https://github.com/dragoonis","followers_url":"https://api.github.com/users/dragoonis/followers","following_url":"https://api.github.com/users/dragoonis/following{/other_user}","gists_url":"https://api.github.com/users/dragoonis/gists{/gist_id}","starred_url":"https://api.github.com/users/dragoonis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dragoonis/subscriptions","organizations_url":"https://api.github.com/users/dragoonis/orgs","repos_url":"https://api.github.com/users/dragoonis/repos","events_url":"https://api.github.com/users/dragoonis/events{/privacy}","received_events_url":"https://api.github.com/users/dragoonis/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2016-02-22T21:40:12Z","updated_at":"2016-02-23T13:49:17Z","closed_at":null,"body":"```\r\nuse Interop\\Container\\ServiceProvider\\ServiceProvider;\r\n\r\nclass MyServiceProvider implements ServiceProvider\r\n{\r\n    public static function getServices()\r\n    {\r\n        return [\r\n            'my_service' => 'createMyService',\r\n        ];\r\n    }\r\n\r\n    public static function createMyService(ContainerInterface $container, $previous = null)\r\n    {\r\n        $dependency = $container->get('my_other_service');\r\n\r\n        return new MyService($dependency);\r\n    }\r\n}\r\n```\r\n\r\nAs per the above example, you're exposing static methods to a provider of multiple services. This means you will need 1 public method per service. \r\n\r\nProblem 1) What if I have 100 services, I will need 100 methods, this will be slow.\r\nProblem 2) Some service names will be dynamic and thus you can't have a dynamic function name as it must be statically declared.\r\n\r\nA better way would be to have:\r\n\r\n``` php\r\n<?php\r\nclass MyServiceProvider implements ServiceProvider\r\n{\r\n\r\n    protected $serviceList = [];\r\n\r\n    public static function getServices()\r\n    {\r\n        return array_keys($this->buildServices());\r\n    }\r\n\r\n    protected function buildServices()\r\n    {\r\n        if(empty($this->serviceList)) {\r\n            return $this->serviceList;\r\n        }\r\n\r\n        $ret = [];\r\n        $ret['my_service'] = MyServiceFactory::class;\r\n        $cacheType = CACHE_TYPE;\r\n        $cacheTypeClass = CACHE_TYPE_CLASS;\r\n        $ret['my_service_cache_' . $cacheType] = $cacheTypeClass::class;\r\n\r\n        return $this->serviceList = $ret;\r\n    }\r\n}\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/container-interop/service-provider/issues/comments/187706070","html_url":"https://github.com/container-interop/service-provider/issues/5#issuecomment-187706070","issue_url":"https://api.github.com/repos/container-interop/service-provider/issues/5","id":187706070,"user":{"login":"mnapoli","id":720328,"avatar_url":"https://avatars.githubusercontent.com/u/720328?v=3","gravatar_id":"","url":"https://api.github.com/users/mnapoli","html_url":"https://github.com/mnapoli","followers_url":"https://api.github.com/users/mnapoli/followers","following_url":"https://api.github.com/users/mnapoli/following{/other_user}","gists_url":"https://api.github.com/users/mnapoli/gists{/gist_id}","starred_url":"https://api.github.com/users/mnapoli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mnapoli/subscriptions","organizations_url":"https://api.github.com/users/mnapoli/orgs","repos_url":"https://api.github.com/users/mnapoli/repos","events_url":"https://api.github.com/users/mnapoli/events{/privacy}","received_events_url":"https://api.github.com/users/mnapoli/received_events","type":"User","site_admin":false},"created_at":"2016-02-23T13:49:17Z","updated_at":"2016-02-23T13:49:17Z","body":"@moufmouf Agreed about the META document. Also it might be worth including in a FAQ  in the README?"}}