{"action":"opened","issue":{"url":"https://api.github.com/repos/symfony/symfony/issues/28961","repository_url":"https://api.github.com/repos/symfony/symfony","labels_url":"https://api.github.com/repos/symfony/symfony/issues/28961/labels{/name}","comments_url":"https://api.github.com/repos/symfony/symfony/issues/28961/comments","events_url":"https://api.github.com/repos/symfony/symfony/issues/28961/events","html_url":"https://github.com/symfony/symfony/issues/28961","id":373065895,"node_id":"MDU6SXNzdWUzNzMwNjU4OTU=","number":28961,"title":"[PropertyAccessor] Unable to write to singular property using setter while plural adder/remover exist","user":{"login":"karser","id":1675033,"node_id":"MDQ6VXNlcjE2NzUwMzM=","avatar_url":"https://avatars3.githubusercontent.com/u/1675033?v=4","gravatar_id":"","url":"https://api.github.com/users/karser","html_url":"https://github.com/karser","followers_url":"https://api.github.com/users/karser/followers","following_url":"https://api.github.com/users/karser/following{/other_user}","gists_url":"https://api.github.com/users/karser/gists{/gist_id}","starred_url":"https://api.github.com/users/karser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karser/subscriptions","organizations_url":"https://api.github.com/users/karser/orgs","repos_url":"https://api.github.com/users/karser/repos","events_url":"https://api.github.com/users/karser/events{/privacy}","received_events_url":"https://api.github.com/users/karser/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-10-23T15:37:04Z","updated_at":"2018-10-23T15:37:04Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"Hi there, I found a bug that exists in 3.4, 4.1 and master branches.\r\nI'll submit a PR soon.\r\n\r\nWhat's happening:\r\nThat's the priorities issue: `findAdderAndRemover('User', 'email')` is called earlier than `$this->isMethodAccessible('User', 'setEmail', 1)`\r\n\r\nThe reproducer:\r\n```\r\n$user = new UserWithSingularAndPluralProps();\r\n$accessor = PropertyAccess::createPropertyAccessor();\r\n\r\nif ($accessor->isWritable($user, 'email')) {\r\n    $accessor->setValue($user, 'email', 'test@email.com');\r\n}\r\n```\r\nHere is User entity that has `email` and `emails` fields:\r\n```\r\n/**\r\n * Notice we don't have getter/setter for emails\r\n * because we count on adder/remover\r\n */\r\nclass UserWithSingularAndPluralProps\r\n{\r\n    /** @var string|null */\r\n    private $email;\r\n\r\n    /** @var array */\r\n    private $emails = [];\r\n\r\n    /**\r\n     * @return null|string\r\n     */\r\n    public function getEmail(): ?string\r\n    {\r\n        return $this->email;\r\n    }\r\n\r\n    /**\r\n     * @param null|string $email\r\n     */\r\n    public function setEmail(?string $email): void\r\n    {\r\n        $this->email = $email;\r\n    }\r\n\r\n    /**\r\n     * @return array\r\n     */\r\n    public function getEmails(): array\r\n    {\r\n        return $this->emails;\r\n    }\r\n\r\n    /**\r\n     * @param string $email\r\n     */\r\n    public function addEmail(string $email): void\r\n    {\r\n        $this->emails[] = $email;\r\n    }\r\n\r\n    /**\r\n     * @param string $email\r\n     */\r\n    public function removeEmail(string $email): void\r\n    {\r\n        $this->emails = array_diff($this->emails, [$email]);\r\n    }\r\n}\r\n```\r\n\r\nExpected result: the value is assigned to user.email.\r\n\r\nActual error:\r\n`Invalid argument supplied for foreach() in symfony/src/Symfony/Component/PropertyAccess/PropertyAccessor.php line 576`"}}
{"actor":{"display_login":"karser"}}