Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.3k
Closed
Description
Moved fromsymfony/symfony#24783 created by@enumag
| Q | A |
|---|---|
| Bug report? | yes |
| Feature request? | no |
| BC Break report? | no |
| RFC? | no |
| Symfony version | 3.3 |
I was reading the documentation of Symfony/Serializer component.Here I found info about a new feature in Symfony 3.3, theallow_extra_attributes option. However the example from documentation does not work. This should throw aSymfony\Component\Serializer\Exception\ExtraAttributesException but it does not:
<?phpdeclare(strict_types =1);require__DIR__ .'/vendor/autoload.php';(new \Symfony\Component\Dotenv\Dotenv())->load(__DIR__.'/.env');$kernel =new \App\Kernel('dev',true);$kernel->boot();$container =$kernel->getContainer();$serializer =$container->get('serializer');class Person{private$age;private$name;private$sportsman;// GetterspublicfunctiongetName(){return$this->name;}publicfunctiongetAge(){return$this->age;}// IsserspublicfunctionisSportsman(){return$this->sportsman;}// SetterspublicfunctionsetName($name){$this->name =$name;}publicfunctionsetAge($age){$this->age =$age;}publicfunctionsetSportsman($sportsman){$this->sportsman =$sportsman;}}$data =<<<EOF<person> <name>foo</name> <age>99</age> <city>Paris</city></person>EOF;$person =$serializer->deserialize($data,'Person','xml',array('allow_extra_attributes' =>false,));var_export($person);
cc@juliendidier ref#19958,#6975