Skip to content

Commit 7aec9b6

Browse files
committed
Merge branch '6.3' into 6.4
* 6.3: Fix wording at `property_access.rst`
2 parents 4fc01cf + c99dd22 commit 7aec9b6

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

components/property_access.rst

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -459,20 +459,21 @@ Using non-standard adder/remover methods
459459
Sometimes, adder and remover methods don't use the standard ``add`` or ``remove`` prefix, like in this example::
460460

461461
// ...
462-
class PeopleList
462+
class Team
463463
{
464464
// ...
465465

466-
public function joinPeople(string $people): void
466+
public function joinTeam(string $person): void
467467
{
468-
$this->peoples[] = $people;
468+
$this->team[] = $person;
469469
}
470470

471-
public function leavePeople(string $people): void
471+
public function leaveTeam(string $person): void
472472
{
473-
foreach ($this->peoples as $id => $item) {
474-
if ($people === $item) {
475-
unset($this->peoples[$id]);
473+
foreach ($this->team as $id => $item) {
474+
if ($person === $item) {
475+
unset($this->team[$id]);
476+
476477
break;
477478
}
478479
}
@@ -482,12 +483,12 @@ Sometimes, adder and remover methods don't use the standard ``add`` or ``remove`
482483
use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor;
483484
use Symfony\Component\PropertyAccess\PropertyAccessor;
484485

485-
$list = new PeopleList();
486+
$list = new Team();
486487
$reflectionExtractor = new ReflectionExtractor(null, null, ['join', 'leave']);
487488
$propertyAccessor = new PropertyAccessor(PropertyAccessor::DISALLOW_MAGIC_METHODS, PropertyAccessor::THROW_ON_INVALID_PROPERTY_PATH, null, $reflectionExtractor, $reflectionExtractor);
488-
$propertyAccessor->setValue($person, 'peoples', ['kevin', 'wouter']);
489+
$propertyAccessor->setValue($person, 'team', ['kevin', 'wouter']);
489490

490-
var_dump($person->getPeoples()); // ['kevin', 'wouter']
491+
var_dump($person->getTeam()); // ['kevin', 'wouter']
491492

492493
Instead of calling ``add<SingularOfThePropertyName>()`` and ``remove<SingularOfThePropertyName>()``, the PropertyAccess
493494
component will call ``join<SingularOfThePropertyName>()`` and ``leave<SingularOfThePropertyName>()`` methods.

0 commit comments

Comments
 (0)