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

Appearance settings

Commit 6ad9a5a

Browse filesBrowse files
committed
minor #19092 Fix wording at property_access.rst (phansys)
This PR was merged into the 5.4 branch. Discussion ---------- Fix wording at `property_access.rst` "people" is the plural form for "person". Commits ------- 4658deb Fix wording at `property_access.rst`
2 parents 51a5af7 + 4658deb commit 6ad9a5a
Copy full SHA for 6ad9a5a

File tree

Expand file treeCollapse file tree

1 file changed

+11
-10
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+11
-10
lines changed

‎components/property_access.rst

Copy file name to clipboardExpand all lines: components/property_access.rst
+11-10Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -406,20 +406,21 @@ Using non-standard adder/remover methods
406406
Sometimes, adder and remover methods don't use the standard ``add`` or ``remove`` prefix, like in this example::
407407

408408
// ...
409-
class PeopleList
409+
class Team
410410
{
411411
// ...
412412

413-
public function joinPeople(string $people): void
413+
public function joinTeam(string $person): void
414414
{
415-
$this->peoples[] = $people;
415+
$this->team[] = $person;
416416
}
417417

418-
public function leavePeople(string $people): void
418+
public function leaveTeam(string $person): void
419419
{
420-
foreach ($this->peoples as $id => $item) {
421-
if ($people === $item) {
422-
unset($this->peoples[$id]);
420+
foreach ($this->team as $id => $item) {
421+
if ($person === $item) {
422+
unset($this->team[$id]);
423+
423424
break;
424425
}
425426
}
@@ -429,12 +430,12 @@ Sometimes, adder and remover methods don't use the standard ``add`` or ``remove`
429430
use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor;
430431
use Symfony\Component\PropertyAccess\PropertyAccessor;
431432

432-
$list = new PeopleList();
433+
$list = new Team();
433434
$reflectionExtractor = new ReflectionExtractor(null, null, ['join', 'leave']);
434435
$propertyAccessor = new PropertyAccessor(PropertyAccessor::DISALLOW_MAGIC_METHODS, PropertyAccessor::THROW_ON_INVALID_PROPERTY_PATH, null, $reflectionExtractor, $reflectionExtractor);
435-
$propertyAccessor->setValue($person, 'peoples', ['kevin', 'wouter']);
436+
$propertyAccessor->setValue($person, 'team', ['kevin', 'wouter']);
436437

437-
var_dump($person->getPeoples()); // ['kevin', 'wouter']
438+
var_dump($person->getTeam()); // ['kevin', 'wouter']
438439

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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.