Skip to content

Commit 013b6d1

Browse files
committed
Tweaks
1 parent 9627986 commit 013b6d1

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

components/var_exporter.rst

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ file looks like this::
9090
[]
9191
);
9292

93+
.. _instantiating-php-classes:
94+
9395
Instantiating & Hydrating PHP Classes
9496
-------------------------------------
9597

@@ -101,18 +103,18 @@ their properties without calling their constructors or any other methods::
101103

102104
use Symfony\Component\VarExporter\Instantiator;
103105

104-
// Creates an empty instance of Foo
106+
// creates an empty instance of Foo
105107
$fooObject = Instantiator::instantiate(Foo::class);
106108

107-
// Creates a Foo instance and sets one of its properties
109+
// creates a Foo instance and sets one of its properties
108110
$fooObject = Instantiator::instantiate(Foo::class, ['propertyName' => $propertyValue]);
109111

110-
The instantiator also allows you to populate the property of a parent class. Assuming
111-
``Bar`` is the parent class of ``Foo`` and defines a ``privateBarProperty`` attribute::
112+
The instantiator can also populate the property of a parent class. Assuming ``Bar``
113+
is the parent class of ``Foo`` and defines a ``privateBarProperty`` attribute::
112114

113115
use Symfony\Component\VarExporter\Instantiator;
114116

115-
// Creates a Foo instance and sets a private property defined on its parent Bar class
117+
// creates a Foo instance and sets a private property defined on its parent Bar class
116118
$fooObject = Instantiator::instantiate(Foo::class, [], [
117119
Bar::class => ['privateBarProperty' => $propertyValue],
118120
]);
@@ -122,7 +124,7 @@ created by using the special ``"\0"`` property name to define their internal val
122124

123125
use Symfony\Component\VarExporter\Instantiator;
124126

125-
// Creates an SplObjectStorage where $info1 is associated with $object1, etc.
127+
// creates an SplObjectStorage where $info1 is associated with $object1, etc.
126128
$theObject = Instantiator::instantiate(SplObjectStorage::class, [
127129
"\0" => [$object1, $info1, $object2, $info2...],
128130
]);
@@ -135,8 +137,8 @@ created by using the special ``"\0"`` property name to define their internal val
135137
Hydrator
136138
~~~~~~~~
137139

138-
The instantiator assumes the object you want to populate doesn't exist yet.
139-
Somehow, you may want to fill properties of an already existing object. This is
140+
Instead of populating objects that don't exist yet (using the instantiator),
141+
sometimes you want to populate properties of an already existing object. This is
140142
the goal of the :class:`Symfony\\Component\\VarExporter\\Hydrator`. Here is a
141143
basic usage of the hydrator populating a property of an object::
142144

@@ -145,8 +147,8 @@ basic usage of the hydrator populating a property of an object::
145147
$object = new Foo();
146148
Hydrator::hydrate($object, ['propertyName' => $propertyValue]);
147149

148-
The hydrator also allows you to populate the property of a parent class. Assuming
149-
``Bar`` is the parent class of ``Foo`` and defines a ``privateBarProperty`` attribute::
150+
The hydrator can also populate the property of a parent class. Assuming ``Bar``
151+
is the parent class of ``Foo`` and defines a ``privateBarProperty`` attribute::
150152

151153
use Symfony\Component\VarExporter\Hydrator;
152154

@@ -155,15 +157,15 @@ The hydrator also allows you to populate the property of a parent class. Assumin
155157
Bar::class => ['privateBarProperty' => $propertyValue],
156158
]);
157159

158-
// Alternatively, you can use the special "\0" syntax
160+
// alternatively, you can use the special "\0" syntax
159161
Hydrator::hydrate($object, ["\0Bar\0privateBarProperty" => $propertyValue]);
160162

161163
Instances of ``ArrayObject``, ``ArrayIterator`` and ``SplObjectHash`` can be
162164
populated by using the special ``"\0"`` property name to define their internal value::
163165

164166
use Symfony\Component\VarExporter\Hydrator;
165167

166-
// Creates an SplObjectHash where $info1 is associated with $object1, etc.
168+
// creates an SplObjectHash where $info1 is associated with $object1, etc.
167169
$storage = new SplObjectStorage();
168170
Hydrator::hydrate($storage, [
169171
"\0" => [$object1, $info1, $object2, $info2...],

0 commit comments

Comments
 (0)