8000 PropertyAccessor::writeProperty() throws misleading NoSuchPropertyException · Issue #24742 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
PropertyAccessor::writeProperty() throws misleading NoSuchPropertyException #24742
Closed
@d42ohpaz

Description

@d42ohpaz
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version master

I had (incorrectly) architected myself into a situation where I have an entity without a setter for a property, and when trying to hydrate the entity from a FormType, I would get the following exception:

Could not determine access type for property "property" in class "AppBundle\Entity\MyEntity".

I'm not always a smart man, so it wasn't immediately obvious what that message meant. It took me dumping the contents of the $access array before it clicked:

/var/www/vendor/symfony/symfony/src/Symfony/Component/PropertyAccess/PropertyAccessor.php:653:
array(3) {
[0] =>
bool(true)
[1] =>
int(4)
[2] =>
string(190) "Neither the property "property" nor one of the methods "addProperty()"/"removeProperty()", "setProperty()", "property()", "__set()" or "__call()" exist and have public access in class "AppBundle\Entity\MyEntity"."
}

Long story short: I believe the NoSuchPropertyException that is thrown should include the $access[self::ACCESS_NAME] if it exists.

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0