{"action":"created","issue":{"url":"https://api.github.com/repos/thephpleague/fractal/issues/124","labels_url":"https://api.github.com/repos/thephpleague/fractal/issues/124/labels{/name}","comments_url":"https://api.github.com/repos/thephpleague/fractal/issues/124/comments","events_url":"https://api.github.com/repos/thephpleague/fractal/issues/124/events","html_url":"https://github.com/thephpleague/fractal/issues/124","id":48688846,"number":124,"title":"Return a null resource?","user":{"login":"troygilbert","id":146465,"avatar_url":"https://avatars.githubusercontent.com/u/146465?v=3","gravatar_id":"","url":"https://api.github.com/users/troygilbert","html_url":"https://github.com/troygilbert","followers_url":"https://api.github.com/users/troygilbert/followers","following_url":"https://api.github.com/users/troygilbert/following{/other_user}","gists_url":"https://api.github.com/users/troygilbert/gists{/gist_id}","starred_url":"https://api.github.com/users/troygilbert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/troygilbert/subscriptions","organizations_url":"https://api.github.com/users/troygilbert/orgs","repos_url":"https://api.github.com/users/troygilbert/repos","events_url":"https://api.github.com/users/troygilbert/events{/privacy}","received_events_url":"https://api.github.com/users/troygilbert/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2014-11-13T20:39:42Z","updated_at":"2015-09-21T16:42:53Z","closed_at":"2014-11-16T16:41:20Z","body":"I've got a resource with a custom transformer. It has some available includes for other resources with custom transformers. Sometimes, those other resources are null. If that child resource is included, I get an error that you can't transform a null value (due to type hinting as in the examples). I can fix that by providing a null default value to the `transform()` method, and my `transform()` method can return null, but I then get an exception thrown on an attempted `array_merge()` call where Fractal tries to merge the return value with another array. How can I avoid this? What's the correct way for me to indicate a child resource is not present (null)?"},"comment":{"url":"https://api.github.com/repos/thephpleague/fractal/issues/comments/142038212","html_url":"https://github.com/thephpleague/fractal/issues/124#issuecomment-142038212","issue_url":"https://api.github.com/repos/thephpleague/fractal/issues/124","id":142038212,"user":{"login":"alexglue","id":1948911,"avatar_url":"https://avatars.githubusercontent.com/u/1948911?v=3","gravatar_id":"","url":"https://api.github.com/users/alexglue","html_url":"https://github.com/alexglue","followers_url":"https://api.github.com/users/alexglue/followers","following_url":"https://api.github.com/users/alexglue/following{/other_user}","gists_url":"https://api.github.com/users/alexglue/gists{/gist_id}","starred_url":"https://api.github.com/users/alexglue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexglue/subscriptions","organizations_url":"https://api.github.com/users/alexglue/orgs","repos_url":"https://api.github.com/users/alexglue/repos","events_url":"https://api.github.com/users/alexglue/events{/privacy}","received_events_url":"https://api.github.com/users/alexglue/received_events","type":"User","site_admin":false},"created_at":"2015-09-21T16:42:53Z","updated_at":"2015-09-21T16:42:53Z","body":"@troygilbert @rickshawhobo @philsturgeon The simple way to fix your trouble is to use something like this:\r\n\r\n```\r\n\tpublic function includeAdditional(MainObject $object)\r\n\t{\r\n                //MainObject has nullable property additional:\r\n\t\treturn $object->additional ? $this->item($object->additional, new AdditionalTransformer(), 'dictionary') : $this->null();\r\n\t}"}}