Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Serializer] Example from documentation does not work #8576

Closed
@javiereguiluz

Description

@javiereguiluz

Moved fromsymfony/symfony#24783 created by@enumag


QA
Bug report?yes
Feature request?no
BC Break report?no
RFC?no
Symfony version3.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

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


      [8]ページ先頭

      ©2009-2025 Movatter.jp