Skip to content

Commit 496ed4a

Browse files
humandbweaverryan
authored andcommitted
Using namespaces for Person definition
1 parent bce81b3 commit 496ed4a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

components/serializer.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ Serializing an object
5151
For the sake of this example, let's ssume the following class already
5252
exists in our project::
5353

54+
namespace Acme;
55+
5456
class Person
5557
{
5658
private $age;
@@ -82,7 +84,7 @@ exists in our project::
8284
Now, if we want to serialize this object into JSON, we only need to
8385
use the Serializer service created before::
8486

85-
$person = new Person();
87+
$person = new Acme\Person();
8688
$person->setName('foo');
8789
$person->setAge(99);
8890

@@ -105,7 +107,7 @@ of the `People` class would be encoded in XML format::
105107
</person>
106108
EOF;
107109

108-
$person = $serializer->deserialize($data,'Person','xml');
110+
$person = $serializer->deserialize($data,'Acme\Person','xml');
109111

110112
In this case, `Serializer::deserialize` needs three parameters:
111113

0 commit comments

Comments
 (0)