{"action":"created","issue":{"url":"https://api.github.com/repos/symfony/symfony/issues/15524","labels_url":"https://api.github.com/repos/symfony/symfony/issues/15524/labels{/name}","comments_url":"https://api.github.com/repos/symfony/symfony/issues/15524/comments","events_url":"https://api.github.com/repos/symfony/symfony/issues/15524/events","html_url":"https://github.com/symfony/symfony/issues/15524","id":100558160,"number":15524,"title":"[OptionsResolver] array of instance allowed type","user":{"login":"Soullivaneuh","id":1698357,"avatar_url":"https://avatars.githubusercontent.com/u/1698357?v=3","gravatar_id":"","url":"https://api.github.com/users/Soullivaneuh","html_url":"https://github.com/Soullivaneuh","followers_url":"https://api.github.com/users/Soullivaneuh/followers","following_url":"https://api.github.com/users/Soullivaneuh/following{/other_user}","gists_url":"https://api.github.com/users/Soullivaneuh/gists{/gist_id}","starred_url":"https://api.github.com/users/Soullivaneuh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Soullivaneuh/subscriptions","organizations_url":"https://api.github.com/users/Soullivaneuh/orgs","repos_url":"https://api.github.com/users/Soullivaneuh/repos","events_url":"https://api.github.com/users/Soullivaneuh/events{/privacy}","received_events_url":"https://api.github.com/users/Soullivaneuh/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-08-12T14:39:22Z","updated_at":"2015-08-12T16:57:05Z","closed_at":null,"body":"It could be nice to have possibility to make this king of requirement:\r\n\r\n```php\r\n->setAllowedTypes('attachments', '\\Swift_Attachment[]')\r\n```\r\n\r\nBasically, for this case, an array of `Swift_Attachment` objects.\r\n\r\nIt could be a good beginning waiting #4833."},"comment":{"url":"https://api.github.com/repos/symfony/symfony/issues/comments/130369403","html_url":"https://github.com/symfony/symfony/issues/15524#issuecomment-130369403","issue_url":"https://api.github.com/repos/symfony/symfony/issues/15524","id":130369403,"user":{"login":"stof","id":439401,"avatar_url":"https://avatars.githubusercontent.com/u/439401?v=3","gravatar_id":"","url":"https://api.github.com/users/stof","html_url":"https://github.com/stof","followers_url":"https://api.github.com/users/stof/followers","following_url":"https://api.github.com/users/stof/following{/other_user}","gists_url":"https://api.github.com/users/stof/gists{/gist_id}","starred_url":"https://api.github.com/users/stof/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stof/subscriptions","organizations_url":"https://api.github.com/users/stof/orgs","repos_url":"https://api.github.com/users/stof/repos","events_url":"https://api.github.com/users/stof/events{/privacy}","received_events_url":"https://api.github.com/users/stof/received_events","type":"User","site_admin":false},"created_at":"2015-08-12T16:57:05Z","updated_at":"2015-08-12T16:57:05Z","body":"@Soullivaneuh the issue with that is that it cannot be implemented easily (it requires some parsing of the string, and looping over the array rther than just checking the value).\r\n\r\nThere is a workaround though:\r\n\r\n```php\r\n$resolver->setAllowedTypes('attachments', 'array')\r\n    ->setAllowedValues('attachments', function (array $attachments) {\r\n        // we already know it is an array as types are validated first\r\n\r\n        foreach ($attachments as $attachment) {\r\n            if (!$attachment instanceof \\Swift_Attachment) {\r\n                return false;\r\n            }\r\n        }\r\n\r\n        return true;\r\n    });\r\n```"}}