{"action":"created","issue":{"url":"https://api.github.com/repos/myclabs/php-enum/issues/18","labels_url":"https://api.github.com/repos/myclabs/php-enum/issues/18/labels{/name}","comments_url":"https://api.github.com/repos/myclabs/php-enum/issues/18/comments","events_url":"https://api.github.com/repos/myclabs/php-enum/issues/18/events","html_url":"https://github.com/myclabs/php-enum/issues/18","id":77718002,"number":18,"title":"Static method to get array of all enum instances","user":{"login":"chriseskow","id":19055,"avatar_url":"https://avatars.githubusercontent.com/u/19055?v=3","gravatar_id":"","url":"https://api.github.com/users/chriseskow","html_url":"https://github.com/chriseskow","followers_url":"https://api.github.com/users/chriseskow/followers","following_url":"https://api.github.com/users/chriseskow/following{/other_user}","gists_url":"https://api.github.com/users/chriseskow/gists{/gist_id}","starred_url":"https://api.github.com/users/chriseskow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chriseskow/subscriptions","organizations_url":"https://api.github.com/users/chriseskow/orgs","repos_url":"https://api.github.com/users/chriseskow/repos","events_url":"https://api.github.com/users/chriseskow/events{/privacy}","received_events_url":"https://api.github.com/users/chriseskow/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-18T16:28:39Z","updated_at":"2015-05-18T17:01:02Z","closed_at":null,"body":"When using this library, I was slightly surprised to find that the toArray() method returns an associative array mapping the enum constant names to their underlying values, rather than to instances of the enum object wrapping the value. When adding additional behavior to the enum via instance methods, having the enum objects is often more useful than only the underlying constant values.\r\n\r\nWhat do you think of adding a static method, e.g. getInstances(), returning an array mapping constant names to object instances?"},"comment":{"url":"https://api.github.com/repos/myclabs/php-enum/issues/comments/103129799","html_url":"https://github.com/myclabs/php-enum/issues/18#issuecomment-103129799","issue_url":"https://api.github.com/repos/myclabs/php-enum/issues/18","id":103129799,"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":"2015-05-18T17:01:02Z","updated_at":"2015-05-18T17:01:02Z","body":"Hi, this is indeed something I've never thought of, and never needed. But it makes sense, I can imagine plenty of scenarios where you would want to get the list of the actual enum instances…\r\n\r\nI think if you make a PR I'd be +1 to merge it, if anybody else has a preference please voice it.\r\n\r\nAnd yes, now I wish `toArray()` would return the instance list ;) But we have to keep BC. However we have `keys()`, and a few month ago someone suggested to rename `toArray()` to `values()`: we didn't because of BC issues, but we could name the new method `values()` it would make sense I think."}}