{"action":"opened","issue":{"url":"https://api.github.com/repos/ramsey/collection/issues/5","repository_url":"https://api.github.com/repos/ramsey/collection","labels_url":"https://api.github.com/repos/ramsey/collection/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/ramsey/collection/issues/5/comments","events_url":"https://api.github.com/repos/ramsey/collection/issues/5/events","html_url":"https://github.com/ramsey/collection/issues/5","id":156393254,"number":5,"title":"TypedMap class","user":{"login":"eclipxe13","id":1266852,"avatar_url":"https://avatars.githubusercontent.com/u/1266852?v=3","gravatar_id":"","url":"https://api.github.com/users/eclipxe13","html_url":"https://github.com/eclipxe13","followers_url":"https://api.github.com/users/eclipxe13/followers","following_url":"https://api.github.com/users/eclipxe13/following{/other_user}","gists_url":"https://api.github.com/users/eclipxe13/gists{/gist_id}","starred_url":"https://api.github.com/users/eclipxe13/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eclipxe13/subscriptions","organizations_url":"https://api.github.com/users/eclipxe13/orgs","repos_url":"https://api.github.com/users/eclipxe13/repos","events_url":"https://api.github.com/users/eclipxe13/events{/privacy}","received_events_url":"https://api.github.com/users/eclipxe13/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-05-24T00:08:25Z","updated_at":"2016-05-24T00:08:25Z","closed_at":null,"body":"I'm interested on push the `TypedMap` class, is like a Map but keys and values are typed. This would follow the generics mimics of `Map<K key, V value>`\r\n\r\nYou could use the concrete class directly:\r\n\r\n```php\r\n$map = new TypedMap('string', \\My\\Foo::class, $data);\r\n$map['foo'] = new \\My\\Foo();\r\n\r\n// this throw an exception since key is not a string\r\n$map[1] = new \\My\\Foo();\r\n\r\n// this throw an exception since value stdClass is not a \\My\\Foo\r\n$map['baz'] = new \\stdClass()\r\n```\r\n\r\nOr extending the AbstractTypedMap:\r\n\r\n```php\r\nclass FooTypedMap extends AbstractTypedMap\r\n{\r\n    public function getKeyType()\r\n    {\r\n        return \"int\"\r\n    }\r\n\r\n    public function getValueType()\r\n    {\r\n         return Foo::class;\r\n    }\r\n}\r\n\r\n$map = new FooTypedMap([\r\n    100 => new Foo(),\r\n    200 => new Foo(2),\r\n]);\r\n```\r\n\r\nQuestion: Should I place the class inside src/Map? Looks like this is the place of Maps since it contains the concrete class `NamedParameterMap`.\r\nAs this contains the interface, an abstract class and a concrete implementation looks more organized on its own namespace `Ramsey\\Collection\\TypedMap` that points to `src/TypedMap`.\r\n\r\nThanks and please advice.\r\n"}}
{"actor":{"display_login":"eclipxe13"}}