schmittjoh/JMSSerializerBundle — Issue #89: AccessType - Not working for unserialization
Author: remialvado
Created: 2012-03-08 13:25:43+00:00
State: open

Hi,

I've created a very basic Img class that I want to serialize/unserialize. I've defined a "type" property which could only be "main" or not be present at all.

This property is defined as this :
```
/**
* @Type("string")
* @XmlAttribute
* @SerializedName("type")
* @Since("1")
*/
protected $type = null;
```

My Class declaration is also really simple :
```php
/**
* @AccessType("public_method")
* @XmlRoot("img")
*/
class Img {
```

And finally my setter method for the type property :
```php
public function setType($type) {
$type = ($type === self::TYPE_MAIN) ? self::TYPE_MAIN : null;
$this->type = $type;
}
```

When I try to unserialize a simple version of an "img" node with an invalid value for "type", the setter method should be called and $type should be replaced by "null".
Problem : it's not. I've added some debug trace in my setter method and the unserializer does not use it even I've specified an AccessType to "public_method".