{"action":"created","issue":{"url":"https://api.github.com/repos/schmittjoh/serializer/issues/411","labels_url":"https://api.github.com/repos/schmittjoh/serializer/issues/411/labels{/name}","comments_url":"https://api.github.com/repos/schmittjoh/serializer/issues/411/comments","events_url":"https://api.github.com/repos/schmittjoh/serializer/issues/411/events","html_url":"https://github.com/schmittjoh/serializer/issues/411","id":60314982,"number":411,"title":"Serializing ArrayCollection of an abstract class returns empty objects","user":{"login":"halloverden","id":3169836,"avatar_url":"https://avatars.githubusercontent.com/u/3169836?v=3","gravatar_id":"","url":"https://api.github.com/users/halloverden","html_url":"https://github.com/halloverden","followers_url":"https://api.github.com/users/halloverden/followers","following_url":"https://api.github.com/users/halloverden/following{/other_user}","gists_url":"https://api.github.com/users/halloverden/gists{/gist_id}","starred_url":"https://api.github.com/users/halloverden/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/halloverden/subscriptions","organizations_url":"https://api.github.com/users/halloverden/orgs","repos_url":"https://api.github.com/users/halloverden/repos","events_url":"https://api.github.com/users/halloverden/events{/privacy}","received_events_url":"https://api.github.com/users/halloverden/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-03-09T09:03:19Z","updated_at":"2015-03-09T09:03:46Z","closed_at":null,"body":"I'm using the [Serlalizer Bundle](https://github.com/schmittjoh/JMSSerializerBundle) with Symfony2, but suspect this is a Serializer issue. \r\n\r\nI have an abstract class \"Question\":\r\n\r\n```\r\n/**\r\n * App\\SurveyBundle\\Entity\\Question\r\n * \r\n * @ORM\\Entity\r\n * @ORM\\InheritanceType(\"JOINED\")\r\n * @ORM\\DiscriminatorColumn(name=\"type\", type=\"integer\")\r\n * @ORM\\DiscriminatorMap({0 = \"App\\SurveyBundle\\Entity\\Question\", 3 = \"App\\SurveyBundle\\Entity\\MultipleChoice\", 2 = \"App\\SurveyBundle\\Entity\\SingleChoice\", 1 = \"App\\SurveyBundle\\Entity\\LikertScale\"})\r\n * @JMS\\Discriminator(field=\"type\", map={0: \"App\\SurveyBundle\\Entity\\Question\", 3: \"App\\SurveyBundle\\Entity\\MultipleChoice\", 2: \"App\\SurveyBundle\\Entity\\SingleChoice\", 1: \"App\\SurveyBundle\\Entity\\LikertScale\"})\r\n * @ORM\\HasLifeCycleCallbacks\r\n */\r\nabstract class Question {\r\n    /**\r\n     * Question type\r\n     */\r\n    public function getQuestionType() {\r\n        if ($this instanceof MultipleChoice) {\r\n            return 3;\r\n        } else if($this instanceof SingleChoice) {\r\n            return 2;\r\n        } else if($this instanceof LikertScale) {\r\n            return 1;\r\n        } else {\r\n            return 0;\r\n        }\r\n    } \r\n}\r\n```\r\n\r\n...extended by three sub classes, using this yml annotation file (Example for the \"SingleChoice\" extended class).\r\n\r\n```\r\nApp\\SurveyBundle\\Entity\\SingleChoice:\r\n    exclusion_policy: ALL\r\n    properties:\r\n        id:\r\n            expose: true\r\n            type: integer\r\n            groups: [default]\r\n        questionText:\r\n            expose: true\r\n            serialized_name: questionText\r\n            type: string\r\n            groups: [default]\r\n        created:\r\n            expose: true\r\n            type: DateTime\r\n            groups: [default]\r\n        survey:\r\n            expose: true\r\n            type: App\\SurveyBundle\\Entity\\Survey\r\n            groups: [deserialization]\r\n    virtual_properties:\r\n        getQuestionType:\r\n            serialized_name: type\r\n            type: integer\r\n            groups: [default]\r\n```\r\n\r\nThe abstract class \"Question\" is used by my \"Survey\" class, which holds an ArrayCollection of Questions.\r\n\r\n```\r\nApp\\SurveyBundle\\Entity\\Survey:\r\n    exclusion_policy: ALL\r\n    properties:\r\n        id:\r\n            expose: true\r\n            type: integer\r\n            groups: [default]\r\n        created:\r\n            expose: true\r\n            type: DateTime\r\n            groups: [default]\r\n        name:\r\n            expose: true\r\n            type: string\r\n            groups: [default]\r\n        questions:\r\n            expose: true\r\n            type: ArrayCollection<App\\SurveyBundle\\Entity\\Question>\r\n            groups: [default]\r\n```\r\n\r\nWhen serializing a survey\r\n\r\n```\r\n$serializer->serialize($survey, 'json', SerializationContext::create()->enableMaxDepthChecks()->setGroups(array('default'));\r\n```\r\n\r\n...this is the output \r\n\r\n```\r\n\r\n{\r\n    id: 1,\r\n    created: \"2015-03-02T10:48:53+0100\",\r\n    name: \"test\",\r\n    questions: [\r\n        { },\r\n        { },\r\n        { },\r\n        { },\r\n        { },\r\n        { },\r\n        { }\r\n    ]\r\n}\r\n```\r\n\r\nAre anyone else seeing this kind of behavior? Am I doing something wrong? "},"comment":{"url":"https://api.github.com/repos/schmittjoh/serializer/issues/comments/77819505","html_url":"https://github.com/schmittjoh/serializer/issues/411#issuecomment-77819505","issue_url":"https://api.github.com/repos/schmittjoh/serializer/issues/411","id":77819505,"user":{"login":"erichfosse","id":3193085,"avatar_url":"https://avatars.githubusercontent.com/u/3193085?v=3","gravatar_id":"","url":"https://api.github.com/users/erichfosse","html_url":"https://github.com/erichfosse","followers_url":"https://api.github.com/users/erichfosse/followers","following_url":"https://api.github.com/users/erichfosse/following{/other_user}","gists_url":"https://api.github.com/users/erichfosse/gists{/gist_id}","starred_url":"https://api.github.com/users/erichfosse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erichfosse/subscriptions","organizations_url":"https://api.github.com/users/erichfosse/orgs","repos_url":"https://api.github.com/users/erichfosse/repos","events_url":"https://api.github.com/users/erichfosse/events{/privacy}","received_events_url":"https://api.github.com/users/erichfosse/received_events","type":"User","site_admin":false},"created_at":"2015-03-09T09:03:46Z","updated_at":"2015-03-09T09:03:46Z","body":"+1"}}